Community
Is it possible to pass command line argument to a plugin through Automation API ?
For example, I want to pass NoGui as an argument through API for am in house plugin.
Yes, this is the way I do it:
// add args
// - create a dictionary first to make more understandable then convert to arg array
Dictionary<string, string> argDict = new Dictionary<string, string>();
argDict.Add("targetFile", masterNwfFile);
argDict.Add("p3dXmlFile", np.ProjectXmlFile);
argDict.Add("doImportP3d", np.ImportP3d.ToString());
argDict.Add("doImportAdvStl", np.ImportAdvStl.ToString());
// erase all saved viewpoints
// - any viewpoints that were created in AutoCAD will be erased
// - previously saved Navisworks viewpoints will need to be imported manually
argDict.Add("doClearViewpoints", "true");
// create the arg array
List<string> argList = new List<string>();
_Debug.AppendLine($"\t\t\t argList:");
foreach (var kvp in argDict)
{
_Debug.AppendLine($"\t\t\t\t {kvp.Key}:\t{kvp.Value}");
argList.Add($"{kvp.Key};{kvp.Value}");
}
// run the plugin
NavAutoApp.ExecuteAddInPlugin("KpeNavisTools.JABO", argList.ToArray());
Plugin:
public override int Execute(params string[] parameters)
{
// get param values as dict
Dictionary<string, string> paramsDict = new Dictionary<string, string>();
foreach (string param in parameters)
{
string key = param.GetStringSplit(';', 0);
string val = param.GetStringSplit(';', 1);
paramsDict.Add(key, val);
}
// report dict values
Debug.AppendLine($"\tparamsDict:");
foreach (var kvp in paramsDict)
{
Debug.AppendLine($"\t\t{kvp.Key}: {kvp.Value}");
}
}
Can't find what you're looking for? Ask the community or share your knowledge.