Message 1 of 2
MoveFeatures.add fails due to 'invalid transform'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I post this example since the documentation is not fully clear on this and I encounter a failure when running my scripts.
rootComp.features.moveFeatures.add() fails for a moveInput with a translation of effective 0.
With, in my case, a dynamic input of params, somethimes there is no transform to apply, but I would expect the script to execute well in this case..
Question: Maybe a zero-transform can be handled by the API in a more graceful way? Or otherwise be added to the documentation as a known reason for failing?
Example (will fail, see inline comment):
import adsk.core, adsk.fusion, traceback def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface # Create a document. doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType) product = app.activeProduct design = adsk.fusion.Design.cast(product) # Get the root component of the active design rootComp = design.rootComponent # Create sketch sketches = rootComp.sketches sketch = sketches.add(rootComp.xZConstructionPlane) sketchCircles = sketch.sketchCurves.sketchCircles centerPoint = adsk.core.Point3D.create(0, 0, 0) sketchCircles.addByCenterRadius(centerPoint, 5.0) # Get the profile defined by the circle prof = sketch.profiles.item(0) # Create an extrusion input extrudes = rootComp.features.extrudeFeatures extInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation) # Define that the extent is a distance extent of 5 cm distance = adsk.core.ValueInput.createByReal(5) extInput.setDistanceExtent(True, distance) # Create the extrusion ext = extrudes.add(extInput) # Get the body created by the extrusion body = ext.bodies.item(0) m1 = adsk.core.Matrix3D.create() # note the zero transform m1.translation = adsk.core.Vector3D.create(0, 0, 0) bodyColl = adsk.core.ObjectCollection.create() bodyColl.add(body) moveInput = rootComp.features.moveFeatures.createInput(bodyColl, m1) # this step will fail due to 'invalid transform' moveFeat = rootComp.features.moveFeatures.add(moveInput) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))