I’m feeling very silly, but I am in the process of learning RhinoCommon and I have a very basic question:
I have stored the reference to an object as a GUID. I now want to lookup that object to either get its properties, or modify its properties. How do I get a handle to that object in RhinoCommon? Any tips?
Thanks for the response which makes perfect sense for a command. I was struggling to find a way to connect to the doc object outside of a RunCommand block.
I ended up with this in my plugin constructor:
RhinoDoc currentDoc = RhinoDoc.ActiveDoc;
myForm = new TD_PilotForm();
myForm.myModel.setDoc(currentDoc);
so that now within my model I have a reference to the current doc which I can use to read/write to. Hopefully that isn’t too bad an approach…
Without more context, I cannot comment on your code. But keep mind that the document can change. So it often best not to hold onto it; obtaining as needed. Or, use some of the document event watchers so you know when the document has changed.
The only way I have found to get a handle on the current document is by calling RhinoDoc.ActiveDoc.
I am happy to call this every time I need it, but there is a note in the help files saying this is not OK - that one should get a reference once and keep using it… This is what the help file says:
WARNING!! Do not use the ActiveDoc if you don’t have to. Under Mac Rhino the ActiveDoc can change while a command is running. Use the doc that is passed to you in your RunCommand function or continue to use the same doc after the first call to ActiveDoc.