Closed JudTown17 closed 9 years ago
Similar errors occur after running TestNumberFeatures.py and TestPointTargetGRG.py.
Test Number Features:
test_number_features:
[exec] scratch.gdb already exists
[exec] Shape type: Polygon
[exec] ERROR: Object: CreateObject cannot open map document
[exec] ERROR: Executing: NumberFeatures "C:\Data\Defense Solutions\solution
s-geoprocessing-toolbox\operational_graphics\data\geodatabases\test_clearing_ope
rations.gdb\AO" "C:\Data\Defense Solutions\solutions-geoprocessing-toolbox\opera
tional_graphics\data\geodatabases\test_clearing_operations.gdb\Structures" Numbe
r "C:\Data\Defense Solutions\solutions-geoprocessing-toolbox\operational_graphic
s\data\geodatabases\scratch.gdb\NumberFeaturesOutput"
[exec] Start Time: Fri Aug 14 09:42:04 2015
[exec] Executing (Number Features Script): NumberFeaturesScript "C:\Data\De
fense Solutions\solutions-geoprocessing-toolbox\operational_graphics\data\geodat
abases\test_clearing_operations.gdb\AO" "C:\Data\Defense Solutions\solutions-geo
processing-toolbox\operational_graphics\data\geodatabases\test_clearing_operatio
ns.gdb\Structures" Number "C:\Data\Defense Solutions\solutions-geoprocessing-too
lbox\operational_graphics\data\geodatabases\scratch.gdb\NumberFeaturesOutput"
[exec] Start Time: Fri Aug 14 09:42:04 2015
[exec] Running script NumberFeaturesScript...
[exec] Shape type: Polygon
[exec] Object: CreateObject cannot open map document
[exec] Completed script NumberFeaturesScript...
[exec] Failed to execute (Number Features Script).
[exec] Failed at Fri Aug 14 09:42:04 2015 (Elapsed Time: 0.34 seconds)
[exec] Failed to execute (NumberFeatures).
[exec] Failed at Fri Aug 14 09:42:04 2015 (Elapsed Time: 0.82 seconds)
[exec] Executing: NumberFeatures "C:\Data\Defense Solutions\solutions-geopr
ocessing-toolbox\operational_graphics\data\geodatabases\test_clearing_operations
.gdb\AO" "C:\Data\Defense Solutions\solutions-geoprocessing-toolbox\operational_
graphics\data\geodatabases\test_clearing_operations.gdb\Structures" Number "C:\D
ata\Defense Solutions\solutions-geoprocessing-toolbox\operational_graphics\data\
geodatabases\scratch.gdb\NumberFeaturesOutput"
[exec] Start Time: Fri Aug 14 09:42:04 2015
[exec] Executing (Number Features Script): NumberFeaturesScript "C:\Data\De
fense Solutions\solutions-geoprocessing-toolbox\operational_graphics\data\geodat
abases\test_clearing_operations.gdb\AO" "C:\Data\Defense Solutions\solutions-geo
processing-toolbox\operational_graphics\data\geodatabases\test_clearing_operatio
ns.gdb\Structures" Number "C:\Data\Defense Solutions\solutions-geoprocessing-too
lbox\operational_graphics\data\geodatabases\scratch.gdb\NumberFeaturesOutput"
[exec] Start Time: Fri Aug 14 09:42:04 2015
[exec] Running script NumberFeaturesScript...
[exec] Shape type: Polygon
[exec] Object: CreateObject cannot open map document
[exec] Completed script NumberFeaturesScript...
[exec] Failed to execute (Number Features Script).
[exec] Failed at Fri Aug 14 09:42:04 2015 (Elapsed Time: 0.34 seconds)
[exec] Failed to execute (NumberFeatures).
[exec] Failed at Fri Aug 14 09:42:04 2015 (Elapsed Time: 0.82 seconds)
[exec] Result: -1
Test Point Target GRG:
test_point_target_grg:
[exec] scratch.gdb already exists
[exec] Starting Test: TestPointTargetGRG.
[exec] ERROR: Executing: PointTargetGRG "C:\Data\Defense Solutions\solution
s-geoprocessing-toolbox\operational_graphics\data\geodatabases\test_clearing_ope
rations.gdb\CenterPoint" 10 10 100 100 Meters "Feature Set" Upper-Left Alpha-Num
eric "C:\Data\Defense Solutions\solutions-geoprocessing-toolbox\operational_grap
hics\data\geodatabases\scratch.gdb\PointTargetGRGOutput"
[exec] Start Time: Fri Aug 14 15:38:59 2015
[exec] Executing (Point Target GRG Script): PointTargetGRGScript "C:\Data\D
efense Solutions\solutions-geoprocessing-toolbox\operational_graphics\data\geoda
tabases\test_clearing_operations.gdb\CenterPoint" 10 10 100 100 Meters "Feature
Set" Alpha-Numeric "C:\Data\Defense Solutions\solutions-geoprocessing-toolbox\op
erational_graphics\data\geodatabases\scratch.gdb\PointTargetGRGOutput" Upper-Lef
t
[exec] Start Time: Fri Aug 14 15:38:59 2015
[exec] Running script PointTargetGRGScript...
[exec] Failed script PointTargetGRGScript...
[exec]
[exec] Traceback (most recent call last):
[exec] File "C:\Data\Defense Solutions\solutions-geoprocessing-toolbox\op
erational_graphics\toolboxes\Scripts\PointTargetGRG.py", line 297, in <module>
[exec] mxd = arcpy.mapping.MapDocument('CURRENT')
[exec] File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\arcobj
ects\mixins.py", line 612, in __init__
[exec] super(MapDocumentMethods, self).__init__(mxd)
[exec] File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\arcobj
ects\_base.py", line 47, in __init__
[exec] for arg in args))
[exec] RuntimeError: Object: CreateObject cannot open map document
[exec]
[exec] Failed to execute (Point Target GRG Script).
[exec] Failed at Fri Aug 14 15:39:00 2015 (Elapsed Time: 0.20 seconds)
[exec] Failed to execute (PointTargetGRG).
[exec] Failed at Fri Aug 14 15:39:00 2015 (Elapsed Time: 0.57 seconds)
[exec] Result: -1
OK so I checked it out and the stuff I'm looking for is in the capability folder, in the PointOfOrigin.py file. There's a lot of tool-specific code but the control we want to try to use to change behavior between ArcMap, ArcGIS Pro, and everything else are around lines 252 through 466.
But to boil it down to the basics:
desktopVersion = ["10.2.2","10.3","10.3.1"]
proVersion = ["1.0", "1.1"]
gisVersion = arcpy.GetInstallInfo()["Version"]
if gisVersion in desktopVersion: #This is ArcGIS Desktkop 10.3 or 10.2.2
mxd = None
try: # what if we are running this from ArcCatalog with no MXD?
mxd = arcpy.mapping.MapDocument('CURRENT')
except: # if so, then just skip this part...
arcpy.AddWarning("Tool is not run in ArcMap, skipping symbolization scheme.")
else: # otherwise lets add the stuff to our current data frame in our map.
df = arcpy.mapping.ListDataFrames(mxd)[0]
...
...
...
elif gisVersion in proVersion: #This Is ArcGIS Pro 1.0.2 or 1.1
arcpy.AddMessage("Working in ArcGIS Pro " + str(gisVersion))
aprx = arcpy.mp.ArcGISProject(r"current")
...
...
...
else:
arcpy.AddWarning(r"...Could not determine version.\n Looking for ArcMap " + str(desktopVersion) + ", or ArcGIS Pro " + str(proVersion) + ".\n Found " + str(gisVersion))
Now Gary S just did a little bit of code in NumberFeatures.py that negates the need to check for explicit versions.
try: # ArcGIS Pro
from arcpy import mp
for layer in maplist.listLayers():
...
...
except ImportError:
...
You can see the full changes he made in: https://github.com/Esri/solutions-geoprocessing-toolbox/pull/297/files
Fixed in #305