- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I did some experimenting. I think part of the problem is that I've changed part names a few times. For example, I have a part named Front Right Joint. That's what the document DisplayName shows. Using this script on it gives different results depending on whether parts are loaded or not, and whether the link is suppressed or not, in 2 ways: 1. Sometimes the RefDoc.DisplayName is Nothing; 2. Sometimes the Descriptor.DisplayName comes back as "Front Right Side Joint", which is a name the part used to have.
So, to summarize, dpc.Name sometimes has the file extension on it, Descriptor.DisplayName sometimes has an old part name in it, and RefDoc is sometimes Nothing. So none of these will reliably identify the DerivedPartComponent I want by DisplayName. I could use string functions to strip off the .ipt, but I want a robust solution and that seems fragile.
SyntaxEditor Code Snippet
Dim dpcs As DerivedPartComponents dpcs = ThisApplication.ActiveDocument.ComponentDefinition.ReferenceComponents.DerivedPartComponents Dim Descriptor As DocumentDescriptor Dim RefDoc As Document Dim s As String Dim i As Integer = 0 For Each dpc As DerivedPartComponent In dpcs i = i + 1 If i > 1 Then s = s & Chr(10) & CHR(10) If dpc Is Nothing Then s = s & Chr(10) & "dpc Is Nothing" Continue For End If s = s & "Dpc.Name=" & dpc.Name Descriptor = dpc.ReferencedDocumentDescriptor If Descriptor Is Nothing Then s = s & Chr(10) & "dpc Is Nothing" Continue For End If s = s & Chr(10) & " Descriptor.DisplayName=" _ & Descriptor.DisplayName RefDoc = Descriptor.ReferencedDocument If RefDoc Is Nothing Then s = s & Chr(10) & "RefDoc Is Nothing" Continue For End If s = s & Chr(10) & " RefDoc.DisplayName=" _ & RefDoc.DisplayName Next MsgBox(s)