Position of Generated Pattern Is Unpredictable With Irregular Shaped Pads
Closed this issue · 4 comments
I am trying to use this macro for designing a parametrized box pattern for laser cutting. I need the box to be robust and I would prefer to avoid exclusively relying on wood glue to support the bottom. In order to do this, I need the holes to not be attached to a corner.
Unfortunately, there seems to be an unpredictable offset from true center with irregular shapes, and yet I can't identify the cause of the problem, because it looks like the code is inheriting the base position from the parent body.
To reproduce,
- Draw an irregular shape in sketcher.
- Pad Sketch in Part Designer.
- Select Face.
- Execute Macro.
- Select Box Joint
Found the code. On line 240
, the script was acquiring shape.Placement
from face.CenterOfMass
. I am not 100% certain why this feature was implemented (maybe to attempt to center the object), but I would offer two suggestions.
- Add an option at the beginning of the script to select either the center of mass, or simply to assign
shape.Placement = face.Placement
- In addition to, or to replace the Center of Mass feature, consider a script that polls the bounding box, I would dig into this method myself, and I may, but not this morning.
Thanks again for all the work!
I found an alternative method that works well even with the irregular shape:
Replace:
shape.Placement = fp.Placement.multiply(FreeCAD.Placement(face.CenterOfMass, FreeCAD.Rotation(FreeCAD.Vector(0,0,1),FreeCAD.Vector(x,y,z))))
With:
shape.Placement = fp.Placement.multiply(FreeCAD.Placement(face.BoundBox.Center, FreeCAD.Rotation(FreeCAD.Vector(0,0,1),FreeCAD.Vector(x,y,z))))
I updated. New version is 0.2022.10.05.
Awesome, thanks for keeping this tool going! It's been very helpful!