Delete unused derived component using iLogic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
Here is what I'm trying to do: I want to be able, using an iLogic rule, to delete the unused derived components in a part. Different "objects" are derived in different derived components. Sometimes it's parameters, blocks or sketches that for some reason are not used anymore in the part modeling. I would like to be able to "clean" the ipt file from these unnecessary links.
I figured out how to delete the derived components using the following code. The problem is that it deletes everything, all the derived components are deleted, even if they are used by something in the ipt file. There is a simple way of doing it manually by right clicking in the browser on the derived component and Inventor will list in the menu the "delete" command only if the component is not in use. I'm unable to find a property somewhere that flags whether or not it is "safe" to delete de derived component.
Any help appreciated!
Thanks!
Dim Doc As PartDocument = ThisDoc.Document Dim DerivedComps As DerivedPartComponents = Doc.ComponentDefinition.ReferenceComponents.DerivedPartComponents For Each DerivedComp As DerivedPartComponent In DerivedComps Try DerivedComp.Delete Catch End Try Next