Relative radiusArc?

272 views
Skip to first unread message

Duncan Smith

unread,
Apr 29, 2021, 10:29:07 AM4/29/21
to CadQuery
Hi-

Learning cadquery here, for this example trying to overcome the issues Freecad has placing text parametricaly.

Wondering if I've missed something in the API, I don't see a relative-to-current-position variant for radiusArc, a radiusArc equivalent to line vs lineTo? The ogee below would be simpler/easier with relative moves, but the apparant absence of a relative radiusArc makes this troublesome.

Feedback on this code appreciated; is there a better way to do this?

Thanks!

   Duncan

Plaque.png

import cadquery as cq
margin=80
cutDepth=-1.0
textSize=40.0 # Specifying an integer here will crash cq-editor
thickness=18
corners=20
rad=3.0
s=1
text = "Made With\nCadQuery"

# Create the text first to get the size.
textObject = cq.Workplane("XY").transformed([0,0,0],[0,0,thickness/2]).text(text, textSize, cutDepth)
bb = textObject.val().BoundingBox()

plaque = cq.Workplane("XY").box( bb.xlen + margin, bb.ylen + margin, thickness)
plaque = plaque.vertices(">Z").circle(corners).cutThruAll()

ogee = cq.Workplane().copyWorkplane(plaque.faces(">X").vertices(">YZ").workplane(centerOption='CenterOfMass')).\
    lineTo(-(rad+2*s),0).\
    lineTo(-(rad+2*s),-s).\
    lineTo(-(rad+s),-s).\
    radiusArc([-s,-(rad+s)],rad).\
    lineTo(-s,-(rad+2*s)).\
    lineTo(0,-(rad+2*s)).\
    close().sweep(plaque.wires(">Z"))

plaque=plaque.cut( ogee ).cut( textObject )

# Discard cutting tools
ogee=None
textObject = None



Jeremy Wright

unread,
Apr 29, 2021, 4:22:20 PM4/29/21
to CadQuery

Ami Fischman

unread,
Apr 29, 2021, 4:42:41 PM4/29/21
to Jeremy Wright, CadQuery
Not sure what's being asked for here, but possibly helpful: a variant of radiusArc where instead of specifying an endPoint you specify an angle to be swept by the arc, its radius, and a vector pointing towards the center of the arc.
(obvs. mostly lifted from CQ sources)

def radialArc(
        self, angleDegrees: float, radius: float, toCenter: Tuple[float, float], forConstruction: bool = False
):
    """
    Creates a radial arc from the current position.
    :param angleDegrees: the angle of the endpoint
    :param radius: the radius of the circle from which the arc is cut
    :param toCenter: a vector pointing from the current point towards the center of the circle from which the arc is cut
    :return: a workplane with the current point at the end of the arc
    """
    startPoint = cq.Vector(self._findFromPoint(False))
    if toCenter[0] == 0:
        startAngle = math.pi/2 if toCenter[1] > 0 else math.pi*3/2
    else:
        startAngle = math.atan(toCenter[1]/toCenter[0])
    center = startPoint + cq.Vector(toCenter).normalized()*abs(radius)
    angle = (angleDegrees/360) * 2.0 * math.pi
    endpoint = center + cq.Vector(math.cos(angle), math.sin(angle))*abs(radius)
    midAngle = (angle-startAngle)/2
    midpoint = center + cq.Vector(math.cos(midAngle), math.sin(midAngle))*abs(radius)
    return self.threePointArc(midpoint, endpoint, forConstruction=forConstruction)
cq.Workplane.radialArc = radialArc


--
cadquery home: https://github.com/CadQuery/cadquery
post issues at https://github.com/CadQuery/cadquery/issues
run it at home at : https://github.com/CadQuery/CQ-editor
---
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/713f5c25-7867-4b68-aed2-f35b405ec4dan%40googlegroups.com.

Adam Urbanczyk

unread,
Apr 30, 2021, 2:57:05 AM4/30/21
to CadQuery
There is no arcTo function. For your specific geometry you could use the following approach:

(cq.Workplane()
 .rect(20,10).extrude(2)
 .faces('>Z').vertices().circle(2).cutThruAll()
 .faces('>Z').fillet(1)
 .faces('>Z').workplane().text('CQ',8,-.5,True)
)

Duncan Smith

unread,
May 1, 2021, 8:58:22 AM5/1/21
to CadQuery
Jeremy, thanks, looks like ellipse arc would do it.

Thanks, Ami, bang on, and bonus points for answering my next question in advance, which was writing custom extensions and accessing the current point, appreciate it.

Adam, the exercise was in figuring out how to do positioning of text and geometry based on the size of the text (for other purposes) and modelling an ogee profile, which is kinda like a fillet but set back.

Cheers!

  Duncan

Adam Urbanczyk

unread,
May 1, 2021, 11:39:15 AM5/1/21
to CadQuery
OK, I did not get the question, but seems that you are helped. BTW: you can also try the spline function for an approximate arc with begin and end tangents specified.
Reply all
Reply to author
Forward
0 new messages