Self intersecting sweep on a tight curve - detecting and deleting resulting artifact

Aaargh74
Explorer

Self intersecting sweep on a tight curve - detecting and deleting resulting artifact

Aaargh74
Explorer
Explorer

I have a routine in a script to make a surface sweep along a spline similar to a bevel. 
If the spline has a tight curve the resultant sweep has an artifact on the rear.  This is upsetting subsequent operations in the script.

I'm after suggestions to detect and delete this artifact  

Aaargh74_0-1647568163816.png

Aaargh74_1-1647568215362.png

 

 

0 Likes
Reply
359 Views
1 Reply
Reply (1)

kandennti
Mentor
Mentor

Hi @Aaargh74 .

 

Interesting subject.

 

At first I thought I could determine self-intersections with the SurfaceEvaluator.getParamAnomaly method, but I could not.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-d6b7d30a-972b-4117-9292-c0a87be8ba62 

 

The next method I came up with was to use the TemporaryBRepManager.createWireFromCurves method.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-62A548C4-305D-47D3-9574-A09743736FC8 

 

I created a sample like this.

 Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

def run(context):
    ui: adsk.core.UserInterface = None
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface

        msg: str = 'Select Face'
        selFilter: str = 'Faces'
        sel: adsk.core.Selection = selectEnt(msg, selFilter)
        if not sel:
            return

        face: adsk.fusion.BRepFace = sel.entity

        if isSelfIntersect(face):
            msg = 'Self intersecting.'
        else:
            msg = 'Not self intersecting.'
        ui.messageBox(msg)


    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def isSelfIntersect(
    face: adsk.fusion.BRepFace) -> bool:

    tempMgr: adsk.fusion.TemporaryBRepManager = adsk.fusion.TemporaryBRepManager.get()
    curves = [e.geometry for e in  face.edges]

    try:
        tempMgr.createWireFromCurves(
            curves,
            False
        )

        return False
    except:
        return True


def selectEnt(
        msg: str,
        filterStr: str) -> adsk.core.Selection:

    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        sel = ui.selectEntity(msg, filterStr)
        return sel
    except:
        return None

 

I tried it with the attached file and it is able to determine.

1.png

 

However, since self-intersections are determined by the boundaries, it could not be determined for shapes where the boundaries are not self-intersecting.

2.png

 

The only other way I can think of is that self-intersecting surfaces will cause offset surfaces to fail, even if they are only a short distance away. However, I did not know if it is possible to determine that a surface with an offset failure is always self-intersecting.

 

Also, I can't think of any way to remove the unwanted part.

0 Likes