I am getting the error message for the code:
Traceback (most recent call last):
File "H:\Desktop\Load_shp.py", line 4, in <module>
mxd = arcpy.mapping.MapDocument("CURRENT")
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\mixins.py", line 444, in __init__
super(MapDocumentMethods, self).__init__(mxd)
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\_base.py", line 47, in __init__
for arg in args))
RuntimeError: Object: CreateObject cannot open map document
However, after spending awhile on this, I could write small script that loads the point shp file.
the code is:
import arcpy
# get the map document
mxd = arcpy.mapping.MapDocument(r"C:\Research-gravity\Huff\Santhi\SGravity\StLine.mxd")
# Set the workspace
arcpy.env.workspace = r"C:\Research-gravity\Huff\Santhi\SGravity"
# get the data frame
df = arcpy.mapping.ListDataFrames(mxd,"*")[0]
# create a new layer
newlayer = arcpy.mapping.Layer(r"C:\Research-gravity\Huff\Santhi\SGravity\points.shp")
# add the layer to the map at the bottom of the TOC in data frame 0
arcpy.mapping.AddLayer(df, newlayer,"AUTO_ARRANGE")
# save the mxd file
mxd.save()
del mxd
Now I need to calculate straight line distances for the point shape file. could you please help me?
I greatly appreciate your help.
Thanks
Raj