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: 

Splining through sketch points

Message 1 of 8
201 Views, 7 Replies

Splining through sketch points



I have posted previously about a problem within the same project. I am trying to capture an extruded volume of the same shape as a derived body, offset by a small distance. I have sliced the body in 2 directions and intersected these sketches. These intersections are for splines, to guide the lofts to generate the larger body. The problem is the numbering of the splines seems to be slightly random - the first 10 intersections seem to be numbered sensibly (ABABAB) from the nose and the tail, but something switches towards the middle and the sequence doesn't match up. I therefore get odd spline shapes, instead of the smooth rails I need between profiles. I have attached an image below. If anyone has any ideas on how to get the numbering of the splines to conform to some basic system, or how to figure out how to get the correct points in the splines that would be great. I have added the spline code below. 

Note, I don't think the x and y constraints on which points get added to which spline are doing anything, as I believe this is the same result as a basic script adding odd and even points to different splines.


import adsk.core, adsk.fusion,, traceback
import math

def run(context):
    ui = None
        app = adsk.core.Application.get()
        ui  = app.userInterface
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)
        #get root component in active design
        rootComp = design.rootComponent

        #get construction planes
        planes = rootComp.constructionPlanes
        #create construction plane intput

        #get sketches
        sketches = rootComp.sketches

        NumPrevSketches = 0
        carHeight = 84.5
        xySlices = 20
        xzSlices = 75
        Zmin = -24.5
        #ignoring the bottom few sketches that arent curved
        z0sketchNum = NumPrevSketches + xzSlices + math.floor((carHeight - Zmin)/xySlices)
        sketchCount = sketches.count
        splineSketches = sketchCount - z0sketchNum

        for i in range(sketchCount😞
            if i > z0sketchNum:
                splinePoints1 = adsk.core.ObjectCollection.create()
                splinePoints2 = adsk.core.ObjectCollection.create()
                zSketch = sketches[i]
                sketchPoints = zSketch.sketchPoints

                numSketchPoints = sketchPoints.count

                for q in range(1, numSketchPoints😞
                    pnt0 = sketchPoints[q-1]
                    pnt1 = sketchPoints[q]

                    pos0 = adsk.fusion.SketchPoint.cast(pnt0)
                    pos1 = adsk.fusion.SketchPoint.cast(pnt1)

                    posArray0 = pos0.geometry.asArray()
                    posArray1 = pos1.geometry.asArray()

                    xVal0 = posArray0[0]
                    xVal1 = posArray1[0]

                    yVal0 = posArray0[1]
                    yVal1 = posArray1[1]

                    xDifPrev = xVal1 - xVal0
                    yDifPrev = yVal1 - yVal0

                    if yDifPrev >1 and xDifPrev < 14 :
                spline1 = zSketch.sketchCurves.sketchFittedSplines.add(splinePoints1)
                spline2 = zSketch.sketchCurves.sketchFittedSplines.add(splinePoints2)

        if ui:
Thanks in advance, 
Message 2 of 8
in reply to: alongman1

*The numbering of intersection points [seems random], not splines. 

Message 3 of 8
in reply to: alongman1

Hi @alongman1 .


I'd like to try it, but I didn't know what it meant.

Can you provide an f3d file for me to try?

Message 4 of 8
in reply to: kandennti

@kandennti the f3z file is too large, how can I share it properly? 

Message 5 of 8
in reply to: alongman1

Hi @alongman1 .


It does not have to be production data.
Do you have any simple data that can reproduce the same condition?

Message 6 of 8
in reply to: alongman1

@alongman1  a écrit :

@kandennti the f3z file is too large, how can I share it properly? 



You can share a public link: How to share a Fusion 360 design


Message 7 of 8
in reply to: alongman1

Hi AlongMan,


If the 'offset distance' is small in comparison with the object size, it is much simpler to find out the area of the surface you want to 'thicken' and multiply it by offset value.

For the single body, perhaps F360 UI and calculator would do the task






Message 8 of 8
in reply to: alongman1

The public link is here: Thank you @JeromeBriot.

@MichaelT_123 I am trying to automate the project entirely, so looking to avoid resorting to the UI, although I know the task can be completed relatively easily in the UI.

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