- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have a need to update all of the parameters in all of my sub assemblies as long as they have matching names. (For example, if the main assembly has a user parameter called "parameter1" any sub assemblies or parts that also have a user parameter called parameter1 should be updated) These sub assemblies may change, but I still want to have everything updated . I can update all my parts with the code below, but my assembly section of my code doesn't function as I am expecting. I feel like it should be updating based on my current knowledge, but I will admit that I am not iLogic Fluent. I have highlighted the area that isn't working. I feel like I should be able to get it to work with only one if loop, but I've gotten stuck.
TIA for any assistance.
Public Sub Main()
CopyUserParams()
iLogicVb.UpdateWhenDone = True
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 'do nothing
Else
' Update the value of the existing parameter.
checkParam.Expression = asmUserParam.Expression
End If
Next
Else If refDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
Dim partdoc As Inventor.AssemblyDocument = refDoc
Dim refDocUserParams As UserParameters = asmDoc.ComponentDefinition.Parameters.UserParameters
' Add the top level parameters to the assembly.
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 'do nothing
Else
' Update the value of the existing parameter.
checkParam.Expression = asmUserParam.Expression
End If
Next
End If
Next
End Sub
Solved! Go to Solution.