- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I'm just trying to have the Assembly Tree in the format of (Part Number)(Part Description) for all parts and subassemblies in the assembly so I can more easily find parts when working in large assemblies.
I've tried using the below code (Best one so far) but they all have the same problem of: working when it is run manually but any attempt at using triggers (such as when opening assembly) results in an error message per part saying it cannot find parts but when you close all errors it has actually done what it was meant to do.
Obviously it is good that it works at all but when I am opening Assemblies with 50+ parts/subassemblies, shutting all the error messages is not optimal.
(A side note if anyone can also get it working for Weldment Assemblies as it errors out saying you cannot convert from string ':1' to type 'Double' would be helpful)
(Says Line 109 due to other formula above which have been commented out. Error occurs on the first line beginning with oPn=iProperties.Value)
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument Dim oOcc As ComponentOccurrence i = 1 For Each oOcc In oDoc.ComponentDefinition.Occurrences.AllLeafOccurrences oSplit = Split(oOcc.Name, ":") oInstance = ":" & oSplit(UBound(oSplit)) oPn = iProperties.Value(oOcc.Name, "Project", "Part Number") oDn = iProperties.Value(oOcc.Name, "Project", "Description") Try oOcc.Name = oPn & " (" & oDn & ")" & oInstance Catch oOcc.Name = oPn & " (" & oDn & ")" & oInstance + i End Try i = i + 1 Next For Each oOcc In oDoc.ComponentDefinition.Occurrences i = 1 If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then oSplit = Split(oOcc.Name, ":") oInstance = ":" & oSplit(UBound(oSplit)) oPn = iProperties.Value(oOcc.Name, "Project", "Part Number") oDn = iProperties.Value(oOcc.Name, "Project", "Description") Try oOcc.Name = oPn & " (" & oDn & ")" & oInstance Catch oOcc.Name = oPn & " (" & oDn & ")" & oInstance + i End Try i = i + 1 End If Next
Solved! Go to Solution.