Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
bevis.hobbs21
887 Views, 7 Replies

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

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

Labels (1)
7 REPLIES 7
Message 2 of 8
BrianEkins
in reply to: bevis.hobbs21

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
Message 3 of 8
bevis.hobbs21
in reply to: BrianEkins

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?

Message 4 of 8
kandennti
in reply to: bevis.hobbs21
Message 5 of 8
bevis.hobbs21
in reply to: kandennti

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.

Message 6 of 8
BrianEkins
in reply to: bevis.hobbs21

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
Message 7 of 8
simonefailla
in reply to: BrianEkins

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

Message 8 of 8
BrianEkins
in reply to: simonefailla

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums