Sub-assembly Placement and Constraints

20 views
Skip to first unread message

TJ Neyman

unread,
Oct 23, 2024, 12:53:57 PM10/23/24
to CadQuery
I am making an assembly composed of multiple subassemblies.

My first approach is to simply place the subassemblies at a certain location and orientation relative to each other. Doing so resulted in the following:
# Make center assembly
p = cq.Workplane().cylinder(height=10, radius=2)
n = cq.Workplane().lineTo(0,2).lineTo(4,3).lineTo(4,0).close().revolve(axisStart=(0,0,0), axisEnd=(1,0,0))
b = cq.Assembly().add(p, name="p").add(n, name="n").constrain("n@edges@<X", "p@edges@>Z", "Plane", param=0).solve()
# Make side assembly
s = cq.Workplane().cylinder(height=20, radius=3)
t = cq.Workplane().lineTo(0,3).lineTo(3,1.5).lineTo(3,0).close().revolve(axisStart=(0,0,0), axisEnd=(1,0,0))
v = cq.Assembly().add(s, name="s").add(t, name="t").constrain("t@edges@<X", "s@edges@>Z", "Plane", param=0).solve()
# Create assembly from subassemblies
all = (cq.Assembly()
       .add(v, name="v", loc=cq.Location((0,0,0),(1,0,0),0))
       .add(b, name="b1", loc=cq.Location((0,5,0),(1,0,0),0))
       .add(b, name="b2", loc=cq.Location((0,-5,0),(0,0,1),0))
)
Screenshot 2024-10-23 105105.pngNote that this did produce the geometry I am looking forever; however, you will notice that the location vectors for "b1" and "b2" are different orientations, but they produce the same result. Changing the vector seems to have no impact on the direction of the subassembly.

Another approach I would like to try is constraining the side of each cylinder together, but I'm not sure how to select and constrain those edges to achieve this same geometry. 
Any advice? Thank you in advance!

Lorenz

unread,
Oct 23, 2024, 10:49:12 PM10/23/24
to CadQuery
> Changing the vector seems to have no impact on the direction of the subassembly

Try changing the angle value to a non-zero value.

This Location:
cq.Location((0, 5, 0), (1, 0, 0), 0)


... means the translation part is (0, 5, 0).
The rotation is zero degrees around (1, 0, 0).
Reply all
Reply to author
Forward
0 new messages