AnsweredAssumed Answered

Python variables not working in pro sdk

Question asked by nicholas.ferri@aecom.com_aecomtraining on Jan 3, 2019
Latest reply on Jan 3, 2019 by xander_bakker

I am using the  CallScriptFromNet pro sdk community sample to run a python script in Pro via an addin. If i add the script through pro in a toolbox it runs fine but if i build an addin that runs it from the CallScriptFromNet example it errors on the "CURRENT" value of arcpy.mp.ArcGISProject. Is there something in the way it's being run from an addin that makes the python script run differently? Has anyone found a solution for this?

 

 

CallScriptFromNet example: https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Geoprocessing/CallScriptFromNet

 

My Updated .py Script:

import sys

import arcpy

from arcpy import env

import arcpy.mp

import os

aprx = arcpy.mp.ArcGISProject("CURRENT")

aprxFolder = aprx.homeFolder

mname = aprx.activeMap.name

m = aprx.listMaps(mname)[0]

 

Error:

arcgisscripting._mapping.ArcGISProject(*gp_fixargs((aprx_path,), True))

OSError: CURRENT

Outcomes