How to get sketch spline points in python?

How to get sketch spline points in python?

eric
Contributor Contributor
1,145 Views
2 Replies
Message 1 of 3

How to get sketch spline points in python?

eric
Contributor
Contributor

I'm trying to figure out how to get a sketched splines points in python.

I started with the intersetcts example and am able to get to a point where I think I have a selected item in variable geom...

            inputs = command.commandInputs

            input0 = inputs[0];
            sel0 = input0.selection(0);

            entityOne = sel0.entity 

              if isinstance(entityOne,adsk.fusion.SketchCurve):
                geom=entityOne.worldGeometry
                ui.messageBox('isacurve')
             
So here I have geom, but how to get the splines points?

Is there a programming API I can get access too which would explain all the member functions and variables of the adsk class?
Thanks

0 Likes
1,146 Views
2 Replies
Replies (2)
Message 2 of 3

marshaltu
Autodesk
Autodesk

Hello,

 

The following codes demo how to get points from spline. 

 

In addition, you should be able to get API help from the web page http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-A92A4B10-3781-4925-94C6-47DA85A4F65A .

 

Thanks,

Marshal

 

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        spline = adsk.fusion.SketchFittedSpline.cast(ui.activeSelections.item(0).entity)
        if spline:
            result = ''
            for sketchpoint in spline.fitPoints:
                point = sketchpoint.geometry
                result += '{}, {}, {}\n'.format(point.x, point.y, point.z)
            ui.messageBox('Spline points: {}\n {}'.format(spline.fitPoints.count, result))
        
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


Marshal Tu
Fusion Developer
>
Message 3 of 3

jmpframce
Enthusiast
Enthusiast

ok to import  in fusion  like a script? 

0 Likes