- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm using VBA in Inventor 2010. I want to create a macro that adds 3 fields to a part for LRNGTH, WIDTH and THICKNESS, as well as comments and setting the export to be export out. My program is below and works well. However i would like to end the macro with the parameter dialog box open. What code do i need to do this?
Sub AddBomFields()
'adds LENGTH, WIDTH and THICKNESS user parameters to part
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition
Set oCompDef = oPartDoc.ComponentDefinition
Dim oUserParam As UserParameter
Set oUserParam = oCompDef.Parameters.UserParameters.AddByValue("LENGTH", 0, kInchLengthUnits)
Set oUserParam = oCompDef.Parameters.UserParameters.AddByValue("WIDTH", 0, kInchLengthUnits)
Set oUserParam = oCompDef.Parameters.UserParameters.AddByValue("THICKNESS", 0, kInchLengthUnits)
' Get the Parameters object. Assumes a part or assembly document is active.
Dim oParameters As Parameters
Set oParameters = ThisApplication.ActiveDocument.ComponentDefinition.Parameters
' Get the parameter named "LENGTH".
Dim oLengthParam As Parameter
Set oLengthParam = oParameters.Item("LENGTH")
oLengthParam.Comment = "BOM LENGTH"
oLengthParam.ExposedAsProperty = True
' Get the parameter named "WIDTH".
Dim oWidthParam As Parameter
Set oWidthParam = oParameters.Item("WIDTH")
oWidthParam.Comment = "BOM WIDTH"
oWidthParam.ExposedAsProperty = True
' Get the parameter named "THICKNESS".
Dim oThicknessParam As Parameter
Set oThicknessParam = oParameters.Item("THICKNESS")
oThicknessParam.Comment = "BOM THICKNESS"
oThicknessParam.ExposedAsProperty = True
ThisApplication.ActiveDocument.Update
Dim Msg, Style, Title, Help, Ctxt, Response
Msg = "Length, Width and Thickness parameters added." ' Define message.
Style = vbOKOnly ' Define buttons.
Title = "Parameter Addition Complete" ' Define title.
' Display message.
Response = MsgBox(Msg, Style, Title)
End Sub
Solved! Go to Solution.