CadQuery / CadQuery/cadquery

Constraining a part to fixed parts doesn't work

Open
#1,896 2 comments 0 reactions 0 assignees View on GitHub
assembly question
Dominant language
Python
Stars
5.8k
Forks
541
Avg merge
3d 2h
Merged PRs (30d)
5

Description

Maybe a bit cryptic title, but I want to build a frame with boxsections and add an angleiron in the corners. These boxsections are assembled at a specific location so they are in the right place. Now I want to add another part to the assembly and constrain it to the boxsections. To stop the boxsections from moving, I added a `Fixed` constrain to them. But the angleiron never gets the right place.

My code below:
```Python
import cadquery as cq

boxsection_w = 20
boxsection_h = 60
boxsection_t = 2
boxsection = (cq.Sketch()
.rect(boxsection_w, boxsection_h, tag='outer')
.rect(boxsection_w - (2 * boxsection_t), boxsection_h - (2 * boxsection_t), mode='s', tag='inner')
.vertices(tag='inner')
.fillet(boxsection_t)
.reset()
.vertices(tag='outer')
.fillet(boxsection_t * 2)
.reset()
)

angleiron_w = 30
angleiron_h = 60
angleiron_t = 5
angleiron = (cq.Sketch()
.segment((0,0), (angleiron_w, 0))
.segment((angleiron_w, angleiron_t))
.segment((angleiron_t, angleiron_t))
.segment((angleiron_t, angleiron_h))
.segment((0, angleiron_h))
.close()
.assemble()
.vertices()[2:5]
.fillet(angleiron_t)
)

frame_w = 700
frame_l = 2400

frame_profile_length = 2200
frame_profile_width = 600

angleiron_lengte = 300

tableprofile_l = (cq.Workplane('XY')
.placeSketch(boxsection)
.extrude(frame_profile_length)
)
tableprofile_l.faces(">X").tag("TL_IN")

tableprofile_w = (cq.Workplane('XY')
.placeSketch(boxsection)
.extrude(frame_profile_width)
)
tableprofile_w.faces(">X").tag("TL_IN")

tabelcorner = (cq.Workplane('XY')
.placeSketch(angleiron)
.extrude(angleiron_lengte)
.copyWorkplane(cq.Workplane('XZ'))
.sketch()
.segment((0,0),(angleiron_w,0))
.segment((0, angleiron_w))
.close()
.assemble()
.finalize()
.cutThruAll()
.moveTo(0, angleiron_lengte)
.sketch()
.segment((0,0),(angleiron_w,0))
.segment((0, -angleiron_w))
.close()
.assemble()
.finalize()
.cutThruAll()
)
tabelcorner.faces("Z").tag("TH_OUT")

tabelframe = (cq.Assembly()
.add(tableprofile_l, loc=cq.Location(-(frame_w - boxsection_w) / 2, -boxsection_h / 2, -frame_profile_length / 2), name="R")
.add(tableprofile_w, loc=cq.Location((-(frame_profile_width) / 2, -boxsection_h / 2, (frame_l - boxsection_w) / 2), (0,90,0)), name="D")
.add(tabelcorner, name="TH1")
)
# add the constraints
(
tabelframe
.constrain('R?TL_IN', 'Fixed')
.constrain('D?TL_IN', 'Fixed')
.constrain('TH1?TH_IN', 'R?TL_IN', 'Plane')
.constrain('TH1?TH_OUT', 'D?TL_IN', 'Plane')
)

tabelframe.solve()

show_object(tabelframe)
```
I have tried to swap the strings of the last two constrains but it doesn't work.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.