Bookmarks to feature help

03-14-2019 10:31 AM
New Contributor

I am trying to use the list bookmarks to feature code from the ArcGIS Help page and I am getting an error. How can I fix this? I am not super great with code so I just replaced the paths in the sample, not sure if that was the correct thing to do. 

Anyway Thanks!

ListBookmarks—Help | ArcGIS Desktop 


Runtime error  Traceback (most recent call last):   File "<string>", line 19, in <module>   File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\", line 1806, in CreateFeatureclass     raise e ExecuteError: ERROR 000622: Failed to execute (Create Feature Class). Parameters are not valid. ERROR 000628: Cannot set input into parameter spatial_reference.

import arcpy, osmxd = arcpy.mapping.MapDocument(r"C:\Users\40002\Documents\My_Maps\mxd\Colorado\Stony.mxd")outFC = r'C:\Users\40002\Documents\My_Maps\Colorado_Roads.gdb\Bookmarks'template = r'C:\Users\40002\Documents\My_Maps\Colorado_Roads.gdb\Template'if arcpy.Exists(outFC):    arcpy.Delete_management(outFC)arcpy.CreateFeatureclass_management(os.path.dirname(outFC),                                    os.path.basename(outFC),                                      "POLYGON", template,                                      spatial_reference=template)cur = arcpy.da.InsertCursor(outFC, ["SHAPE@", "Name"])array = arcpy.Array()for bkmk in arcpy.mapping.ListBookmarks(mxd):    array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMin))    array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMax))    array.add(arcpy.Point(bkmk.extent.XMax, bkmk.extent.YMax))    array.add(arcpy.Point(bkmk.extent.XMax, bkmk.extent.YMin))    # To close the polygon, add the first point again    array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMin))    cur.insertRow([arcpy.Polygon(array),])    array.removeAll()
Tags (2)
0 Kudos
0 Replies