- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Currently I'm using a code of iLogic I found to populate my parameters from the parent assembly to it's child components
Public Sub Main()
CopyUserParams()
End Sub
Private Sub CopyUserParams()
If ThisDoc.Document.DocumentType <> Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("The active document must be an assembly.")
Return
End If
Dim asmDoc As Inventor.AssemblyDocument = ThisDoc.Document
For Each refDoc As Inventor.Document In asmDoc.AllReferencedDocuments
' Look for part documents.
If refDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then
Dim partDoc As Inventor.PartDocument = refDoc
Dim refDocUserParams As UserParameters = partDoc.ComponentDefinition.Parameters.UserParameters
' Add the assembly parameters to the part.
For Each asmUserParam As UserParameter In asmDoc.ComponentDefinition.Parameters.UserParameters
' Check to see if the parameter already exists.
Dim checkParam As UserParameter = Nothing
Try
checkParam = refDocUserParams.Item(asmUserParam.Name)
Catch ex As Exception
checkParam = Nothing
End Try
If checkParam Is Nothing Then
' Create the missing parameter.
refDocUserParams.AddByExpression(asmUserParam.Name, asmUserParam.Expression, asmUserParam.Units)
Else
' Update the value of the existing parameter.
checkParam.Expression = asmUserParam.Expression
End If
Next
End If
Next
iLogicVb.UpdateWhenDone = True
End Sub
The issue is that this code only spreads the parameters to it's child components (the ".ipt"s) but it doesn't spread the parameters to it's child assemblies (the ".iam"s don't receive the parameters). So, my question is; how can I modify this code so it populates the parameters to all it's child elements both the sub-asseblies and the child components?
Thanks for reading!
Solved! Go to Solution.