-2

Trying to figure out why my script won't work (I should mention I'm still at an intro level).

This is a script I exported from ArcGIS ModelBuilder which worked fine using that:

# Import arcpy module
import arcpy


# Local variables:
DN700_Less_Than_10m_distance_M2S = "DN700_Less_Than_10m_distance_M2S"
Easement_BND = "C:\\20140211_scripting\\Sample_data.gdb\\Easement_BND"
Output_Feature_Class__3_ = "DN700_Less_Than_10m_distance"
DN700_Less_Than_10m_distance_M2S__2_ = "DN700_Less_Than_10m_distance_M2S"

# Process: Densify
arcpy.Densify_edit(DN700_Less_Than_10m_distance_M2S, "DISTANCE", "1 Meters", "0.1 Meters", "10")

# Process: Feature Vertices To Points
arcpy.FeatureVerticesToPoints_management(DN700_Less_Than_10m_distance_M2S__2_, Output_Feature_Class__3_, "ALL")

# Process: Near
arcpy.Near_analysis(Output_Feature_Class__3_, "Easement_BND", "", "NO_LOCATION", "NO_ANGLE")

Any help would be great!

  • 6
    What/where exactly is the problem? – steffan Feb 11 '14 at 11:28
  • 3
    Can you edit your Question to replace "won't work" with the error message you are seeing, please? – PolyGeo Feb 11 '14 at 11:32
  • AH! Thanks for the advice guys - got the scripted working now! Added in arcpy.env.workspace & arcpy.env.overwriteOutput = true – Brian Feb 12 '14 at 2:31
  • Now that you have your script working can you reward the people who helped by upvoting their Answers (if you have not already) but then especially be sure to Accept (green tick) the one that helped the most. – PolyGeo Feb 12 '14 at 10:22
5

It looks like you referenced layers in your models instead of actual feature classes. This happens whenever you choose a feature layer from the dropdown list, which contains a list of the layers contained in the current map document, rather than browsing for a feature class.

You can do that, but you not only have to have that layer loaded any time you want to run the model/script, but it has to be named exactly the same thing each time.

You should change DN700_Less_Than_10m_distance_M2S and DN700_Less_Than_10m_distance_M2S__2_ to be the path of a feature class like Easement_BND.

You may also want to change Output_Feature_Class__3_ to a feature class rather than a layer reference as well, although it shouldn't be required. As is, it should output that feature class in whatever workspace is set to default, which could be confusing.

3

The path to the output of the FeatureToVertices tool is incomplete, add a workspace of define it using arcpy.env.workspace. And if you don't run your script in ArcMap with the DN700_Less_Than_10m_distance_M2S layer present, the other tools won't work neither for the same reason (workspace not defined).

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.