SetPythonModuleResult SetPythonModule(OdId tObject, SetPythonModuleArg tArg)
tObject. Moniker of repository object that is a Python unit.
tArg. Operation execution parameters.
The SetPythonModule operation is used to change Python unit code and start it for execution.
To execute the operation, in the tObject field specify moniker of the repository object that is a Python unit. The object moniker can be obtained on executing the GetObjects operation. In the tArg.meta field specify new metadata of the unit, which should be applied. Changes are saved on executing the operation.
The tArg.run parameter enables the user to start a Python unit for execution.
The operation results in the information about compilation results and unit execution results.
Below is the example of starting a Python unit for execution. The request contains moniker of unit in the repository. The response contains text of messages displayed in the console on execution. The example uses the FindObjectById function, which code is given in the Getting Object Description by Its Identifier example.
{
"SetPythonModule" :
{
"tObject" :
{
"id" : "LGAABCFKMMJNFOAEJHAJNCGDICAAELAEKLDHEEPJJFLLCAAC!M!304842"
},
"tArg" :
{
"run" : "true"
}
}
}
{
"SetPythonModuleResult" :
{
"consoleOutput" : " Today: 08-Jul-2022"
}
}
public static SetPythonModuleResult RunPythonModule(MbId mb, string modId)
{
var somClient = new SomPortTypeClient(); // Proxy object for operation execution
// Operation execution parameters
var tSet = new SetPythonModule()
{
tArg = new SetPythonModuleArg()
{
run = true
},
// Create object moniker
tObject = new OdId() { id = mb.id + "!" + FindObjectById(mb, modId).k }
};
// Start Python unit
var result = somClient.SetPythonModule(tSet);
return result;
}
See also: