Preserving global position of Parts during export
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Preserving global position of Parts during export
Hi,
I often receive STEP or FCStd files from collegues containing Parts inside Body objects. If I export a single Part, its position with respect to the global reference system is not preserved. As an example, in the attached file, export separately the two Parts, then load them: they will be far apart. Their relative position is not preserved. Is there a way to export a Part preserving its global position?
Thanks!
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16110 (Git)
Build type: Release
Branch: (HEAD detached at upstream/releases/FreeCAD-0-18)
Hash: f7dccfaa909e5b9da26bf50c4a22ccca9bb10c40
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Italian/Italy (it_IT)
I often receive STEP or FCStd files from collegues containing Parts inside Body objects. If I export a single Part, its position with respect to the global reference system is not preserved. As an example, in the attached file, export separately the two Parts, then load them: they will be far apart. Their relative position is not preserved. Is there a way to export a Part preserving its global position?
Thanks!
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16110 (Git)
Build type: Release
Branch: (HEAD detached at upstream/releases/FreeCAD-0-18)
Hash: f7dccfaa909e5b9da26bf50c4a22ccca9bb10c40
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Italian/Italy (it_IT)
- Attachments
-
- Example.FCStd
- (18.1 KiB) Downloaded 65 times
Re: Preserving global position of Parts during export
Hi,
This happens because of the "Body2" part container. Actually this container lives in an "unfinished" implementation. Especially when its placement is changed, it creates a new origin root that is then used by children as their own origin.
When you export, the origin shift created by the part container isn't took into account.
A simple workaround is to not change placement of part container. In your example, "Body002" should be set to position 0,0,0 with a 0° rotation, then "Solid005" should be moved to its position with its own placement property.
This happens because of the "Body2" part container. Actually this container lives in an "unfinished" implementation. Especially when its placement is changed, it creates a new origin root that is then used by children as their own origin.
When you export, the origin shift created by the part container isn't took into account.
A simple workaround is to not change placement of part container. In your example, "Body002" should be set to position 0,0,0 with a 0° rotation, then "Solid005" should be moved to its position with its own placement property.
Re: Preserving global position of Parts during export
Notice that if you're pretty comfortable with Python, this is fixed with 2 code lines (in your example) :
If you're facing that often, that could be easily solved with a macro.
Code: Select all
>>> Gui.ActiveDocument.Part__Feature009.Object.Placement = Gui.ActiveDocument.Part__Feature009.Object.getGlobalPlacement()
>>> Gui.ActiveDocument.R1823_ConLenteCondensatrice.Object.Placement = App.Placement(App.Vector(0,0,0),App.Rotation(0,0,0))
Re: Preserving global position of Parts during export
Finally attached an alpha release macro that you can run on needed documents.
It will basically reset all part containers to the global origin while preserving objects absolute placements.
Should solve your problems at exporting.
It will basically reset all part containers to the global origin while preserving objects absolute placements.
Should solve your problems at exporting.
- Attachments
-
- Absolufy.FCMacro
- (1.46 KiB) Downloaded 284 times
Re: Preserving global position of Parts during export
Oh, thank you!
Especially to openBrain for the macro!
Especially to openBrain for the macro!
Re: Preserving global position of Parts during export
@iari,
if you had followed the links, you would have found
https://www.freecadweb.org/wiki/Macro_DeepCopy installable with FC Addons Manager
if you had followed the links, you would have found
https://www.freecadweb.org/wiki/Macro_DeepCopy installable with FC Addons Manager
Re: Preserving global position of Parts during export
Thank you, easyw-fc, for signaling also the DeepCopy macro.
Re: Preserving global position of Parts during export
But DeepCopy loses hierarchy, which isn't always suitable.easyw-fc wrote: ↑Thu Jun 06, 2019 9:05 pm @iari,
if you had followed the links, you would have found
https://www.freecadweb.org/wiki/Macro_DeepCopy installable with FC Addons Manager
Re: Preserving global position of Parts during export
yes, but the OP needs are as per single part placement:
FreeCAD doesn't fail to export the full hierarchy placement.