Each document object has property Name which is unique and can not be changed afterwards and property Label which is NOT unitque and which can be changed afterwards.
Each object can be accessed by
doc.Name whereas doc is inside FreeCAD App.ActiveDocument thus FreeCAD App.ActiveDocument.Name accesses a object.
Rebuild the FEM model
Moderator: bernd
Forum rules
and Helpful information for the FEM forum
and Helpful information for the FEM forum
Re: Rebuild the FEM model
It means the first object, on the left side, isn't actually named like that. Its Label is "examp104_01" but internally it is called something else. You can use the same method as in the right side to get the object by Label.
Code: Select all
App.ActiveDocument.getObjectsByLabel("examp104_01")[0].Shape = App.ActiveDocument.getObjectsByLabel("examp104_02")[0].Shape
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: Rebuild the FEM model
in addition https://wiki.freecadweb.org/Property_ed ... propertiesbernd wrote: ↑Wed Jun 03, 2020 6:23 am Each document object has property Name which is unique and can not be changed afterwards and property Label which is NOT unitque and which can be changed afterwards.
Each object can be accessed by
doc.Name whereas doc is inside FreeCAD App.ActiveDocument thus FreeCAD App.ActiveDocument.Name accesses a object.
Re: Rebuild the FEM model
Accessing the object by label works well. Thanks !
But If I am going to do all this in batch model, without viewing the label and attribute window, how do I get the label of the currently active FEM model/object ? And How do I get the label of the CAD/object I just imported on top of the original one ?
Thanks again.
Regards
Chen
But If I am going to do all this in batch model, without viewing the label and attribute window, how do I get the label of the currently active FEM model/object ? And How do I get the label of the CAD/object I just imported on top of the original one ?
Thanks again.
Regards
Chen
Re: Rebuild the FEM model
if you import by Python you do have an identifier to access the object. the Label of the current FEM gemetry you shoul know. BTW the name is not unique it is better to use the object Name to access a object by Python. Just give it a go and start.S-Y.Chen wrote: ↑Wed Jun 03, 2020 4:04 pm Accessing the object by label works well. Thanks !
But If I am going to do all this in batch model, without viewing the label and attribute window, how do I get the label of the currently active FEM model/object ? And How do I get the label of the CAD/object I just imported on top of the original one ?
Thanks again.
Regards
Chen
Re: Rebuild the FEM model
For me it is not 100 % sure what do you want. Would you like to do as much as possible with the Gui, or would you like to script the workflow?
Re: Rebuild the FEM model
I think it's clear he wants to do this by a script. Like he wants to open, migrate the shape, and run the simulation.
Something like this.
Code: Select all
obj = import_something("document.FCStd")
App.ActiveDocument.OldObject.Shape = obj.Shape
FEM.run_simulation()
Code: Select all
the_one = None
for obj in App.ActiveDocument.Objects:
if obj.isDerivedFrom("Part::Feature") and ...: # other conditions to locate the right object
the_one = obj
break
new_obj = import_something("document.FCStd")
the_one.Shape = new_obj.Shape
FEM.run_simulation()
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.