filtering faces

237 views
Skip to first unread message

Matt Maier

unread,
Sep 19, 2015, 7:52:03 PM9/19/15
to CadQuery
This is my script:
---------------------------------------------------------

# This is a CadQuery script template

# Add your script code below

import cadquery as cq

from cadquery import selectors

from Helpers import show


spoolWidth = 6 # spool thickness, front to back (half 20mm shaft)

spoolRadius = 35/2 # the outer dia the line wraps around

indexRadius = 3 # inner dia holes indexing pin(s) use to lock spool together

hexRadius = 45.5/2 # outer dia of the integral hex nut for tightening

hexWidth = 4 # thickness of integral hex nut


result = cq.Workplane("XY").circle(spoolRadius).extrude(spoolWidth)\

.faces("<Z").workplane().polygon(6, hexRadius*2).extrude(hexWidth)\

.faces("<Z").chamfer(hexWidth/2.01)

result2 = cq.Workplane("XY").polygon(6, hexRadius*2).extrude(hexWidth)\

.faces("|Z").chamfer(hexWidth/2.01)


# Use the following to render your model with grey RGB and no transparency

# show(my_model, (204, 204, 204, 0.0))

show(result)

show(result2)

---------------------------------------------------------

The "|Z" filter works in results2, but if I replace the second "<Z" in results with a bar it throws an error and doesn't compile. As far as I can tell the code is exactly the same and I should be able to replace result2 with the last half of result, except that "|Z" doesn't work in that spot.

Jeremy Wright

unread,
Sep 19, 2015, 8:53:10 PM9/19/15
to Matt Maier, CadQuery

Is there a parallel face for it to select at that point on the chain of result1?

--
cadquery home: https://github.com/dcowden/cadquery
post issues at https://github.com/dcowden/cadquery/issues
run it at home at : https://github.com/jmwright/cadquery-freecad-module
see it in action at http://www.parametricparts.com
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/362c9602-3e56-4cec-91d2-fb3380e1bd1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jmwright

unread,
Sep 20, 2015, 2:25:02 PM9/20/15
to CadQuery, blueb...@gmail.com

BRep_API: command not done


That's a generic FreeCAD error that's never very helpful. 

It looks like the chamfer size is too large to be applied to the parallel faces. If you adjust the chamfer size, it works.

result = cq.Workplane("XY").circle(spoolRadius).extrude(spoolWidth)\

.faces("<Z").workplane().polygon(6, hexRadius*2).extrude(hexWidth)\

.faces("|Z").chamfer(0.5)



Matt Maier

unread,
Sep 20, 2015, 2:36:06 PM9/20/15
to jmwright, CadQuery
Ah, yeah, good find. Maybe it's choking when the chamfer crosses over the small perimeter holes. It looks like as long as the chamfer gets really close it still renders

result = cq.Workplane("XY").circle(spoolRadius).extrude(spoolWidth)\

.faces("<Z").workplane().polygon(6, hexRadius*2).extrude(hexWidth)\

.faces(">Z").workplane().polygon(22, spoolRadius*2-5).vertices().hole(indexDia)\

.faces(">Z").workplane().hole(shaftDia)\

.faces("|Z").chamfer(.3999)


Now is there a way to select only the edges of the hex portion instead of all faces?

Jeremy Wright

unread,
Sep 20, 2015, 2:49:58 PM9/20/15
to Matt Maier, CadQuery
I'm not sure that I'm understanding you correctly, but I think you could probably and a nearest point selector with a parallel selector.


Can you explain what you're trying to do in a slightly different way?


Matt Maier

unread,
Sep 20, 2015, 3:38:25 PM9/20/15
to Jeremy Wright, CadQuery
There's a round part and a hex part. I want the six faces of the hex part to be convex instead of flat so that I can slip a concaved wrench around it that won't slip off.

Awesome, I'm trying to use the boolean selectors. Any thoughts on why this isn't working?

# This is a CadQuery script template

# Add your script code below

import cadquery as cq

from cadquery import selectors

from Helpers import show


# dimensions are off of ideal to account for printing errors


spoolWidth = 6 # spool thickness, front to back (half 20mm shaft)

spoolRadius = 35.5/2 # the outer dia the line wraps around

indexDia = 3.4 # inner dia holes indexing pin(s) use to lock spool together

hexRadius = 45.5/2 # outer dia of the integral hex nut for tightening

hexWidth = 4 # thickness of integral hex nut

shaftDia = 5.3 # outer dia of motor shaft


result = cq.Workplane("XY").circle(spoolRadius).extrude(spoolWidth)\

.faces("<Z").workplane().polygon(6, hexRadius*2).extrude(hexWidth)\

.faces(">Z").workplane().polygon(22, spoolRadius*2-5).vertices().hole(indexDia)\

.faces(">Z").workplane().hole(shaftDia)

# .faces("|Z").chamfer(.3999)

s = selectors.StringSyntaxSelector

#result = result.faces("<Z").fillet(.45)

result = result.faces(s("<Z")+s(">Z")).fillet(.45)


show(result)

Jeremy Wright

unread,
Sep 20, 2015, 3:56:56 PM9/20/15
to Matt Maier, CadQuery
It's the fillet size. I decreased it from 0.45 and it started working.

Matt Maier

unread,
Sep 20, 2015, 4:09:15 PM9/20/15
to Jeremy Wright, CadQuery
I get this error: unsupported operand type(s) for +: 'StringSyntaxSelector' and 'StringSyntaxSelector' even when the fillet is .0001

Jeremy Wright

unread,
Sep 20, 2015, 4:10:41 PM9/20/15
to Matt Maier, CadQuery

Have you updated to the latest version (Github master) of the CadQuery FreeCAD module?

Matt Maier

unread,
Sep 20, 2015, 6:38:50 PM9/20/15
to Jeremy Wright, CadQuery
Well, that's a good question. The zip file I've got says 0.2.0 but there's nothing in the actual FreeCAD/CadQuery folders under programs to indicate which version of cadquery I've got.

Jeremy Wright

unread,
Sep 20, 2015, 6:49:09 PM9/20/15
to Matt Maier, CadQuery

Go to the main Github page for the module and click the "Download Zip" link. The changes you're needing haven't been officially released yet, so you have to grab a current copy of master.

https://github.com/jmwright/cadquery-freecad-module/archive/master.zip

The last version in the changes.md file should be the version that you're using.

Matt Maier

unread,
Sep 20, 2015, 7:05:23 PM9/20/15
to Jeremy Wright, CadQuery
Neat, thanks now the boolean is working as long as the fillet (or whatever) doesn't cross over another fillet.
Reply all
Reply to author
Forward
0 new messages