2

This really seems like I should be able to do this, but I am running into some problems. I want to import 3D Analyst with python, in the same way I import Spatial Analyst, but it returns an error.

For Spatial Analyst I use the following:

from arcpy.sa import *

This allows me to use the spatial analyst functions in python scripts outside of ArcMap. I want to do the same with 3D analyst, but I am running into an error.

I really feel like it should just be:

from arcpy.3D import *

I also tried arcpy.3d, but either way I get the error:

Parsing error <type 'exceptions.SyntaxError'>: invalid syntax (line 1)
  • I know that I can use a 3D Analyst tool with say: arcpy.aspect_3d(), but I am mainly wondering if I can import the 3D Analyst library the same way. – Cody Brown Aug 23 '12 at 17:36
  • 3
    Spatial Analyst is a module within arcpy which allows the from ___ import * syntax. 3D is not a module so you can't import it that way. – twospeeder Aug 23 '12 at 18:10
  • Thanks for the info @twospeeder I was just starting to think the same thing. – Cody Brown Aug 23 '12 at 18:15
  • 1
    @twospeeder - You should post that as an official answer so that it is searchable by other people with potentially the same question. – Get Spatial Aug 23 '12 at 18:25
1

Spatial Analyst is a module within arcpy which allows the from _ import * syntax. 3D is not a module so you can't import it that way.

  • @CodyBrown suggest you unaccept this incorrect answer. – user2856 Jul 28 '17 at 4:44
6

Sorry for bumping this old question, but a Python module's name cannot begin with a number, so arcpy.3d will never work. To import the module, you'll need to reference ddd:

from arcpy.ddd import *

or:

from arcpy import ddd

A geoprocessing tool can be referenced in arcpy by either arcpy._ or arcpy... For 3D Analyst, the toolbox alias is '3d' but the module name is 'ddd'.

  • 1
    Thank you for adding an answer that is correct. It's a little sad that a patently, demonstrably false answer was accepted as correct on this question. – Jason Scheirer Mar 10 '16 at 2:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.