The Inventor 2013 API now fully supports Move Body Features. A move body feature allows you to manipulate the location and orientation of a body and is listed in the feature tree. There are different ways you can manipulate the body using methods of the new MoveDefinition object. You can rotate it, move it along a vector or do a free drag by specifying the xyz offset.
New 2013 Object & Methods:
MoveFeatures.CreateMoveDefinition Method
MoveDefinition Object
- AddRotateAboutAxis
- AddMoveAlongRay
- AddFreeDrag
VBA Example:
Keep in mind that we only recommend using VBA for prototyping and learning the API but do not recommend using VBA in production.
To use this example have a part that has a multiple solid bodies. When you run the code select one of the bodies. This screenshot shows a solid body before running the code:
After the procedure is run a Move Body feature has been created. This feature changes the location of the body.
VBA Code:
' Demonstrates using the API to create a
' Move Body feature. You must have a part
' open that contains at least one body.
Public Sub MoveBody()
' Get the active part document.
Dim partDoc As PartDocument
Set partDoc = ThisApplication.ActiveDocument
Dim partDef As PartComponentDefinition
Set partDef = partDoc.ComponentDefinition
' Have the user select a body.
Dim body As SurfaceBody
Set body = ThisApplication.CommandManager.Pick _
(kPartBodyFilter, "Select the body to move.")
If Not body Is Nothing Then
' Create a collection containing the body to move.
Dim bodyCollection As ObjectCollection
Set bodyCollection = ThisApplication. _
TransientObjects.CreateObjectCollection
Call bodyCollection.Add(body)
' Create a move definition.
Dim moveDef As MoveDefinition
Set moveDef = partDef.Features.MoveFeatures _
.CreateMoveDefinition(bodyCollection)
' Define a rotate, move, and free drag.
Call moveDef.AddRotateAboutAxis _
(partDef.WorkAxes.Item(3), True, _
3.14159265358979 / 4)
Call moveDef.AddMoveAlongRay _
(partDef.WorkAxes.Item(1), True, 3)
Call moveDef.AddFreeDrag(0.5, 6, 3)
' Create the move feature.
Dim move As MoveFeature
Set move = partDef.Features.MoveFeatures _
.Add(moveDef)
End If
End Sub