I am writing a plugin with a command that adds an instance object to the document and writes a simple parameter string into the UserDictionary on the InstanceObject. When I run my command again there is an option to “edit” an existing object in the document and to do that I try to read my parameter string back from the selected InstanceObject in order to restore the state of my command. This works well up to a point. Below is the general sequence of events:
- Run command first time with nothing selected and hit
a. Parameters are written to the UserDictionary of the created InstanceObject - Run command second time with previously created object pre-selected
a. Parameters are read from the UserDictionary of the pre-selected object
b. The pre-selected object is altered: ReplaceInstanceObject to change the instance definition
c. Parameters are written/overwritten to the UserDictionary of the created InstanceObject - Run command third time with previously created/altered object pre-selected
a. Parameters can not be read as the UserDictionary on my InstanceObject is now empty
I’m only dealing with a single object in my document and I can verify that the GUID on the InstanceObject never changes. I can also verify that each time after I write my parameter string to the UserDictionary it appears to me to write successfully. I’m not sure at what point the UserDictionary is getting cleared.
I’ve written a similar test just with normal geometry rather than instance objects and the results are similar but slightly different. In that instance when I reach point 3a the UserDictionary on my RhinoObject does still have my parameter string but it is not the updated copy from step 2 but rather the original from step 1.
Very confused what is happening here. Any ideas?