Hola!
I am having some problems with a script that will slice a part with a plane, then project the intersection of the part with the plane on a sketch. Finally, it will extrude those profiles (as surfaces).
The script works fine for most geometries but occasionally crashes giving the error: "input curves are not on the same plane". I don't understand how this is happening since the input curves were created by the plane to begin with.
Any ideas? Is this a bug?
I am attaching a sample file where this problem occurs as well as the script where this occurs (it is attached as txt because it wouldn't let me upload a .py file).
Thanks!
Sebastian
#Author- #Description- import adsk.core, adsk.fusion, adsk.cam, traceback app = adsk.core.Application.get() if app: ui = app.userInterface def run(context): try: activeDoc = adsk.core.Application.get().activeDocument design = activeDoc.design rootComp = design.rootComponent rootComp.occurrences.addNewComponent (adsk.core.Matrix3D.create()).component.name=("extrusions") modelMinZ=rootComp.boundingBox.minPoint.z+0.002 planes=rootComp.constructionPlanes planeInOff=planes.createInput() planeInOff.setByOffset(rootComp.xYConstructionPlane,adsk.core.ValueInput.createByReal(modelMinZ)) planeMin=planes.add(planeInOff) planeMin.isLightBulbOn=False sketches= rootComp.sketches sketch = sketches.add(planeMin) body = rootComp.bRepBodies.item(0) sketch.projectCutEdges(body) extrudesComp = rootComp.occurrences.itemByName("extrusions:1").component extrudes = extrudesComp.features.extrudeFeatures distance = adsk.core.ValueInput.createByReal(2) curves=sketch.sketchCurves.item(0) profileCollection = adsk.core.ObjectCollection.create() profileCollection.add(rootComp.createOpenProfile(curves)) extrudeInput = extrudes.createInput(profileCollection, adsk.fusion.FeatureOperations.NewBodyFeatureOperation) extrudeInput.isSolid = False extrudeInput.setDistanceExtent(False, distance) extrude = extrudes.add(extrudeInput) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.
Solved by ekinsb. Go to Solution.
There does appear to be a problem in the API that I'll log a bug for.
However, there's another approach that is better and works. If you remove the crossed out lines below and add the code in red, it works.
curves=sketch.sketchCurves.item(0)profileCollection = adsk.core.ObjectCollection.create()profileCollection.add(rootComp.createOpenProfile(curves))prof = sketch.profiles.item(0) extrudeInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
Awesome! This works pretty well. Do you know how this could work in case the profile was open? Lets say the input body is not solid but a surface?
Thanks!
I'm not finding a way that works with an open profile. We're in the process of changing the concept of a Profile so that Profiles should only be used for closed 2D sections. Paths should be used for open and/or 3D sets of connected curves. With this new concept, you should be creating a Path instead of a Profile, but I tested that too and it also has a problem. I've logged both of the issues so we can get them fixed. The only thing I found that worked is if I just extrude one curve at a time.
That sounds ideal, and thoughts for when this might be released? I just want to know if I should try to fix it now another way or if I should just wait.
Thank you for taking a dive at it though!
Sebastian