incorprate all Placement into shape coordinates
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
incorprate all Placement into shape coordinates
if removeSplitter() is used on a Shape the Shape returned has all placement incorporated into the vertices coordinates. What is the best way to archieve this without removeSplitter(), because this methods cleans the Shape. Is there any method around or does this needs to be done manually?
cheers bernd
cheers bernd
Re: incorprate all Placement into shape coordinates
You have to do some tests, as it probably is due to the copy that removeSplitter() probably is doing:bernd wrote: ↑Thu Apr 13, 2023 6:35 am if removeSplitter() is used on a Shape the Shape returned has all placement incorporated into the vertices coordinates. What is the best way to archieve this without removeSplitter(), because this methods cleans the Shape. Is there any method around or does this needs to be done manually?
cheers bernd
Some hints from:
https://forum.freecadweb.org/viewtopic. ... 74#p603474
Code: Select all
# deep copy = waste of memory and nullify shape compare API
dp_copy = shape.copy()
# shallow copy
sh_copy = Part.Shape(shape)
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: incorprate all Placement into shape coordinates
both do not incorporate the Placement into the vertices coordinates. They keep the placment in the placement not in the vertices coordinates ...
Re: incorprate all Placement into shape coordinates
Probably removeSplitter() will make some other operations, I usually see this behaviour when I make as example a Boolean operation, the new object will have a null Placement and retain the "relative position" of original objects.
try eventually if:
Code: Select all
help(Part.Shape.copy())
Hope it helps.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: incorprate all Placement into shape coordinates
Code: Select all
| copy(...)
| Create a copy of this shape
| copy(copyGeom=True, copyMesh=False) -> Shape
| --
| If copyMesh is True, triangulation contained in original shape will be
| copied along with geometry.
| If copyGeom is False, only topological objects will be copied, while
| geometry and triangulation will be shared with original shape.
Re: incorprate all Placement into shape coordinates
Sadly is not what I remembered.
I don't know what person to poke exactly.
@edwilliams16, @chrisb, @Chris_G or even @wmayer are usually my source of informations and people whom I discuss this sort of things.
Let's see if some help could came from them.
Regards
Carlo D.
I don't know what person to poke exactly.
@edwilliams16, @chrisb, @Chris_G or even @wmayer are usually my source of informations and people whom I discuss this sort of things.
Let's see if some help could came from them.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: incorprate all Placement into shape coordinates
The placement of the top-level shape is applied to the direct child shapes and not only to the vertexes.
Since you talk about removeSplitter() that works for shells and solids: You can move the top-level placement to the children withWhat is the best way to archieve this without removeSplitter(), because this methods cleans the Shape.
Code: Select all
shape = ...
clean_shape = Part.Shell(shape.Faces)
So, assuming you have applied a placement to shape then shape.Placement has the same output as shape.Face1.Placement because when accessing Face1 with TopoExp_Explorer it copies the placement of shape to the accessed sub-shape.
Another way of iterating over sub-shapes is TopoDS_Iterator which provides an option to ignore the placements of parent shapes. The Python API provides this function with shape.childShapes(). But this method only allows you to access direct children and no grandchildren. So, if your shape is a solid you can only access the shell and from the shell you can access the faces.
Example:
Code: Select all
box = Part.makeBox(1,1,1)
box.Placement.isIdentity() # True
box.Placement.Base = App.Vector(1,2,3)
box.Placement.isIdentity() # False
box.Face1.Placement.isIdentity() # False
# Get the sub-shape without placement of parent shape
shells = box.childShapes(False, False)
shells[0].Placement.isIdentity() # True, means the shell itself has no placement set
faces = shells[0].childShapes(False, False)
faces[0].Placement.isIdentity() # True
# Create a cleaned box
cleaned_box = Part.Solid(Part.Shell(box.Faces))
cleaned_box.Face1.Placement.isIdentity() # False, is OK
cleaned_box.Placement.isIdentity() # True, is what we want
# If you display the two boxes with
Part.show(box)
Part.show(cleaned_box)
# you will see that they are coincident. In the property editor you can see that the placement
# of the one object is a translation set and the other object not.
Re: incorprate all Placement into shape coordinates
Just to report back: I am of no help here.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: incorprate all Placement into shape coordinates
Alternatively you can use transformGeometry:
Code: Select all
import Part
box = Part.makeBox(1,1,1)
box.Placement.Base = App.Vector(1,2,3)
Part.show(box)
print(box.Placement.isIdentity()) # False
new = Part.Shape(box)
new = new.transformGeometry(new.Placement.Matrix)
new.Placement = App.Placement()
Part.show(new)
print(new.Placement.isIdentity()) # True
print(new.Face1.Placement.isIdentity()) # True
Re: incorprate all Placement into shape coordinates
lots of stuff to read and test ... thanks guys ...
BTW: This is why I am asking ... viewtopic.php?p=675641#p675254
BTW: This is why I am asking ... viewtopic.php?p=675641#p675254