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()))
Thanks in advance,
Andrew