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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Moving Existing Points in an existing sketch

Message 1 of 9
972 Views, 8 Replies

Moving Existing Points in an existing sketch

There is plenty of examples that create new sketches and points. 

Looking for some sample code on how to move an existing spline point in an existing sketch. This could be really useful for editing existing sketch geometry instead of always creating new, Like in the Fusion gear program I am always having to create a new component instead of editing the existing on. Thanks,

Message 2 of 9
in reply to: michael.graybar

Here's a very simple program that illustrates the process of moving some points on a spline.  I've also attached the model I used to test this.  The points that the spline goes through are regular sketch points and can be moved and constrained in any way other sketch points can.


def run(context):
        app = adsk.core.Application.get()
        ui = app.userInterface
        des = adsk.fusion.Design.cast(app.activeProduct)
        sk = des.rootComponent.sketches.itemByName('Test')
        spline = sk.sketchCurves.sketchFittedSplines.item(0)
        pnts = spline.fitPoints
        skPnt = pnts.item(1)
        res = skPnt.move(adsk.core.Vector3D.create(-1,2,0))

        skPnt = pnts.item(2)
        res = skPnt.move(adsk.core.Vector3D.create(2,2,0))
        if ui:

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 9
in reply to: michael.graybar

I just realized I was using a pre-production build of Fusion to create the file that I attached so you won't be able to open it.  Here's an equivalent file created with the current Fusion version.

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 4 of 9
in reply to: ekinsb

I used a similar method to modify a simple sketch based on external data. Works fins. But, I couldn't figure a way to get a geometry update for the loft operation based on the sketch.

In UI mode with fusion: any edits of and root sketch result in a recalculation of the resulting body, once you click the 'finish sketch' button. Is there an equivalent to this, something like sketch.finish() in the API?




Message 5 of 9

is it the


command I need to call to trigger a complete update?


Looks bit like.

Message 6 of 9
in reply to: designingberlin

Yes, that is forcing a recompute.  I wasn't sure if it would be needed but found that it was after some testing.  We'll expose this as a method in the API in the future instead of making you execute the command.

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 7 of 9

Is there anyway to move sketch points by end coordinates to avoid the vector math and eventual rounding errors? Is merge an option?




line1 = sk.sketchCurves.sketchLines.item(0)  Selects the first line entity

ptemp = adsk.core.Point3D.create(1.0, 1.0, 0)  Creates a point to merge to

sPoint = line1.startSketchPoint

ePoint = line1.endSketchPoint

res = ePoint.merge(ptemp)

Message 8 of 9

This seems to work, but is there a more straightforward way?


line1 = sk.sketchCurves.sketchLines.item(0) #Selects the first line entity

ptemp = sk.sketchPoints.add(adsk.core.Point3D.create(randint(-9,9),0,randint(-9,9)))

sPoint = line1.startSketchPoint

res = ptemp.merge(sPoint)

res = ptemp.deleteMe()

Message 9 of 9
in reply to: michael.graybar

Using a Vector3D and the move method is the way to go.  A vector is just used to define the delta difference between the current position and the new position.  There aren't any rounding errors to worry about because those calculations are being done as double-precision floating point and are much more accurate than the geometry needs.


If you have an know end point of a line and want to move it to (5,4,0) it could be done something like this.


line1 = sk.sketchCurves.sketchLines.item(0) 
startPnt = line1.startSketchPoint
newPosition = adsk.core.Point3D.create(5,4,0)



Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog

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