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

making a 3D spline using points of existing sketch splines

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
franck.gressier
512 Views, 2 Replies

making a 3D spline using points of existing sketch splines

I have been searching to do this in various ways but nothing worked out.

What I want to do:

I have a bunch of sketch splines that I use to create a loft.

As guide rail I would like to make a spline going by point #5 of each of the sketch splines...

 

xYplane = design.rootComponent.xYConstructionPlane
sketch3dSplines = sketches.add(xYplane)
sketch3dSplines.name ="sketch3dSplines"
SplineRailPoints = adsk.core.ObjectCollection.create()
for loc in sections: # I have a dictionary indexing my sketch Splines
courbe = sketchsProfils[loc].sketchCurves.sketchFittedSplines.item(0)
sketch3dSplines.include(courbe.fitPoints(5))
SplineExPoints.add(sketch3dSplines.points(-1))

SplineEx = sketch3dSplines.sketchCurves.sketchFittedSplines.add(SplineExPoints)

This says that SkechPointList object is not callable... when I try to include the spline fitPoint  5 .

Adding without including isn't better.

 

I have also tryed to make a list of the points while creating the splines but then I get a curve all messed up in the xY plane and not at all what I expect...

 

Do I need to add some .geometry in this ?

 

 

 

2 REPLIES 2
Message 2 of 3

I have kept searching.

I can access the 3d coordinates of the points like this:

 

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.worldGeometry
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()))

 

But that is not really what I want. I would like to reuse the existing points.

I guess I could create new points and merge but it seems heavy. 

Message 3 of 3

Sometimes you look for complicate things....

Not callable is because I used "()" which are for functions...

.item(5) is better.

[5] could do I guess

But I get another error:

2019-11-24_19h56_39.png

However, i was able to avercome this with world.geometry...

This works ! :o)

import adsk.core, adsk.fusion, traceback


def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
comp = design.activeComponent
#ui.messageBox(comp.name)
sketches = comp.sketches
SplineExPoints = adsk.core.ObjectCollection.create()

for sk in sketches:
spline = sk.sketchCurves.sketchFittedSplines.item(0)
SplineExPoints.add(spline.fitPoints.item(5).worldGeometry)

xYplane = design.rootComponent.xYConstructionPlane
sketch3dSplines = sketches.add(xYplane)
SplineEx = sketch3dSplines.sketchCurves.sketchFittedSplines.add(SplineExPoints)


except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
 

 

Tags (3)

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