Create Sketch with Point and Vector

Create Sketch with Point and Vector

Anonymous
Not applicable
1,143 Views
2 Replies
Message 1 of 3

Create Sketch with Point and Vector

Anonymous
Not applicable

I would like to create a new sketch at a point (Point3D) facing along a Vector (Vector3D).

What would be my options to accomplish this?

I am guessing I can't get around creating a construction plane for the sketch to sit on.

I know I could generate a BRep face there but I would like to avoid that.

Thanks

0 Likes
Accepted solutions (1)
1,144 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor
Accepted solution

Hi edidos

try this

#Fusion360API python
import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        #Vector & Point
        vec = adsk.core.Vector3D.create(0,0,1)
        pnt = adsk.core.Point3D.create(2.0,3.0,4.0)
        
        #Doc
        app = adsk.core.Application.get()
        ui = app.userInterface
        
        app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        des = app.activeProduct
        root = des.rootComponent
        
        planes = root.constructionPlanes
        planeInput = planes.createInput()
        
        #Plane
        pln3d = adsk.core.Plane.create(pnt, vec)
        planeInput.setByPlane(pln3d)
        
        des.designType = adsk.fusion.DesignTypes.DirectDesignType
        pln = planes.add(planeInput)
        des.designType = adsk.fusion.DesignTypes.ParametricDesignType
        
        #sketch
        skts = root.sketches
        skt = skts.add(pln)
        
        ui.messageBox('Done\n{}'.format(skt.name))
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
0 Likes
Message 3 of 3

Anonymous
Not applicable

Thank you.

This is exactly what I needed.

0 Likes