Get Sketch Plane Using Python

Get Sketch Plane Using Python

isocam
Collaborator Collaborator
953 Views
1 Reply
Message 1 of 2

Get Sketch Plane Using Python

isocam
Collaborator
Collaborator

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

0 Likes
954 Views
1 Reply
Reply (1)
Message 2 of 2

kandennti
Mentor
Mentor

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