Splining through sketch points

Splining through sketch points

alongman1
Participant Participant
1,441 Views
7 Replies
Message 1 of 8

Splining through sketch points

alongman1
Participant
Participant

Hi,

 

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, adsk.cam, traceback
import math

def run(context):
    ui = None
    try:
        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

                splinePoints1.add(sketchPoints[0])
                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 :
                        splinePoints1.add(sketchPoints[q])
                    else:
                        splinePoints2.add(sketchPoints[q])
                spline1 = zSketch.sketchCurves.sketchFittedSplines.add(splinePoints1)
                spline2 = zSketch.sketchCurves.sketchFittedSplines.add(splinePoints2)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
 
splineFail.PNG
 
Thanks in advance, 
Andrew
0 Likes
1,442 Views
7 Replies
Replies (7)
Message 2 of 8

alongman1
Participant
Participant

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

0 Likes
Message 3 of 8

kandennti
Mentor
Mentor

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?

0 Likes
Message 4 of 8

alongman1
Participant
Participant

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

0 Likes
Message 5 of 8

kandennti
Mentor
Mentor

Hi @alongman1 .

 

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

0 Likes
Message 6 of 8

JeromeBriot
Mentor
Mentor

@alongman1  a écrit :

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


Hello,

 

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

 

Message 7 of 8

MichaelT_123
Advisor
Advisor

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

 

Regards

MichaelT

 

 

MichaelT
0 Likes
Message 8 of 8

alongman1
Participant
Participant

The public link is here: https://a360.co/3rdav72. 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.

0 Likes