Code: Select all
OS: Ubuntu 18.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15379 (Git)
Build type: Release
Branch: master
Hash: 3290c36d28551875f02333c2e01af80e38b8ad02
Python version: 2.7.15rc1
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
Conceptually, it would be easiest for me to store references to objects in arrays/lists, then remove/add objects from these lists to the document before each save. So I'm stuck at whether it is possibly to remove an object only temporarily from a FreeCAD document - that is, whether it is possible to re-add it again once it is removed.
So, let's say I have some object in FreeCAD, and I get a reference to it thus:
Code: Select all
myobj = App.ActiveDocument.getObject("MyObject")
Code: Select all
App.ActiveDocument.removeObject("MyObject")
Now, the thing is, just like .getObject and .removeObject, also .addObject operates on strings, including the object name. So I cannot use an object reference with it. There is App.ActiveDocument.Objects list, but it is read-only, and doing .append(myobj) on it is silently ignored.
Now, the thing is, this object could be a result of some complex calculation, and so I wouldn't want to reinstantiate it at this point. Therefore, the best for me would be to re-add it to the document from the existing object reference and memory content. Is there a FreeCAD Python command (or approach) which would allow for that?