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: 

Get Sketch Plane Using Python

1 REPLY 1
Reply
Message 1 of 2
isocam
661 Views, 1 Reply

Get Sketch Plane Using Python

Can anybody help?

Does anybody know how to get the sketch plane (Front, Top or Right) that a sketch was created on?

I can do this in Inventor but I do not know how to do this in Fusion 360

Many thanks in advance!!!

Darren

1 REPLY 1
Message 2 of 2
kandennti
in reply to: isocam

Hi isocam.

 

Try it

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        sel = Sel('select sketch','Sketches')
        if sel is None: return
        skt = adsk.fusion.Sketch.cast(sel.entity)        
        
        refplane = skt.referencePlane #This
        if refplane.classType() == 'adsk::fusion::BRepFace':
            msg = '{} face'.format(refplane.body.name)
        else:
            msg = refplane.name
        ui.messageBox('Reference Plane is\n' + msg)
        
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def Sel(msg, selFilter):
    app = adsk.core.Application.get()
    ui  = app.userInterface
    try:
        return ui.selectEntity(msg, selFilter)
    except:
        return None

 

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report