Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Stop derive solids from basepart

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
marius.andersen3RVB4
210 Views, 2 Replies

Stop derive solids from basepart

Hi
I have an assembly with sub asse,bly structures.
In all total 2500 part files.
All part files is now derived from basepart.
I want to stop derive for all solids in all files.

This can be done manually by opening part, right click on solid, chose recovery and afeter some nexts chose stop derive.

Code have to iterate through all solids in all parts.

I have no clue for where to start, but this is way to time-consuming to do manually

Someone that can help?

It would be great if code can be run both in .ipt and .iam.
In .iam working from active .iam document and downwards in structure

Br
Marius A

2 REPLIES 2
Message 2 of 3

This code breaks all links for each derived components in active document and all referenced documents.

Perhaps it is good starting point for you

Sub Main()
    Dim activeDoc As Document = ThisDoc.Document

    If activeDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
        BreakLinkForDerivedComponent(activeDoc)
        Return
    End If

    For Each refDoc As Document In activeDoc.AllReferencedDocuments

        If refDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
            Continue For
        End If

        If refDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
            BreakLinkForDerivedComponent(refDoc)
            Continue For
        End If

        Logger.Warn("Strange document " & refDoc.DisplayName)
    Next
End Sub

Sub BreakLinkForDerivedComponent(part As PartDocument)

    For Each derivedPartComp As DerivedPartComponent In part.ComponentDefinition.ReferenceComponents.DerivedPartComponents
        derivedPartComp.BreakLinkToFile()
    Next

    For Each derivedAsmComp As DerivedPartComponent In part.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents
        derivedAsmComp.BreakLinkToFile()
    Next

    'Another possibilities but usually not used
    'part.ComponentDefinition.ReferenceComponents.DerivedAliasComponents
    'part.ComponentDefinition.ReferenceComponents.DerivedFutureAssemblyComponents
    'part.ComponentDefinition.ReferenceComponents.DerivedFuturePartComponents

End Sub
Message 3 of 3

Thanks.
This is a perfect solution for my issue.

Br
Marius A

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report