@pl.fauny .
Initially, I used the CurveEvaluator3D.getStrokes method to get the passing points from each line and create a spline.
The second one was improved to add only one passing point near the start and end points of each line.
I also added more passing points near the start and end points.
# Fusion360API Python script
import adsk.core, adsk.fusion, traceback
_tolerance = 0.01
_nearCount = 5
def run(context):
ui = adsk.core.UserInterface.cast(None)
try:
app :adsk.fusion.Application = adsk.core.Application.get()
ui = app.userInterface
# select sketch curve
msg :str = 'Select'
selFiltter :str = 'SketchCurves'
sel :adsk.core.Selection = selectEnt(msg ,selFiltter)
if not sel: return
# get sketch curve
sktCrv :adsk.fusion.SketchEntity = sel.entity
refSkt: adsk.fusion.Sketch = sktCrv.parentSketch
# get path
comp: adsk.fusion.Component = refSkt.parentComponent
path: adsk.fusion.Path = comp.features.createPath(sktCrv)
if path.count < 2:
return
# get points
pathEnt: adsk.fusion.PathEntity
pntsGroup = []
for pathEnt in path:
geo = pathEnt.entity.worldGeometry
if hasattr(geo, 'asNurbsCurve'):
geo = geo.asNurbsCurve
eva: adsk.core.CurveEvaluator3D = geo.evaluator
_, startPrm, endPrm = eva.getParameterExtents()
_, vertexCoordinates = eva.getStrokes(startPrm, endPrm, _tolerance)
pnts = [p for p in vertexCoordinates]
pntsCount = len(pnts)
print(f'-- {geo.objectType},{startPrm},{endPrm} --')
nearStarts = getNearPoints(eva, _nearCount, pnts[0], pnts[1])
pnts[1:1] = nearStarts
if pntsCount > 2:
nearEnds = getNearPoints(eva, _nearCount, pnts[-1], pnts[-2])
pnts[-1:1] = nearEnds[::-1]
pntsGroup.append(pnts)
# Reordering
objs: adsk.core.ObjectCollection = adsk.core.ObjectCollection.create()
if pntsGroup[0][0].isEqualTo(pntsGroup[1][0]) or pntsGroup[0][0].isEqualTo(pntsGroup[1][-1]):
[objs.add(p) for p in pntsGroup[0][::-1]]
else:
[objs.add(p) for p in pntsGroup[0]]
for pnts in pntsGroup[1:]:
pnt: adsk.core.Point3D = objs.item(objs.count - 1)
if pnt.isEqualTo(pnts[0]):
[objs.add(p) for p in pnts[1:]]
else:
[objs.add(p) for p in pnts[1::-1]]
# create curve
skt: adsk.fusion.Sketch = comp.sketches.add(comp.xYConstructionPlane)
skt.arePointsShown = False # hide sketch points
skt.isComputeDeferred = True
skt.sketchCurves.sketchFittedSplines.add(objs)
skt.isComputeDeferred = False
ui.messageBox('Done')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def getNearPoints(
eva: adsk.core.CurveEvaluator3D,
count :int,
p1: adsk.core.Point3D,
p2: adsk.core.Point3D) -> list:
_, prms = eva.getParametersAtPoints([p1,p2])
nearPrm = (prms[1] - prms[0]) / (_nearCount + 1)
prmLst = [prms[0] + (nearPrm * idx) for idx in range(1, count + 1)]
print(f'{prms[0]}:{prms[1]}:{nearPrm}')
_, tmpLst = eva.getPointsAtParameters(prmLst)
pntLst = [p for p in tmpLst if not p1.isEqualTo(p)]
print(f'count:{len(pntLst)}')
return pntLst
def selectEnt(
msg :str,
filtterStr :str) -> adsk.core.Selection :
try:
app = adsk.core.Application.get()
ui = app.userInterface
sel = ui.selectEntity(msg, filtterStr)
return sel
except:
return None

It's a little better, but not much better.
I have also noticed that the arc part is not correct.
So I made a sample with only multiple arcs and tried it, and made it display the points as well.

The results were different depending on the arc selected.
I suspect that the cause of this is that the passage point is not calculated correctly due to the relationship between the start point and the end point, but I have no idea how to deal with this.