MoveFeatures.add fails due to 'invalid transform'

MoveFeatures.add fails due to 'invalid transform'

wh6Q9NU
Advocate Advocate
405 Views
1 Reply
Message 1 of 2

MoveFeatures.add fails due to 'invalid transform'

wh6Q9NU
Advocate
Advocate

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()))
 
0 Likes
406 Views
1 Reply
Reply (1)
Message 2 of 2

kandennti
Mentor
Mentor

Hi wh6Q9NU.

 

I think it's the same problem as here.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/identity-matrix-causing-problems/td-p/9125... 

 

Perhaps unchanged conversions are not allowed because CAD is meaningless.
In the conversion that does nothing even manually, the OK button was gray and could not be pressed.

 

 

0 Likes