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: 

Create arbitrary plane for sketch in a script

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
951 Views, 2 Replies

Create arbitrary plane for sketch in a script

When writing scripts for the fusion 360 API one could use `sk = root.sketches.add(root.xYConstructionPlane)` to create a sketch plane to add points to. But is it possible to create a arbitrary plane given a normal or base vectors from global coordinates? 

2 REPLIES 2
Message 2 of 3
MichaelT_123
in reply to: Anonymous

Yes Mr.Erikvk,

--> goto <API Documentation>

Sincerely

MichaelT

 

MichaelT
Message 3 of 3
kandennti
in reply to: Anonymous

Hi Erikvk.

 

After executing the script, click the face to create a tangent plane.
It continues until the ESC key is pressed.

#Fusion360API Python Script
#Author-kantoku
#Description-CreatePlane ClickPoint

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        des = adsk.fusion.Design.cast(app.activeProduct)
        root = des.rootComponent
        planes = root.constructionPlanes

        msg = 'Click on the face / End is ESC key'
        skt = None

        while True:
            sel = SelectEnt(ui, msg, 'Faces')
            if sel is None:
                break

            if skt is None:
                skt = root.sketches.add(root.xYConstructionPlane)

            pnt = skt.sketchPoints.add(sel.point)

            InitPlane(planes, sel.entity, pnt)

        ui.messageBox('Done')

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

def InitPlane(
        plns :adsk.fusion.ConstructionPlanes,
        surf :adsk.fusion.BRepFace,
        pnt :adsk.core.Point3D):

    plnInput = plns.createInput()
    if plnInput.setByTangentAtPoint(surf, pnt):
        plns.add(plnInput)

def SelectEnt(
        ui :adsk.core.UserInterface,
        msg :str, 
        filtter_str :str) -> adsk.core.Selection :

    try:
        selection = ui.selectEntity(msg, filtter_str)
        return selection
    except:
        return None

enjoy!

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

Post to forums  

Autodesk Design & Make Report