Closed shehabattia96 closed 1 month ago
@jdegenstein suggested PartBuilder used in Build123d. Build Pattern may be a good solution for this problem. https://build123d.readthedocs.io/en/latest/introductory_examples.html#simple-rectangular-plate
So after comparing a lot of existing Code-CAD solutions, and looking at how they tackle this problem, I honestly don't think there is one good way to do it.
For now, CodeToCAD is going to utilize Landmarks and PresetLandmarks to automatically build and attach parts together.
Parts: To keep building with preset parts, it will look like this:
part = Part("myPart")
part.create_cube(l,w,h, merge_at = PresetLandmark.bottom, merge_to = PresetLandmark.top, operation = Boolean.Union)
part.create_cylinder(r, h, merge_at = PresetLandmark.bottom, merge_to = PresetLandmark.top, operation = Boolean.Union)
Explanation: If the Part does not have existing geometry, a cube will be inserted by default at PresetLandmark.bottom, relative to PresetLandmark.top of origin - in other words, it will sit on top of the plane. If the Part has an existing geometry, the cube will be inserted by default at PresetLandmark.bottom, relative to PresetLandmark.top of the existing geometry - in other words it will stack vertically in the Z axis.
The user will be able to provide a different landmark to control where the new geometry will be merged to. They can choose any Boolean operation between Union|Subtract|Intersect.
Sketchs: To keep building with sketches, it will look like this:
some_profile = Wire("mySketch") # This will create a new wire in this sketch.
some_profile.create_line(length, angle, start_at=PresetLandmark.end)
some_profile.create_arc(*args, start_at=PresetLandmark.end)
some_profile.create_line_to(to=PresetLandmark.start, start_at=PresetLandmark.end)
Explanation: We're going to add PresetLandmark.end and PresetLandmark.start to denote landmarks at the beginning and end of a wire. The user can decide where to append the new wire or edge in an existing wire.
These are observations made while using CodeToCAD:
To make a simple L-Bracket, I'd have to make two Cube Parts,
Joint
them to the ends of each other, thenUnion
them. I want to make this experience more intuitive.You can create 2D lines, polygons, circles and text, but connecting and constraining them using
Joints
takes too many steps. I would like to be able to at least have parity in 2D sketching with CadQuery or OpenSCAD, or make theJoint
system that we have easier to access.Attaching/assembling/mating a pin to a pin-hole, or a shaft to a shaft coupling is difficult. Currently, you have to create landmarks on the two parts that will be mated - and then create the
Joint
. This becomes cumbersome if a circular or linear pattern is involved as multiple landmarks need to be created on a patterned feature.Related: #154
Resources: