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)
4
  • 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, 2012 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, 2012 at 18:10
  • Thanks for the info @twospeeder I was just starting to think the same thing.
    – Cody Brown
    Aug 23, 2012 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. Aug 23, 2012 at 18:25

2 Answers 2

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
  • 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. Mar 10, 2016 at 2:48
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.

1
  • @CodyBrown suggest you unaccept this incorrect answer.
    – user2856
    Jul 28, 2017 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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