04-03-2024
08:34 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
04-03-2024
08:34 PM
here you go, i briefly tested it, it should be working ok. Let me know if you have any issues
Sub main iPropPartNumbers End Sub Sub iPropPartNumbers Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition ''' Sub Asm ' Iterate through all Of the occurrences Dim oOccurrence As ComponentOccurrence For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef) ' Searching through the top level assembly file in order to locate only sub assembly files If oOccurrence.DefinitionDocumentType = kAssemblyDocumentObject Then comp = Component.InventorComponent(oOccurrence.Name) Dim CompStrng As String = oOccurrence.Name ' Split the string using ":" as delimiter and get the first element Dim NewName As String = CompStrng.Split(":")(0) ' Create iprop with PS Value iProperties.Value("Project", "Part Number") = NewName ' Write to component iprops On Error Resume Next iProperties.Value(oOccurrence.Name, "Project", "Part Number") = _ iProperties.Value("Project", "Part Number") Else End If Next ''' Piece Parts ' Iterate through all Of the occurrences For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef) ' Searching through the top level assembly file in order to locate only sub assembly files If oOccurrence.DefinitionDocumentType = kPartDocumentObject Then comp = Component.InventorComponent(oOccurrence.Name) Dim CompStrng As String = oOccurrence.Name ' Split the string using ":" as delimiter and get the first element Dim NewName As String = CompStrng.Split(":")(0) ' Create iprop with PS Value iProperties.Value("Project", "Part Number") = NewName ' Write to component iprops On Error Resume Next iProperties.Value(oOccurrence.Name, "Project", "Part Number") = _ iProperties.Value("Project", "Part Number") Else End If Next End Sub