In case the derived part has multiple reference documents, I need to select the desired reference document and then select the required custom iProperties (multiple) from the drop-down list.
By searching in the forum, I managed to crate a rule. It is doing a kind of well except I am not able to select multiple items from the drop down list. Please see below. I believe, I am not capable of writing a code and I would like to request someone help me with a code.
Sample files (Inventor 2019) is provided. Please run the rule in p0003
Step-1: Select the desired reference document
Step-2: Select the desired custom iProperty. Can I select more from this list?
Step-3: Currently, I select the next by hitting YES button to copy another custom iProperty.
Sub main() Dim iL_NO As String = "002DP" Dim iL_Name As String = "Copy Custom Property in Derived Part" Dim iL_FullName As String = "Rule " & iL_NO & ": " & iL_Name Dim openDoc As Document openDoc = ThisDoc.Document If openDoc.DocumentType <> kPartDocumentObject Then MessageBox.Show("This rule is for a part docuent only!", "File Type Mismatch!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Exit Sub End If Dim oRefFile As FileDescriptor Dim oName_DerivedFile As Object Dim oFFN_DerivedParts_Array As New ArrayList Dim oLFN_DerivedParts_Array As New ArrayList Dim oCancel As String = "Cancel" For Each oRefFile In openDoc.File.ReferencedFileDescriptors oName_DerivedFile = oRefFile.FullFileName oFFN_DerivedParts_Array.Add(oName_DerivedFile) If oFFN_DerivedParts_Array.Count = 0 Then MessageBox.Show("NO DERIVED PART(S) FOUND: Exit Sub!", "Title") Exit Sub End If oPosition_LFN_oRefFile = InStrRev(oName_DerivedFile, "\", - 1) oLFN_oRefFile = Right(oName_DerivedFile, Len(oName_DerivedFile) - oPosition_LFN_oRefFile) 'MessageBox.Show("Len(oFFN): " & Len(oFFN) _ '& vbLf & "oPosition_LFN: " & oPosition_LFN _ '& vbLf & "oLFN (Delected ref doc): " & oLFN, "SELECTED DOC") oLFN_DerivedParts_Array.Add(oLFN_oRefFile) Next oLFN_Selected_DerivedPart = InputListBox("Prompt", oLFN_DerivedParts_Array, oLFN_DerivedParts_Array(0), Title := "Title", ListName := "List") oIndex = oLFN_DerivedParts_Array.IndexOf(oLFN_Selected_DerivedPart) oSourceSelected_DerivedPart = oFFN_DerivedParts_Array(oIndex) 'oSourceSelected_DerivedPart = InputListBox("Prompt", oFFN_DerivedParts_Array, oFFN_DerivedParts_Array(0), Title := "Title", ListName := "List") Dim oDoc_CurrDerivedPart As Document oDoc_CurrDerivedPart = ThisApplication.ActiveDocument Dim oDerivedPartSource_Selected As Document oDerivedPartSource_Selected = ThisApplication.Documents.Open(oSourceSelected_DerivedPart, False) ' MessageBox.Show("oDerivedPartSource_Selected: " & oDerivedPartSource_Selected.FullFileName, "Title") Copy_iProperties_Sub(oDerivedPartSource_Selected, oDoc_CurrDerivedPart) ' Skip save oDerivedPartSource_Selected.Close(True) iLogicVb.UpdateWhenDone = True End Sub Sub Copy_iProperties_Sub(ByVal oDerivedPartSource_Selected As Document, ByVal oDoc_CurrDerivedPart As Document) oFFN = oDerivedPartSource_Selected.FullFileName oPosition_LFN = InStrRev(oFFN, "\", - 1) oLFN = Right(oFFN, Len(oFFN) - oPosition_LFN) 'MessageBox.Show("Len(oFFN): " & Len(oFFN) _ '& vbLf & "oPosition_LFN: " & oPosition_LFN _ '& vbLf & "oLFN (Delected ref doc): " & oLFN, "SELECTED DOC") Dim to_PropertySet As PropertySet to_PropertySet = oDoc_CurrDerivedPart.PropertySets.Item("Inventor User Defined Properties") Dim from_PropertySet As PropertySet from_PropertySet = oDerivedPartSource_Selected.PropertySets.Item("Inventor User Defined Properties") ' For Each oCustProp In oCustomPropertySet ' oCustProp.Delete ' Next 'docFile.PropertySets.Item("Inventor User Defined Properties") 'Dim oDerived As Inventor.Document = ThisApplication.ActiveDocument 'If oDerived.ReferencedDocuments.Count = 0 Then Exit Sub Dim oProps_DerivedPart As PropertySet = oDoc_CurrDerivedPart.PropertySets.Item("Inventor User Defined Properties") Dim oProps_SelectedSource As PropertySet = oDerivedPartSource_Selected.PropertySets.Item("Inventor User Defined Properties") Dim oCustProps_Availble_To_Copy As New ArrayList Dim oProList() As String = {"*" } '"CMF_DESGINATION", "OTHER_iPRO"} 'Use "*" to copy all iPros 'Dim oProList() As String = {"Finished_Length_1", "OTHER_iPRO" } For Each oProp_RefDoc As Inventor.Property In oProps_SelectedSource Dim oSkip As Boolean = True For Each oProp_oProList As String In oProList ' MessageBox.Show("oProp_oProList: " & oProp_oProList _ ' & vbLf & "oProp_RefDoc.Name:" & oProp_RefDoc.Name, "Title") If UCase(oProp_oProList) <> UCase(oProp_RefDoc.Name) And oProp_oProList <> "*" Then Continue For oSkip = False Exit For Next ' MessageBox.Show("oSkip: " & oSkip, "Title") If oSkip = True Then Continue For ' MessageBox.Show("iProp found in (Ref. doc): " & oLFN _ ' & vbLf & "oProp_RefDoc.Name: " & oProp_RefDoc.Name, "Title") oCustProps_Availble_To_Copy.Add(oProp_RefDoc.Name) Next L_oProp_Selected: oProp_Selected = InputListBox("Prompt", oCustProps_Availble_To_Copy, oCustProps_Availble_To_Copy(0), Title := "Title", ListName := "List") Dim oDerPro As Inventor.Property Try oDerPro = oProps_DerivedPart(oProp_Selected) Catch oDerPro = oProps_DerivedPart.Add("", oProp_Selected) End Try oDerPro.Value = oProp_Selected oYesNo = MessageBox.Show("Selected custom iProperty:" _ & vbLf & "" & oProp_Selected _ & vblf & "Created. Do you want To Select again ?", " Select AGAIN! ", MessageBoxButtons.YesNo) If oYesNo = vbYes Then GoTo L_oProp_Selected: End Sub
Solved! Go to Solution.
In case the derived part has multiple reference documents, I need to select the desired reference document and then select the required custom iProperties (multiple) from the drop-down list.
By searching in the forum, I managed to crate a rule. It is doing a kind of well except I am not able to select multiple items from the drop down list. Please see below. I believe, I am not capable of writing a code and I would like to request someone help me with a code.
Sample files (Inventor 2019) is provided. Please run the rule in p0003
Step-1: Select the desired reference document
Step-2: Select the desired custom iProperty. Can I select more from this list?
Step-3: Currently, I select the next by hitting YES button to copy another custom iProperty.
Sub main() Dim iL_NO As String = "002DP" Dim iL_Name As String = "Copy Custom Property in Derived Part" Dim iL_FullName As String = "Rule " & iL_NO & ": " & iL_Name Dim openDoc As Document openDoc = ThisDoc.Document If openDoc.DocumentType <> kPartDocumentObject Then MessageBox.Show("This rule is for a part docuent only!", "File Type Mismatch!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Exit Sub End If Dim oRefFile As FileDescriptor Dim oName_DerivedFile As Object Dim oFFN_DerivedParts_Array As New ArrayList Dim oLFN_DerivedParts_Array As New ArrayList Dim oCancel As String = "Cancel" For Each oRefFile In openDoc.File.ReferencedFileDescriptors oName_DerivedFile = oRefFile.FullFileName oFFN_DerivedParts_Array.Add(oName_DerivedFile) If oFFN_DerivedParts_Array.Count = 0 Then MessageBox.Show("NO DERIVED PART(S) FOUND: Exit Sub!", "Title") Exit Sub End If oPosition_LFN_oRefFile = InStrRev(oName_DerivedFile, "\", - 1) oLFN_oRefFile = Right(oName_DerivedFile, Len(oName_DerivedFile) - oPosition_LFN_oRefFile) 'MessageBox.Show("Len(oFFN): " & Len(oFFN) _ '& vbLf & "oPosition_LFN: " & oPosition_LFN _ '& vbLf & "oLFN (Delected ref doc): " & oLFN, "SELECTED DOC") oLFN_DerivedParts_Array.Add(oLFN_oRefFile) Next oLFN_Selected_DerivedPart = InputListBox("Prompt", oLFN_DerivedParts_Array, oLFN_DerivedParts_Array(0), Title := "Title", ListName := "List") oIndex = oLFN_DerivedParts_Array.IndexOf(oLFN_Selected_DerivedPart) oSourceSelected_DerivedPart = oFFN_DerivedParts_Array(oIndex) 'oSourceSelected_DerivedPart = InputListBox("Prompt", oFFN_DerivedParts_Array, oFFN_DerivedParts_Array(0), Title := "Title", ListName := "List") Dim oDoc_CurrDerivedPart As Document oDoc_CurrDerivedPart = ThisApplication.ActiveDocument Dim oDerivedPartSource_Selected As Document oDerivedPartSource_Selected = ThisApplication.Documents.Open(oSourceSelected_DerivedPart, False) ' MessageBox.Show("oDerivedPartSource_Selected: " & oDerivedPartSource_Selected.FullFileName, "Title") Copy_iProperties_Sub(oDerivedPartSource_Selected, oDoc_CurrDerivedPart) ' Skip save oDerivedPartSource_Selected.Close(True) iLogicVb.UpdateWhenDone = True End Sub Sub Copy_iProperties_Sub(ByVal oDerivedPartSource_Selected As Document, ByVal oDoc_CurrDerivedPart As Document) oFFN = oDerivedPartSource_Selected.FullFileName oPosition_LFN = InStrRev(oFFN, "\", - 1) oLFN = Right(oFFN, Len(oFFN) - oPosition_LFN) 'MessageBox.Show("Len(oFFN): " & Len(oFFN) _ '& vbLf & "oPosition_LFN: " & oPosition_LFN _ '& vbLf & "oLFN (Delected ref doc): " & oLFN, "SELECTED DOC") Dim to_PropertySet As PropertySet to_PropertySet = oDoc_CurrDerivedPart.PropertySets.Item("Inventor User Defined Properties") Dim from_PropertySet As PropertySet from_PropertySet = oDerivedPartSource_Selected.PropertySets.Item("Inventor User Defined Properties") ' For Each oCustProp In oCustomPropertySet ' oCustProp.Delete ' Next 'docFile.PropertySets.Item("Inventor User Defined Properties") 'Dim oDerived As Inventor.Document = ThisApplication.ActiveDocument 'If oDerived.ReferencedDocuments.Count = 0 Then Exit Sub Dim oProps_DerivedPart As PropertySet = oDoc_CurrDerivedPart.PropertySets.Item("Inventor User Defined Properties") Dim oProps_SelectedSource As PropertySet = oDerivedPartSource_Selected.PropertySets.Item("Inventor User Defined Properties") Dim oCustProps_Availble_To_Copy As New ArrayList Dim oProList() As String = {"*" } '"CMF_DESGINATION", "OTHER_iPRO"} 'Use "*" to copy all iPros 'Dim oProList() As String = {"Finished_Length_1", "OTHER_iPRO" } For Each oProp_RefDoc As Inventor.Property In oProps_SelectedSource Dim oSkip As Boolean = True For Each oProp_oProList As String In oProList ' MessageBox.Show("oProp_oProList: " & oProp_oProList _ ' & vbLf & "oProp_RefDoc.Name:" & oProp_RefDoc.Name, "Title") If UCase(oProp_oProList) <> UCase(oProp_RefDoc.Name) And oProp_oProList <> "*" Then Continue For oSkip = False Exit For Next ' MessageBox.Show("oSkip: " & oSkip, "Title") If oSkip = True Then Continue For ' MessageBox.Show("iProp found in (Ref. doc): " & oLFN _ ' & vbLf & "oProp_RefDoc.Name: " & oProp_RefDoc.Name, "Title") oCustProps_Availble_To_Copy.Add(oProp_RefDoc.Name) Next L_oProp_Selected: oProp_Selected = InputListBox("Prompt", oCustProps_Availble_To_Copy, oCustProps_Availble_To_Copy(0), Title := "Title", ListName := "List") Dim oDerPro As Inventor.Property Try oDerPro = oProps_DerivedPart(oProp_Selected) Catch oDerPro = oProps_DerivedPart.Add("", oProp_Selected) End Try oDerPro.Value = oProp_Selected oYesNo = MessageBox.Show("Selected custom iProperty:" _ & vbLf & "" & oProp_Selected _ & vblf & "Created. Do you want To Select again ?", " Select AGAIN! ", MessageBoxButtons.YesNo) If oYesNo = vbYes Then GoTo L_oProp_Selected: End Sub
Solved! Go to Solution.
Solved by RoyWickrama_RWEI. Go to Solution.
Please check one of the topics in my signature about derived parts and copy properties. You could vote it!
Regards,
Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Dimension Component! | Partlist Export! | Derive I-properties! | Vault Prompts Via API! | Vault Handbook/Manual!
Drawing Toggle Sheets! | Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Please check one of the topics in my signature about derived parts and copy properties. You could vote it!
Regards,
Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Dimension Component! | Partlist Export! | Derive I-properties! | Vault Prompts Via API! | Vault Handbook/Manual!
Drawing Toggle Sheets! | Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
I revised the rule a little bit: it removes the item selected from the list (diminishing list) so that I don't have to re-selected what I selected already.
L_oProp_Selected: oProp_Selected = InputListBox("Prompt", oCustProps_Availble_To_Copy, oCustProps_Availble_To_Copy(0), Title := "Title", ListName := "List") Dim oDerPro As Inventor.Property Try oDerPro = oProps_DerivedPart(oProp_Selected) Catch oDerPro = oProps_DerivedPart.Add("", oProp_Selected) End Try oDerPro.Value = oProp_Selected oYesNo = MessageBox.Show("Selected custom iProperty:" _ & vbLf & "" & oProp_Selected _ & vbLf & "Created. Do you want To Select again ?", " Select AGAIN! ", MessageBoxButtons.YesNo) If oYesNo = vbYes Then oIndex_X = oCustProps_Availble_To_Copy.IndexOf(oProp_Selected) oCustProps_Availble_To_Copy.Remove(oCustProps_Availble_To_Copy(oIndex_X)) GoTo L_oProp_Selected : End If
I revised the rule a little bit: it removes the item selected from the list (diminishing list) so that I don't have to re-selected what I selected already.
L_oProp_Selected: oProp_Selected = InputListBox("Prompt", oCustProps_Availble_To_Copy, oCustProps_Availble_To_Copy(0), Title := "Title", ListName := "List") Dim oDerPro As Inventor.Property Try oDerPro = oProps_DerivedPart(oProp_Selected) Catch oDerPro = oProps_DerivedPart.Add("", oProp_Selected) End Try oDerPro.Value = oProp_Selected oYesNo = MessageBox.Show("Selected custom iProperty:" _ & vbLf & "" & oProp_Selected _ & vbLf & "Created. Do you want To Select again ?", " Select AGAIN! ", MessageBoxButtons.YesNo) If oYesNo = vbYes Then oIndex_X = oCustProps_Availble_To_Copy.IndexOf(oProp_Selected) oCustProps_Availble_To_Copy.Remove(oCustProps_Availble_To_Copy(oIndex_X)) GoTo L_oProp_Selected : End If
I would vote. Could you provide me with the link.
I would vote. Could you provide me with the link.
https://forums.autodesk.com/t5/inventor-ideas/derived-part-and-assembly-copy-i-properties/idi-p/6349... is the link referred by @bradeneuropeArthur.
Thanks and regards,
https://forums.autodesk.com/t5/inventor-ideas/derived-part-and-assembly-copy-i-properties/idi-p/6349... is the link referred by @bradeneuropeArthur.
Thanks and regards,
Thanks for the reply.
I voted.
Somehow, I got my rule developed and it is fine now:
Sub main() 'https://forums.autodesk.com/t5/inventor-forum/custom-iproperties-carrying-over-to-derived-components/td-p/8414311 'https://forums.autodesk.com/t5/inventor-customization/ilogic-add-custom-property-and-value-to-selected-assembly-parts/td-p/8381018 'https://forums.autodesk.com/t5/inventor-customization/ilogic-arraylist-acting-strange/td-p/3805800 Dim iL_NO As String = "002DP" Dim iL_Name As String = "Copy Custom Property in Derived Part" Dim iL_FullName As String = "Rule " & iL_NO & ": " & iL_Name Dim openDoc As Document openDoc = ThisDoc.Document 'MessageBox.Show("openDoc: " & openDoc.FullFileName, "Title") If openDoc.DocumentType <> kPartDocumentObject Then MessageBox.Show("This rule is for a part docuent only!", "File Type Mismatch!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Exit Sub End If Dim oRefFile As FileDescriptor Dim oName_DerivedFile As Object Dim oFFN_DerivedParts_Array As New ArrayList Dim oLFN_DerivedParts_Array As New ArrayList Dim oCancel As String = "Cancel" For Each oRefFile In openDoc.File.ReferencedFileDescriptors oName_DerivedFile = oRefFile.FullFileName oFFN_DerivedParts_Array.Add(oName_DerivedFile) If oFFN_DerivedParts_Array.Count = 0 Then MessageBox.Show("NO DERIVED PART(S) FOUND: Exit Sub!", "Title") Exit Sub End If oPosition_LFN_oRefFile = InStrRev(oName_DerivedFile, "\", - 1) oLFN_oRefFile = Right(oName_DerivedFile, Len(oName_DerivedFile) - oPosition_LFN_oRefFile) 'MessageBox.Show("Len(oFFN): " & Len(oFFN) _ '& vbLf & "oPosition_LFN: " & oPosition_LFN _ '& vbLf & "oLFN (Delected ref doc): " & oLFN, "SELECTED DOC") oLFN_DerivedParts_Array.Add(oLFN_oRefFile) Next oLFN_Selected_DerivedPart = InputListBox("Prompt", oLFN_DerivedParts_Array, oLFN_DerivedParts_Array(0), Title := "Title", ListName := "List") oIndex = oLFN_DerivedParts_Array.IndexOf(oLFN_Selected_DerivedPart) oSourceSelected_DerivedPart = oFFN_DerivedParts_Array(oIndex) 'oSourceSelected_DerivedPart = InputListBox("Prompt", oFFN_DerivedParts_Array, oFFN_DerivedParts_Array(0), Title := "Title", ListName := "List") Dim oDoc_CurrDerivedPart As Document oDoc_CurrDerivedPart = ThisApplication.ActiveDocument Dim oDerivedPartSource_Selected As Document oDerivedPartSource_Selected = ThisApplication.Documents.Open(oSourceSelected_DerivedPart, False) ' MessageBox.Show("oDerivedPartSource_Selected: " & oDerivedPartSource_Selected.FullFileName, "Title") Copy_iProperties_Sub(oDerivedPartSource_Selected, oDoc_CurrDerivedPart) ' Skip save oDerivedPartSource_Selected.Close(True) iLogicVb.UpdateWhenDone = True End Sub Sub Copy_iProperties_Sub(ByVal oDerivedPartSource_Selected As Document, ByVal oDoc_CurrDerivedPart As Document) oFFN = oDerivedPartSource_Selected.FullFileName oPosition_LFN = InStrRev(oFFN, "\", - 1) oLFN = Right(oFFN, Len(oFFN) - oPosition_LFN) 'MessageBox.Show("Len(oFFN): " & Len(oFFN) _ '& vbLf & "oPosition_LFN: " & oPosition_LFN _ '& vbLf & "oLFN (Delected ref doc): " & oLFN, "SELECTED DOC") Dim to_PropertySet As PropertySet to_PropertySet = oDoc_CurrDerivedPart.PropertySets.Item("Inventor User Defined Properties") Dim from_PropertySet As PropertySet from_PropertySet = oDerivedPartSource_Selected.PropertySets.Item("Inventor User Defined Properties") Dim oProps_DerivedPart As PropertySet = oDoc_CurrDerivedPart.PropertySets.Item("Inventor User Defined Properties") Dim oProps_SelectedSource As PropertySet = oDerivedPartSource_Selected.PropertySets.Item("Inventor User Defined Properties") Dim oCustProps_Availble_To_Copy As New ArrayList Dim oProList() As String = {"*" } '"CMF_DESGINATION", "OTHER_iPRO"} 'Use "*" to copy all iPros 'Dim oProList() As String = {"Finished_Length_1", "OTHER_iPRO" } Dim oProp_RefDoc As Inventor.Property Dim oDerPro As Inventor.Property 'For Each oProp_RefDoc As Inventor.Property In oProps_SelectedSource For Each oProp_RefDoc In oProps_SelectedSource Dim oSkip As Boolean = True For Each oProp_oProList As String In oProList ' MessageBox.Show("oProp_oProList: " & oProp_oProList _ ' & vbLf & "oProp_RefDoc.Name:" & oProp_RefDoc.Name _ ' & vbLf & "oProp_RefDoc.Name: " & oProp_RefDoc.Value, "Title") If UCase(oProp_oProList) <> UCase(oProp_RefDoc.Name) And oProp_oProList <> "*" Then Continue For oSkip = False Exit For Next ' MessageBox.Show("oSkip: " & oSkip, "Title") If oSkip = True Then Continue For ' MessageBox.Show("iProp found in (Ref. doc): " & oLFN _ ' & vbLf & "oProp_RefDoc.Name: " & oProp_RefDoc.Name, "Title") oCustProps_Availble_To_Copy.Add(oProp_RefDoc.Name) Next Dim oList_NeedToDo As New ArrayList oCopyAll = "Copy all from Reference Document" oCopySelected = "Copy Only Selected" oList_NeedToDo.Add(oCopyAll) oList_NeedToDo.Add(oCopySelected) oInput_NeedToDo = InputListBox("Prompt", oList_NeedToDo, oList_NeedToDo(1), Title := "Title", ListName := "List") If oInput_NeedToDo = oCopySelected Then L_oProp_Selected: oProp_Selected = InputListBox("Prompt", oCustProps_Availble_To_Copy, oCustProps_Availble_To_Copy(0), Title := "Title", ListName := "List") ' Dim oDerPro As Inventor.Property Try oDerPro = oProps_DerivedPart(oProp_Selected) Catch oDerPro = oProps_DerivedPart.Add("", oProp_Selected) End Try oDerPro.Value = oProp_RefDoc.Value 'oProp_Selected.Value oYesNo = MessageBox.Show("Selected custom iProperty:" _ & vbLf & "" & oProp_Selected _ & vbLf & "Created. Do you want To Select again ?", " Select AGAIN! ", MessageBoxButtons.YesNo) If oYesNo = vbYes Then oIndex_X = oCustProps_Availble_To_Copy.IndexOf(oProp_Selected) oCustProps_Availble_To_Copy.Remove(oCustProps_Availble_To_Copy(oIndex_X)) GoTo L_oProp_Selected : End If Else If oInput_NeedToDo = oCopyAll Then For Each oProp_RefDoc In oProps_SelectedSource Try oDerPro = oProps_DerivedPart(oProp_RefDoc.Name) Catch oDerPro = oProps_DerivedPart.Add("", oProp_RefDoc.Name) End Try oDerPro.Value = oProp_RefDoc.Value Next oProp_RefDoc End If End Sub
Thanks for the reply.
I voted.
Somehow, I got my rule developed and it is fine now:
Sub main() 'https://forums.autodesk.com/t5/inventor-forum/custom-iproperties-carrying-over-to-derived-components/td-p/8414311 'https://forums.autodesk.com/t5/inventor-customization/ilogic-add-custom-property-and-value-to-selected-assembly-parts/td-p/8381018 'https://forums.autodesk.com/t5/inventor-customization/ilogic-arraylist-acting-strange/td-p/3805800 Dim iL_NO As String = "002DP" Dim iL_Name As String = "Copy Custom Property in Derived Part" Dim iL_FullName As String = "Rule " & iL_NO & ": " & iL_Name Dim openDoc As Document openDoc = ThisDoc.Document 'MessageBox.Show("openDoc: " & openDoc.FullFileName, "Title") If openDoc.DocumentType <> kPartDocumentObject Then MessageBox.Show("This rule is for a part docuent only!", "File Type Mismatch!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Exit Sub End If Dim oRefFile As FileDescriptor Dim oName_DerivedFile As Object Dim oFFN_DerivedParts_Array As New ArrayList Dim oLFN_DerivedParts_Array As New ArrayList Dim oCancel As String = "Cancel" For Each oRefFile In openDoc.File.ReferencedFileDescriptors oName_DerivedFile = oRefFile.FullFileName oFFN_DerivedParts_Array.Add(oName_DerivedFile) If oFFN_DerivedParts_Array.Count = 0 Then MessageBox.Show("NO DERIVED PART(S) FOUND: Exit Sub!", "Title") Exit Sub End If oPosition_LFN_oRefFile = InStrRev(oName_DerivedFile, "\", - 1) oLFN_oRefFile = Right(oName_DerivedFile, Len(oName_DerivedFile) - oPosition_LFN_oRefFile) 'MessageBox.Show("Len(oFFN): " & Len(oFFN) _ '& vbLf & "oPosition_LFN: " & oPosition_LFN _ '& vbLf & "oLFN (Delected ref doc): " & oLFN, "SELECTED DOC") oLFN_DerivedParts_Array.Add(oLFN_oRefFile) Next oLFN_Selected_DerivedPart = InputListBox("Prompt", oLFN_DerivedParts_Array, oLFN_DerivedParts_Array(0), Title := "Title", ListName := "List") oIndex = oLFN_DerivedParts_Array.IndexOf(oLFN_Selected_DerivedPart) oSourceSelected_DerivedPart = oFFN_DerivedParts_Array(oIndex) 'oSourceSelected_DerivedPart = InputListBox("Prompt", oFFN_DerivedParts_Array, oFFN_DerivedParts_Array(0), Title := "Title", ListName := "List") Dim oDoc_CurrDerivedPart As Document oDoc_CurrDerivedPart = ThisApplication.ActiveDocument Dim oDerivedPartSource_Selected As Document oDerivedPartSource_Selected = ThisApplication.Documents.Open(oSourceSelected_DerivedPart, False) ' MessageBox.Show("oDerivedPartSource_Selected: " & oDerivedPartSource_Selected.FullFileName, "Title") Copy_iProperties_Sub(oDerivedPartSource_Selected, oDoc_CurrDerivedPart) ' Skip save oDerivedPartSource_Selected.Close(True) iLogicVb.UpdateWhenDone = True End Sub Sub Copy_iProperties_Sub(ByVal oDerivedPartSource_Selected As Document, ByVal oDoc_CurrDerivedPart As Document) oFFN = oDerivedPartSource_Selected.FullFileName oPosition_LFN = InStrRev(oFFN, "\", - 1) oLFN = Right(oFFN, Len(oFFN) - oPosition_LFN) 'MessageBox.Show("Len(oFFN): " & Len(oFFN) _ '& vbLf & "oPosition_LFN: " & oPosition_LFN _ '& vbLf & "oLFN (Delected ref doc): " & oLFN, "SELECTED DOC") Dim to_PropertySet As PropertySet to_PropertySet = oDoc_CurrDerivedPart.PropertySets.Item("Inventor User Defined Properties") Dim from_PropertySet As PropertySet from_PropertySet = oDerivedPartSource_Selected.PropertySets.Item("Inventor User Defined Properties") Dim oProps_DerivedPart As PropertySet = oDoc_CurrDerivedPart.PropertySets.Item("Inventor User Defined Properties") Dim oProps_SelectedSource As PropertySet = oDerivedPartSource_Selected.PropertySets.Item("Inventor User Defined Properties") Dim oCustProps_Availble_To_Copy As New ArrayList Dim oProList() As String = {"*" } '"CMF_DESGINATION", "OTHER_iPRO"} 'Use "*" to copy all iPros 'Dim oProList() As String = {"Finished_Length_1", "OTHER_iPRO" } Dim oProp_RefDoc As Inventor.Property Dim oDerPro As Inventor.Property 'For Each oProp_RefDoc As Inventor.Property In oProps_SelectedSource For Each oProp_RefDoc In oProps_SelectedSource Dim oSkip As Boolean = True For Each oProp_oProList As String In oProList ' MessageBox.Show("oProp_oProList: " & oProp_oProList _ ' & vbLf & "oProp_RefDoc.Name:" & oProp_RefDoc.Name _ ' & vbLf & "oProp_RefDoc.Name: " & oProp_RefDoc.Value, "Title") If UCase(oProp_oProList) <> UCase(oProp_RefDoc.Name) And oProp_oProList <> "*" Then Continue For oSkip = False Exit For Next ' MessageBox.Show("oSkip: " & oSkip, "Title") If oSkip = True Then Continue For ' MessageBox.Show("iProp found in (Ref. doc): " & oLFN _ ' & vbLf & "oProp_RefDoc.Name: " & oProp_RefDoc.Name, "Title") oCustProps_Availble_To_Copy.Add(oProp_RefDoc.Name) Next Dim oList_NeedToDo As New ArrayList oCopyAll = "Copy all from Reference Document" oCopySelected = "Copy Only Selected" oList_NeedToDo.Add(oCopyAll) oList_NeedToDo.Add(oCopySelected) oInput_NeedToDo = InputListBox("Prompt", oList_NeedToDo, oList_NeedToDo(1), Title := "Title", ListName := "List") If oInput_NeedToDo = oCopySelected Then L_oProp_Selected: oProp_Selected = InputListBox("Prompt", oCustProps_Availble_To_Copy, oCustProps_Availble_To_Copy(0), Title := "Title", ListName := "List") ' Dim oDerPro As Inventor.Property Try oDerPro = oProps_DerivedPart(oProp_Selected) Catch oDerPro = oProps_DerivedPart.Add("", oProp_Selected) End Try oDerPro.Value = oProp_RefDoc.Value 'oProp_Selected.Value oYesNo = MessageBox.Show("Selected custom iProperty:" _ & vbLf & "" & oProp_Selected _ & vbLf & "Created. Do you want To Select again ?", " Select AGAIN! ", MessageBoxButtons.YesNo) If oYesNo = vbYes Then oIndex_X = oCustProps_Availble_To_Copy.IndexOf(oProp_Selected) oCustProps_Availble_To_Copy.Remove(oCustProps_Availble_To_Copy(oIndex_X)) GoTo L_oProp_Selected : End If Else If oInput_NeedToDo = oCopyAll Then For Each oProp_RefDoc In oProps_SelectedSource Try oDerPro = oProps_DerivedPart(oProp_RefDoc.Name) Catch oDerPro = oProps_DerivedPart.Add("", oProp_RefDoc.Name) End Try oDerPro.Value = oProp_RefDoc.Value Next oProp_RefDoc End If End Sub
The rule is attached.
The rule is attached.
Hi.
Great piece of code. Works like a charm. I just did a test and it also works for Inventor Summary Information and Inventor Document Summary Information but not for Design Tracking Properties.
It crashes on Catalog Web Link, Part Icon and Template Row. Is there a possibility to add some iProperties to an Exclude List so that it doesn't show up in the List To Select at all?
Hi.
Great piece of code. Works like a charm. I just did a test and it also works for Inventor Summary Information and Inventor Document Summary Information but not for Design Tracking Properties.
It crashes on Catalog Web Link, Part Icon and Template Row. Is there a possibility to add some iProperties to an Exclude List so that it doesn't show up in the List To Select at all?
Thanks for the comment. My need was to extract some custom iProperties from the reference document. Could be expanded to copy all iProperties. I will update (but I am busy for a few days, currently)
Thanks for the comment. My need was to extract some custom iProperties from the reference document. Could be expanded to copy all iProperties. I will update (but I am busy for a few days, currently)
Can't find what you're looking for? Ask the community or share your knowledge.