Troubleshooting of specific object and help with general workflow

209 views
Skip to first unread message

Nick K

unread,
Apr 3, 2021, 2:06:10 AM4/3/21
to CadQuery
Hello. First, let me say how excited I am about the potential of cadquery! It appears to be everything I hoped opescad would be and more. Unfortunately, I am having a fair bit of trouble. You can see my effort at
 All files there are the exact same object.  The 3d viewer was acting up and I wasn't sure if it was my file or the site. Originally I wanted to make it in CQ but my attempt failed and I had to use freecad(was using cadquery 2). As you can see from looking at the .py on thingiverse. I got as far at trying to add the sets of holes and had real trouble getting them to appear on the correct face, in the right spot, with the hole oriented the right way. More generally, I seem to have trouble with the stack concept. I seems that many things return a workplane object when it doesn't make sense to me for them to do so. Additionally it seems like CQ encourages heavy use of one liners with its use of the stack. I sometimes had unexpected results when splitting an operation into multiple lines and intermediate variables Additionally, and I am explaining this very poorly, it seems like object that I was using just to make cuts and such seemed to stick around and cauue me weird issues.. Any general advice or specific issues you see in the file would be greatly appreciated. I did try other approaches as well, but was not diligent about saving my other failures. Thanks

Jeremy Wright

unread,
Apr 5, 2021, 8:02:51 AM4/5/21
to CadQuery
The boolean operation (cut) you've done for the for the slot is fine, but CadQuery does not put a heavy focus on boolean operations like OpenSCAD does. For creating the holes, the workflow is typically more like the following.

1. Select a face
2. Create a workplane
3. Move to the point where you want the hole (or use pushPoints to place all the points at once)
4. Create a circle
5. Use cutBlind or cutThruAll to cut the hole(s).

If you place a circle on a face and perform a 3D operation using the circle, a new workplane is returned that you can continue to build on. That's why I do parabola= in two places below. I took some things out of your code and simply placed a hole to illustrate some things that might help.

spPoints=[ (-20,100), (-30,80), (0,0),  (30,80), (20,100)]
zipTieSlotCutter=cq.Workplane("YZ").box(10,3,300).translate([0,75,0])
parabola=cq.Workplane("YZ").rect(5,20).sweep( cq.Workplane("XY").spline(spPoints)).cut(zipTieSlotCutter)
parabola = parabola.faces(">Z").workplane(invert=True).moveTo(2, 1).circle(1).cutBlind(10)
show_object(parabola)


Notice the invert=True inside of the workplane creation. If CadQuery gets the normal wrong, the hole cut will go away from the face instead of down into it. You can use invert to flip the normal and get the hole to work. The moveTo() could be replaced by pushPoints() to place all the points for the holes on the face at once. Then the following circle/cutBlind calls would put holes at all those locations at once.

I noticed that the parabola profile of your object was different in CQ and that you had used a spline (probably for simplicity). As an alternative if you don't need your profile to be parametric, you could draw your profile as a DXF, import it into CadQuery, and extrude it. If you place the circles for the holes in the correct positions in the DXF, CadQuery SHOULD see that those wires are inside the main profile and make them holes during the extrude operation. You'll end up with all thru holes though, and I think your FreeCAD-created object has mostly blind holes.

Adam Urbanczyk

unread,
Apr 6, 2021, 12:05:50 PM4/6/21
to CadQuery
One addition, it looks to me that in FreeCAD you modeled you main body using a polyline and fillets:

pts = [ (-20,100), (-30,80), (0,0),  (30,80), (20,100)]
spine = cq.Workplane().polyline(pts)

body = (
    cq.Workplane("XZ", origin=pts[0])
    .rect(5,20)
    .sweep(spine)
    .edges('|Z').edges('not(<<Y[0] or <<Y[1] or <<Y[2])')
    .fillet(8)
    )

Reply all
Reply to author
Forward
0 new messages