This rule permanently break component derive references.
It can be run from top level assembly.
Procedure:
- detecting document type
- detecting count of component derive references
- breaking all component derive references
Private Sub Main
BreakLinkToFileForAll(ThisDoc.Document)
End Sub
Private Sub BreakLinkToFileForAll(ByVal oDoc As Inventor.Document)
Dim oAssy As Inventor.AssemblyDocument
Dim oComp As Inventor.ComponentOccurrence
Dim oSubDoc As Inventor.Document
If oDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
oAssy = CType(oDoc, AssemblyDocument)
For Each oComp In oAssy.ComponentDefinition.Occurrences
oSubDoc = CType(oComp.Definition.Document, Document)
If oSubDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then
BreakAssemblyReferences(oSubDoc)
BreakPartsReferences(oSubDoc)
End If
If oSubDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
Call BreakLinkToFileForAll(oSubDoc)
End If
Next oComp
End If
End Sub
Sub BreakPartsReferences (ByVal oPartDoc As PartDocument)
If (oPartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count > 0)
For Each oDerivedDoc As DerivedPartComponent In oPartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents
oDerivedDoc.BreakLinkToFile
Next
End If
End Sub
Sub BreakAssemblyReferences (ByVal oPartDoc As PartDocument)
If (oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Count > 0)
For Each oDerivedAssy As DerivedAssemblyComponent In oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents
oDerivedAssy.BreakLinkToFile
Next
End If
End Sub
Žádné komentáře:
Okomentovat