Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Implement the move feature point to point move type in the Fusion 360 API

bevis.hobbs21
Contributor

Implement the move feature point to point move type in the Fusion 360 API

bevis.hobbs21
Contributor
Contributor

How do you implement the move feature point to point move type option in the Fusion 360 API? 

In the move/copy feature there is a point to point move type option, but I can't find anything in the documentation about how to do this in the API in a python add-in:

Fusion 360 Move Feature point to point move type.png

0 Likes
Reply
Accepted solutions (2)
1,301 Views
9 Replies
Replies (9)

BrianEkins
Mentor
Mentor
Accepted solution

The Move command was completely redone a while ago to support a parametric move.  In the Move command, one of move types is a "Free Move".  This moves and/or rotates the body or component, but there aren't any parameters created to modify the move later.  The other move types result in associated parameters or the move is dependent on geometry, like in the case of the Point-to-Point move.  Before the rewrite of the Move command, it only supported the "Free Move" type of move.  The API was implemented for the older Move command and has not yet been updated to support the new move capabilities.

 

You can still move a body or component like a point-to-point move by creating a matrix that defines the desired translation, but the result won't be associated with any points.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes

bevis.hobbs21
Contributor
Contributor

Could you give me an example, using python of how to do a point-to-point move type by creating a matrix that defines the desired translation?

0 Likes

bevis.hobbs21
Contributor
Contributor

Before I posted how to implement the move feature point to point move type in the Fusion 360 API I spent ages looking at that example to try and figure out how to do a point to point move type, but I'm not to familiar with using Matrix3D and Vector3D and I couldn't think how to do it. An example that clearly shows how to use Matrix3D and Vector3D to do a point to point move type would be really helpful.

0 Likes

BrianEkins
Mentor
Mentor
Accepted solution

Here's some code that demonstrates doing the equivalent of the point-to-point move.  To demonstrate a couple of approaches, for the first point I have an entity selected that represents a point get the X-Y-Z position of the point in space.  For the second point, I have a hard-coded coordinate but they could both be calculated somehow or both be from a user selection.  In the end, I have two Point3D objects which represent the X-Y-Z coordinates of the from and to points.

 

It then creates a matrix and defines the translation portion of the matrix using the vector that defined from point 1 to point 2. Finally, it uses this matrix to create a move feature to move the selected body.

 

# Get a body by having the user select one.
body: adsk.fusion.BRepBody = ui.selectEntity('Select a body.', 'Bodies').entity

# Have an entity selected that represents a point.
# This can be a Vertex, Sketch Point, or Construction Point.
pointEnt = ui.selectEntity('Select a point entity', 'ConstructionPoints, SketchPoints, Vertices').entity

# Get the XYZ position of the point in model space.
pnt1: adsk.core.Point3D = None
if pointEnt.objectType == adsk.fusion.SketchPoint.classType():
    skPoint: adsk.fusion.SketchPoint = pointEnt
    pnt1 = skPoint.worldGeometry
else:
    pnt1 = pointEnt.geometry

# The second point is defined using a known coordinate.
pnt2 = adsk.core.Point3D.create(5, 0, 0)

# Create a matrix that defines the translation from point 1 to point 2.
trans: adsk.core.Matrix3D = adsk.core.Matrix3D.create()
trans.translation = pnt1.vectorTo(pnt2)

# Create a move feature using the matrix.
moveFeatures = des.rootComponent.features.moveFeatures
inputEnts = adsk.core.ObjectCollection.create()
inputEnts.add(body)
moveInput = moveFeatures.createInput(inputEnts, trans)
moveFeature = moveFeatures.add(moveInput)

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes

simonefailla
Community Visitor
Community Visitor

hi, is it possible using the move from point to point command to create multiple copies of the same object, select the different points and position them?

it would be helpful in placing the same screws in different holes

0 Likes

BrianEkins
Mentor
Mentor

For the case you described, you can effectively get the same thing by computing the desired location of the new occurrence and creating a matrix that defines that location, and use the matrix when adding the new occurrence.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes

i_tin
Community Visitor
Community Visitor

As features.moveFeatures.createInput() is noted as **RETIRED** in the documentation, can you provide a sample code with .createInput2()? Also, is it advisable NOT to use .defineAsPointToPoint()? Finally, if .defineAsPointToPoint() is OK to use, what are its parameters? The documentation is vague saying both parameters are Base - an example would help. Thank you Brian!

0 Likes

BrianEkins
Mentor
Mentor

Here's some code using the new createInput2 that uses two arbitrary points to define the magnitude and direction of a move feature.

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        des: adsk.fusion.Design = app.activeProduct        
        root = des.rootComponent
        body = root.bRepBodies[0]

        entities = adsk.core.ObjectCollection.create()
        entities.add(body)
        moveInput = root.features.moveFeatures.createInput2(entities)
        fromPnt = adsk.core.Point3D.create(1,0,0)
        toPnt = adsk.core.Point3D.create(5,3,6)
        moveTrans = adsk.core.Matrix3D.create()
        moveTrans.translation = fromPnt.vectorTo(toPnt)
        moveInput.defineAsFreeMove(moveTrans)

        moveFeat = root.features.moveFeatures.add(moveInput)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) 
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
1 Like