Data to share between commands

Hello to you,

I have a C# UI that is calling 2 python commands in 2 occasions.
The first command is loading an complex object.
The problem is that in the second command, the object become null even though I set it as a global variable.
Would you have an idea how to share data between command calls?

I tried to save the data in a layout item.
I would put it in a json string.
But the object is too complex.

I also tried to send it to the UI by calling an ActionItem that would be used to set the data in the second command.
But the object is too complex also here:

// in python:
localize = findCommand(“netCommand”)
localize.execute(“Process3DBuildCommandId”, dstvBuildSeq)

// in C# ActionItem (Process3DBuildCommandId):
public override void Execute(PropertyCollection args)
dstvBuildSeq = args[0].Value; //is true when I put the whole object,
//otherwise if I send a string it has a string…

thanks for helping…

I’ve noticed that many Python commands are implemented incorrectly such that every time the command is called it does full initialization including recreating all properties, which of course loses their values.

You can test when your Python command initialization runs by e.g. adding some print commands and see if you can avoid recreating / resetting the properties.