Hi @0xHexdec .
Since the API did not seem to provide the functionality, we used a text command.
Please make the attached f3d file active and run the following script.
# Fusion360API Python script
import traceback
import adsk.fusion
import adsk.core
def run(context):
ui = adsk.core.UserInterface.cast(None)
try:
app: adsk.core.Application = adsk.core.Application.get()
ui = app.userInterface
des: adsk.fusion.Design = app.activeProduct
root: adsk.fusion.Component = des.rootComponent
crv1: adsk.fusion.SketchEntity = root.sketches[0].sketchCurves[0]
crv2: adsk.fusion.SketchEntity = root.sketches[1].sketchCurves[0]
intersectionCurve: adsk.fusion.SketchEntity = execIntersectionCurve(crv1, crv2)
ui.messageBox('Done')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def execIntersectionCurve(
crv1: adsk.fusion.SketchEntity,
crv2: adsk.fusion.SketchEntity,
skt: adsk.fusion.Sketch = None,) -> adsk.fusion.SketchEntity:
app: adsk.core.Application = adsk.core.Application.get()
ui: adsk.core.UserInterface = app.userInterface
sels: adsk.core.Selections = ui.activeSelections
if not skt:
des: adsk.fusion.Design = app.activeProduct
root: adsk.fusion.Component = des.rootComponent
skt = root.sketches.add(root.xYConstructionPlane)
sktEntsCount = skt.sketchCurves
sels.add(skt)
app.executeTextCommand(u'Commands.Start SketchActivate')
app.executeTextCommand(u'Commands.Start IntersectionCurve')
sels.add(crv1)
sels.add(crv2)
try:
app.executeTextCommand(u'NuCommands.CommitCmd')
except:
pass
finally:
app.executeTextCommand(u'NaFusionUI.SketchStopCmd')
if sktEntsCount == skt.sketchCurves.count:
return None
else:
return skt.sketchCurves[-1]
If you select a curve for which the command succeeds in the GUI, it is OK, but if you select a curve for which the command fails, you will get an error.
I need some logic to determine if it will fail beforehand, but I haven't come up with it.