Executes an Inventor macro. The macro can be external or embedded in the document.
InvObjectMixin
RULE NAME |
DESCRIPTION |
TYPE |
DEFAULTS |
CATEGORY |
FLAGS |
invExecuteMacro |
Fully qualified name of the macro to be executed. For example: |
String |
""
|
Inventor |
Cached Required |
invProjectPath |
Full file path to an external macro file. |
String |
""
|
Inventor |
Cached |
In your kBridge Examples Projects folder open the project called ‘Table_KB_Inventor_Example’.
Expand the CombineParts folder , expand the Models folder, right click ‘CombineParts’ and select ‘Load Model…’.
Reference Location:
"world.combineparts.partsassembly.partsassembly0.myextrudedpart.myextrudedpart0.invmacro.invmacro0"
Link: https://knowledgebridge.engineer/projects
InvMacro was dragged into MyExtrudedPart0 from InventorUtilities. and these values were put into the rules:
invExecuteMacro: |
"thisDocument.changeParam" |
|
|
invProjectPath: |
"" |
You don’t put your Macro or VBA code in the InvMacro design. Instead, you reference (invExecuteMacro) in the code that you created in Inventor. This example code was created in Inventor by opening ExtrudedPart.ipt, clicking on the Tool tab and selecting the VBA Editor.
Expand Autodesk Inventor Professional Objects and click on ‘ThisDocument’. Then write your code in the window on the right and save.
Notice the first part of the string for:
invExecuteMacro: "thisDocument.changeParam"
‘thisDocument’ is required before the name of the subroutine (changeParam) separated by a period.
Sub changeParam()
Dim pd As PartDocument
Set pd = ThisDocument
Dim mup As UserParameter
Set mup = pd.ComponentDefinition.Parameters.UserParameters("height")
mup.Value = mup.Value + 10
End Sub
In the first example below, the ‘invExecuteMacro’ value has been set to an empty set ("").
In the second example the value has been set to "thisDocument.changeParam".