Numerical Issues when extruding some polygons (tapered)

51 views
Skip to first unread message

Al R

unread,
Aug 20, 2024, 10:06:37 PM8/20/24
to CadQuery
I've been working on code to read in a set of 2D shapes to build a 3D structure; mostly by extrusion/cutting.  For some steps, I extrude & cut using taper angles.  For some of the input polygons, these tapered extrusions yield numerical issues for cadquery.

I believe the issue occurs when the set of points in the polygon create line segments with very small angles between them.  At such interfaces, a new face/line segment seems to be created... if the angle is too small (I assume), I get numerical issues.

I am wondering if this is a "known" issue with a "known" solution.  Would "loft" be more stable or do I need to pre-process all polygons prior to these tapered extrusions?  Relatively new to cadquery.

I have a point list below + line of code where the extrusion fails unless I manipulate the shape.  

Curious to hear what you think - thanks!

Capture.PNG

points =[(-439.87, 420.34000000000003), (-440.71000000000004, 415.56), (-441.27, 409.66), (-441.27, 380.14), (-454.67, 380.64), (-461.55, 381.56), (-461.55, 382.41), (-469.1, 383.84000000000003), (-475.42, 385.59000000000003), (-481.8, 387.92), (-488.35, 390.85), (-495.09000000000003, 394.39), (-503.82, 399.61), (-534.01, 419.82), (-548.29, 428.53000000000003), (-556.75, 432.97), (-563.22, 435.93), (-576.4300000000001, 440.73), (-583.1, 442.52), (-591.95, 444.26), (-600.65, 445.34000000000003), (-609.1, 445.90000000000003), (-625.02, 446.13), (-640.94, 445.90000000000003), (-651.5500000000001, 445.13), (-660.3000000000001, 443.89), (-669.17, 441.97), (-675.83, 440.04), (-684.64, 436.84000000000003), (-693.3000000000001, 432.97), (-701.76, 428.53000000000003), (-709.99, 423.66), (-744.4300000000001, 400.75), (-758.35, 392.54), (-764.99, 389.31), (-773.04, 386.12), (-780.94, 383.84000000000003), (-788.45, 382.42), (-788.45, 381.56), (-795.37, 380.64), (-808.57, 380.15000000000003), (-808.58, 405.69), (-809.29, 415.56), (-810.13, 420.34000000000003), (-811.44, 425.3), (-814.73, 433.59000000000003), (-817.33, 438.37), (-820.32, 442.93), (-825.97, 449.99), (-833.48, 457.65000000000003), (-856.0500000000001, 477.08), (-861.91, 482.48), (-866.77, 487.83), (-869.71, 492.38), (-870.95, 495.94), (-871.48, 500.69), (-871.5500000000001, 536.14), (-767.95, 536.14), (-767.95, 467.02), (-768.95, 467.02), (-768.95, 454.14), (-481.05, 454.14), (-481.05, 467.02), (-482.05, 467.02), (-482.05, 536.14), (-378.45, 536.14), (-378.52, 500.69), (-379.05, 495.94), (-380.29, 492.38), (-383.23, 487.83), (-388.09000000000003, 482.48), (-393.95, 477.08), (-416.52, 457.65000000000003), (-422.82, 451.32), (-428.61, 444.40000000000003), (-433.58, 436.8), (-437.41, 428.64), (-439.87, 420.34000000000003)]

cq.Workplane("XY").workplane(offset=3.7).sketch().polygon(points).finalize().extrude(2.3,taper=-40)

Al R

unread,
Aug 22, 2024, 9:23:02 AM8/22/24
to CadQuery
Update on this question:

I decided to use loft with 2 planes to create a similar effect.  First plane is the above defined polygon, second plane is the above defined polygon after it was grown by a set amount.  At the interface depicted above, this loft approach uses a single line second + two faces & does not create the third "glue" section.

This is "close enough" for my purpose & worked well for my application.  A snippet of the relevant code is below (I used "Shapely" python library for polygon manipulation); the simplify/normalize commands were an effort to remove any duplicate points & order the polygon point array consistently.

for shape in shapes:
        hull = sp.simplify(shape, tolerance=0, preserve_topology=False)
        hull = sp.normalize(hull)
        hull2 = hull.buffer(thk,cap_style='square', join_style='mitre')
        hull2 = sp.normalize(hull2)
        if tang !=0:
            print(hull)
        tmp = cq.Workplane("XY").workplane(offset=zoff).polyline(hull.exterior.coords).close()
        tmp = tmp.workplane(offset=thk).polyline(hull2.exterior.coords).close()
        tmp = tmp.loft()
        layerwp.add(tmp)

Reply all
Reply to author
Forward
0 new messages