Hello forum:
We're launching a python toolbox tool "CreaCCAA" from a custom ArcMap menu option "Gestion de Cartografia" as shown in pic1 (see attachments)
The "CreaCCAA" tool has 6 parameters itself.
This operation is working fine
What we're trying to do (see Pic2 in attachments) is to launch "CreaCCAA" from menu "Gestion de Cartografía" with 3 first parameters initialized. We want the final user just to enter parameters 4,5 and 6 in "CreaCCAA"....but it doent work
Code for launching "CreaCCAA" in the "Gestion de Cartografia" .net side, is as follows:
public static void ExecuteScript(string PathTOToolbox,string ScriptName, List<string> ParametersList)
{
try
{
IGeoProcessor2 gp = new GeoProcessorClass();
IVariantArray parameters = null;
gp.AddToolbox(PathTOToolbox);
if (ParametersList != null)
{
parameters = new VarArrayClass();
foreach (string param in ParametersList)
{
parameters.Add(param);
}
}
gp.Execute(ScriptName, parameters, null);
}
catch (Exception Err)
{
Connector.ConnectorExtension.WriteStaticLog("Error", Err.Message + " - " + Err.StackTrace);
}
}
In the "CreaCCAA" python code side, we're trying to read the 3 arguments using sys.argv but it doesn't work.
Exploring the sys.argv value we get always an empty string ['']
It makes no difference to read sys.argv in any section in the python toolbox code (__init__, getParameterInfo, updateParameters or execute): we get always the empty string ['']
Does anybody know how to solve this? Does sys.argv work "fine" in a pyhon toolbox?
We think one possible way to solve this, could be reading the 3 parameters needed in "CreaCCAA" from a text file (like cookies work) using the "open" and "readlines" python methods.
But, because of security issues (one of the parameters to pass to "CreaCCAA" is a password) we prefer to avoid it.
Our development environment is ArcGIS 10.2.2 on Windows 7 Professional SP1
Hope you could help with this and thanks in advance
Antonio