pythoncadstepcadquery

How to detect filleted or chamfered edges in CadQuery


I am using CadQuery to detect certain information present in a provided STEP file. This includes data like the number of different types of edges, of different types of faces, the dimensions of the bounding box, part volume, etc.

I also need to detect if a given edge has a fillet or chamfer attached. Unfortunately, I can't quite figure out the syntax necessary to do this, and the CadQuery documentation is very much focused on creating objects over reading existing ones. For other data, it is a line like file.edges('%PARABOLA').size(), but that doesn't work here.

I know you can do detec fillets in PythonOCC, selecting specific outputs from code like curve_handle.DynamicType().Name(), but we're trying to not use PythonOCC.

Any help would be appreciated. Thanks.


Solution

  • Logical-Baseball-478 on Reddit's r/cadquery came up with a solution that has worked quite well. Posting for posterity:

    from build123d import *
    from ocp_vscode import *
    from OCP.BRep import BRep_Tool
    
    b = Box(1, 1, 1)
    b = fillet(b.edges().group_by(Axis.Z)[-1], 0.2)
    
    # The above is equivalent to importing a step file as `b`
    # b = import_step("some_step_file.step")
    
    fillets = []
    for edge in b.edges():
        type_name = BRep_Tool.Curve_s(edge.wrapped, 0.0, 1.0).DynamicType().Name()
        if type_name == "Geom_TrimmedCurve":
            fillets.append(edge)
            
    show(b, fillets)