Because some commands are not available in .Net you sometimes need to create Python Scripts to run them via the workaround => Change a property on ISimComponent which triggers a Python Script.
Because in my use case it is not given that the Python script does exist on the component. That’s why I want to search for it and if it isn’t available create it by code. Below you can find my current code. Is there a way to create behaviors in VC?
IProperty SaveBitmapProperty = component.GetProperty("saveBitmap");
if (SaveBitmapProperty == null)
component.CreateProperty(typeof(string), PropertyConstraintType.AllValuesAllowed, "saveBitmap");
IBehavior SaveBitmapBehavior = component.FindBehavior("saveBitmap");
if (SaveBitmapBehavior == null)
{
// Create Python Script Behavior Here
}
IProperty SaveBitmapProperty = component.GetProperty("saveBitmap");
if (SaveBitmapProperty == null)
component.CreateProperty(typeof(string), PropertyConstraintType.AllValuesAllowed, "saveBitmap");
IPythonScript SaveBitmapBehavior = (IPythonScript)component.FindBehavior("saveBitmap");
if (SaveBitmapBehavior == null)
{
ISimNode simNode = component.Nodes[0];
SaveBitmapBehavior = (IPythonScript)simNode.CreateBehaviorByType(BehaviorType.PythonScript);
SaveBitmapBehavior.Name = "saveBitmap";
SaveBitmapBehavior.Script = Properties.Resources.saveBitmap; // String with the python code
}
Still, if you find a way on how to create a bitmap with the .NET API let me know! There is some functionallity in the PlotViewEx Class, but I couldn’t figure out how to fetch this object from the session.