I changed your script a little and did this, but the curve was inserted into the original sketch. Originally I wanted to apply the loft function between sketches, but it can be done between the curves of the same sketch. I'm right? I have attached my script, it creates a copy of the curve, but I cannot create the surface. Maybe you can tell me what I'm doing wrong? The answer to your question: the error occurs on any sketch, for example on a line.

#Fusion360API Python script
import adsk.core, adsk.fusion, traceback
_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)
def run(context):
try:
global _app, _ui
_app = adsk.core.Application.get()
_ui = _app.userInterface
filter =[
# 'Sketches'
# 'SketchConstraints',
'Profiles',
'Texts',
'SketchCurves',
'SketchLines',
'SketchCircles',
'SketchPoints']
design = _app.activeProduct
rootComp = design.rootComponent
# select sketch entity
msg :str = 'Select Sketch Entity'
selFiltter :str = ','.join(filter)
sel :adsk.core.Selection = selectEnt(_ui, msg ,selFiltter)
if not sel: return
# get sketch entities
skt :adsk.fusion.Sketch = getSketch(sel.entity)
objs :adsk.core.ObjectCollection = getSketchAllEntities(skt)
new_obj = adsk.core.ObjectCollection.create()
mat = adsk.core.Matrix3D.create()
mat.translation = adsk.core.Vector3D.create(0, 0, 1)
new_obj = skt.copy(objs, mat)
path1 = rootComp.features.createPath(skt.sketchCurves[0])
path2 = rootComp.features.createPath(skt.sketchCurves[1])
loftFeats = rootComp.features.loftFeatures
loftInput = loftFeats.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
loftSectionsObj = loftInput.loftSections
loftSectionsObj.add(path1)
loftSectionsObj.add(path2)
loftInput.isSolid = False
except:
if _ui:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def selectEnt(
_ui :adsk.core.UserInterface,
msg :str,
filtterStr :str
) -> adsk.core.Selection :
try:
sel = _ui.selectEntity(msg, filtterStr)
return sel
except:
return None
def getSketch(
ent
) -> adsk.fusion.Sketch:
skt = adsk.fusion.Sketch.cast(ent)
if skt:
return skt
return ent.parentSketch
def getSketchAllEntities(
skt :adsk.fusion.Sketch
) -> adsk.core.ObjectCollection:
objs = adsk.core.ObjectCollection.create()
[objs.add(e) for e in skt.sketchPoints if not e.isReference]
[objs.add(e) for e in skt.sketchCurves]
[objs.add(e) for e in skt.sketchTexts]
return objs
I am able to create a curve between the two sketches that I search by name in the script, this even works with 3D sketches.