Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

How to remove inner sketch lines from an intersection sketch?

Anonymous

How to remove inner sketch lines from an intersection sketch?

Anonymous
Not applicable

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

0 Likes
Reply
Accepted solutions (1)
1,923 Views
4 Replies
Replies (4)

kandennti
Mentor
Mentor
Accepted solution

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

 

0 Likes

metd01567
Advocate
Advocate

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

0 Likes

kandennti
Mentor
Mentor

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()
・・・
0 Likes

metd01567
Advocate
Advocate

Thanks, I've got a similar problem.

0 Likes