I've now spent the last three hours on this ... I've tried using sketch curves, paths, open profiles, and more yet nothing seems to work. They all complain in the end that the curves (or profiles, depending on which API is used) are not planar.
I also took your sketch and extruded it, and then in the debugger looked at what Fusion creates, and it is an extrusion feature as expected, and no indication of unusual properties that be a clue as to what we need to do. I search the web a bunch and found nothing that helped with a solution (extruding 3D sketches as surfaces using the API is not a common discussion!)
My gut is this is an API bug, where they are trying to ensure the planar use of extrude even though there is a valid use case where it should work. But just as easily it could be incorrect API usage, as the documentation is weak in these areas.
Here is one of my latest attempts, in case somebody else wants to take the model above and take a whack at the code. The error occurs on the "extrudes.add" line near the end.
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
rootComp = design.rootComponent
extrudes = rootComp.features.extrudeFeatures
# locate our sketch
sketch = rootComp.sketches.itemByName('Sketch1')
if not sketch:
ui.messageBox("Unable to locate sketch")
return
# set extrude distance to 10mm
mm10 = adsk.core.ValueInput.createByString("10 mm")
distance = adsk.fusion.DistanceExtentDefinition.create(mm10)
# define a path from the sketch curves
path = rootComp.features.createPath(sketch.sketchCurves[0])
# set parameters to extrude surfaces according to the profileCollection
extrudeInput = extrudes.createInput(path, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
extrudeInput.setOneSideExtent(distance, adsk.fusion.ExtentDirections.PositiveExtentDirection)
# indiciate that the extrude should be a surface, not a solid
extrudeInput.isSolid = False
# extrude the profile into a surface (*** this generates the error "input curves are not on the same plane" ***)
extrudes.add(extrudeInput)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
If you, or anyone else, have any suggestions, I'm glad to plug away at this some more.
Chris