Message 1 of 3
To copy parameters from one to another by clicking in assembly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
By running the rule in assembly, I need to copy selected parameters from one part to another selected in an assembly with the following rule.
It does not copy the expression. I request someone help. Sample files attached.
Public Sub Main() If ThisDoc.Document.DocumentType <> Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then MsgBox("The active document must be an assembly.") Return End If CopyUserParams() oUpdate() End Sub Private Sub CopyUserParams() Dim oOcc1 As ComponentOccurrence oOcc1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select Doc 1") oOcc1_Selected = oOcc1 If oOcc1_Selected Is Nothing Then Exit Sub Dim oDoc1_Selected As Document = oOcc1_Selected.Definition.Document Dim oDoc1_UserParams As UserParameters = oDoc1_Selected.ComponentDefinition.Parameters.UserParameters oDoc1_UserParams = oDoc1_Selected.ComponentDefinition.Parameters.UserParameters Dim oUserParams_oOcc1_Selected As New ArrayList For Each oListParams_oOcc1 In oDoc1_UserParams 'MessageBox.Show("oListParams_oOcc1: " & oListParams_oOcc1.Name, "Title") If oListParams_oOcc1.Name.Contains("Stairs") Then oUserParams_oOcc1_Selected.Add(oListParams_oOcc1.Name) End If Next oListParams_oOcc1 Dim oOcc2 As ComponentOccurrence oOcc2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select Doc 2") oOcc2_Selected = oOcc2 If oOcc2_Selected Is Nothing Then Exit Sub Dim oDoc2_Selected As Document = oOcc2_Selected.Definition.Document Dim oDoc2_UserParams As UserParameters = oDoc2_Selected.ComponentDefinition.Parameters.UserParameters oDoc2_UserParams = oDoc2_Selected.ComponentDefinition.Parameters.UserParameters ' Add the assembly parameters to the part. ' For Each oUserParam_oOcc1 As UserParameter In oDoc1_UserParams 'asmDoc.ComponentDefinition.Parameters.UserParameters For Each oUserParam_oOcc1_Selected In oUserParams_oOcc1_Selected 'asmDoc.ComponentDefinition.Parameters.UserParameters oAvail = "No" For Each oUserParam_oOcc2 As UserParameter In oDoc2_UserParams 'MessageBox.Show("oUserParam_oOcc2.Name): " & oUserParam_oOcc2.Name, "Title") If oUserParam_oOcc2.Name = oUserParam_oOcc1_Selected Then oAvail = "Yes" Exit For Else End If Next oUserParam_oOcc2 If oAvail = "No" Then MessageBox.Show("@ No" _ & vbLf & "oName: " & oUserParam_oOcc1_Selected _ & vbLf & "oExpression: " & oDoc1_UserParams.Item(oUserParam_oOcc1_Selected).Expression _ & vbLf & "Units: " & oDoc1_UserParams.Item(oUserParam_oOcc1_Selected).Units, "Title") oName = oUserParam_oOcc1_Selected oExpression = oDoc1_UserParams.Item(oUserParam_oOcc1_Selected).Expression oUnits = oDoc1_UserParams.Item(oUserParam_oOcc1_Selected).Units oDoc2_UserParams.AddByExpression(oName, oExpression, oUnits) Else If oAvail = "Yes" Then MessageBox.Show("@ YES: " & oUserParam_oOcc1_Selected, "Title") oDoc2_UserParams.Item(oUserParam_oOcc1_Selected).Expression = oDoc1_UserParams.Item(oUserParam_oOcc1_Selected).Expression End If Next oUserParam_oOcc1_Selected End Sub Sub oUpdate() End Sub