Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to remove inner sketch lines from an intersection sketch?

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
1937 Views, 4 Replies

How to remove inner sketch lines from an intersection sketch?

How can I be able to remove the inner sketch lines of an intersection sketch, such that I only have the outer edges in Python?
For example, I have an intersection of my Brep body below. The left hand side is the output of doing the intersection sketch, and the right hand side is what I want. I did the right hand side manually through Fusion 360 but I need to also do it in Python code. 
So, does anyone have an idea?
FusionHelp.jpg

4 REPLIES 4
Message 2 of 5
kandennti
in reply to: Anonymous

hi. jmperez6

 

Because it was an interesting theme, I challenged it.
I use temporary patch surfaces and projections.
Therefore, we will create a new sketch which is the outer circumference of the profile.

(Because there are not enough exception handling, it may cause an error.)

 It is only parametric mode.

import adsk.core, adsk.fusion, traceback
_ui = None

def run(context):
    try:
        global _ui
        
        app = adsk.core.Application.get()
        _ui  = app.userInterface
        prod = app.activeProduct
        
        #select Sketch
        filters = 'Sketches'
        sel = Sel('Select Sketch / ESC-Cancel', filters)
        if sel is None:
            return
        sel_skt = sel.entity
        refplane = sel_skt.referencePlane
        
        #component
        comp = prod.rootComponent
        if sel_skt.assemblyContext != None:
            comp = sel_skt.assemblyContext.component
        
        #patch
        profs = lst2objCollection(sel_skt.profiles)
        patches = comp.features.patchFeatures
        patchInput = patches.createInput(profs, 
                        adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        tmp_patch = patches.add(patchInput)
        
        #project
        res_skt = comp.sketches.add(refplane)
        [res_skt.project(face) for face in tmp_patch.faces]
        
        #Sketch Remove Reference
        curves = res_skt.sketchCurves   
        pros = ['sketchArcs',
                'sketchCircles',
                'sketchConicCurves',
                'sketchEllipses',
                'sketchEllipticalArcs',
                'sketchFittedSplines',
                'sketchFixedSplines',
                'sketchLines']
        for pro in pros:
            [remove_ref(c) for c in eval('curves.' + pro)]
        
        #Remove Temp Patch
        tmp_patch.deleteMe()
        
        _ui.messageBox('Done')
    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def lst2objCollection(lst):
    ents = adsk.core.ObjectCollection.create()
    for ent in lst:
        ents.add(ent)
    return ents

def remove_ref(skt_crv):
    skt_crv.isReference = False

def Sel(msg, selFilter):
    global _ui
    try:
        return _ui.selectEntity(msg, selFilter)
    except:
        return None

 

Message 3 of 5
metd01567
in reply to: kandennti

Doesn't a generic SketchCurve have a deleteMe method/isReference attribute?  could that be used to avoid the walk though known curve types?

Message 4 of 5
kandennti
in reply to: metd01567

I'm sorry. Similar processing can be done here.

 

・・・
        #Sketch Remove Reference
        [remove_ref(crv) for crv in res_skt.sketchCurves]

        #Remove Temp Patch
        tmp_patch.deleteMe()
・・・
Message 5 of 5
metd01567
in reply to: kandennti

Thanks, I've got a similar problem.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report