mwganson/joint

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,

  1. Draw an irregular shape in sketcher.
  2. Pad Sketch in Part Designer.
  3. Select Face.
  4. Execute Macro.
  5. Select Box Joint

image

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.

  1. Add an option at the beginning of the script to select either the center of mass, or simply to assign shape.Placement = face.Placement
  2. 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!

image

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!