- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Derived Component names
Is there a way to change the names of the parts in the browser of a derived part? Randomly, some of them have gotten .ipt on the end of them, like filenames, but not all of them. This messes me up when I try to look up a derived component in code. For example, this code:
SyntaxEditor Code Snippet
Dim dpcs As DerivedPartComponents dpcs = ThisApplication.ActiveDocument.ComponentDefinition.ReferenceComponents.DerivedPartComponents 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) s = s & dpc.Name Next MsgBox(s)
Produces the results in the attached screen shot: some of the parts have .ipt extensions, and some don't. Nothing I've tried has enabled me to change the names. The Name property of DerivedPartComponents is read-only, too.
Any suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
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 !
- 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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I was able to work around this by comparing Document.FullFileName to ReferencedDocumentDescriptor.FullDocumentName.
I wasn't sure if I should have used Document.FullDocumentName instead, because the property names would be the same. But going by the documentation, the descriptions of these two were the same and the descriptions of the ones with the same property names were oddly not the same. But all 3 seemed to produce the same string for me.
I'm not entirely satisfied this workaround won't break under some circumstances, though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I was right. It broke.
ReferencedDocumentDescriptor.FullDocumentName gave an old filespec with a different directory on one of the parts.
It seems like ReferencedDocumentDescriptor properties don't ever update themselves; then when a link is suppressed, they dredge up ancient history instead of the last known values. This is really unhelpful.
If I have a suppressed derivation to a part, I need to be able to reliably find the correct DerivedPartComponent for it. Otherwise how can I un-suppress it in code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Please don't say "re-derive the part". With the stuff that's built on it, that would be hellish. I'd have to recreate the whole project from scratch - something I've already had to do a dozen times or more. That's one of the worst things about Inventor.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Current workaround now is to compare these two:
System.IO.Path.GetFileNameWithoutExtension(Document.FullFileName)
System.IO.Path.GetFileNameWithoutExtension(DerivedPartComponent.ReferencedDocumentDescriptor.FullDocumentName)