Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Delete Suppressed parts

Anonymous

Delete Suppressed parts

Anonymous
Not applicable

All,

 

I am looking into deleting suppressed parts within my model. The issue i am having now is that i want to delete all suppressed parts some are within a pattern while others aren't. Is there a way to do this??

0 Likes
Reply
573 Views
5 Replies
Replies (5)

wmgshurik
Enthusiast
Enthusiast

 

 Inventor.AssemblyDocument oDoc = invApp.ActiveDocument as Inventor.AssemblyDocument;

 

ComponentOccurences oCompOccs =  oDoc.ComponentDefinition.Occurrences;

foreach(ComponentOccurence localCompOcc in oCompOccs)

 

{  

   if (localCompOcc.supressed)    

    {    

      localCompOcc.delete();  

     }

}

 

0 Likes

Anonymous
Not applicable

I am using strictly iLogic code, So looking at this it seems to be VB?? or not complete i have errors in every line 😞

0 Likes

Anonymous
Not applicable

Ive tried both of these codes:

 

SyntaxEditor Code Snippet

 Dim oAsmDoc As AssemblyDocument = ThisDoc.Document
Dim oAsmDef As AssemblyComponentDefinition _
= oAsmDoc.ComponentDefinition
RunAgain:
oAsmDoc.Update
Dim oOccs As ComponentOccurrences = oAsmDef.Occurrences
For Each oOcc As ComponentOccurrence In oOccs
If oOcc.Suppressed Then
If oOcc.IsPatternElement Then
Dim oPattern As RectangularOccurrencePattern _
= oOcc.PatternElement.Parent
oPattern.Delete
Goto RunAgain
End If
End If
Next

 

 

SyntaxEditor Code Snippet

    Dim oComp As ComponentOccurrence
    Dim oComps As ComponentOccurrences
    
    oComps = ThisDoc.Document.ComponentDefinition.Occurrences
    
    For Each oComp In oComps
        If Component.IsActive(oComp.Name) = False Then oComp.Delete
    Next

 

0 Likes

wmgshurik
Enthusiast
Enthusiast

I dont know ilogic and VB, sorry. I hope, somebody translate C# to VB

0 Likes

wmgshurik
Enthusiast
Enthusiast



 

 Public Sub AssemblyTraversal()

Dim oAsmDoc As AssemblyDocument

Set oAsmDoc = ThisApplication.ActiveDocument

 

Call TraverseAsm(oAsmDoc.ComponentDefinition.Occurrences,1)

 

 End Sub

 

Private Sub TraverseAsm(oOccurrences As ComponentOccurrences, Level As Integer)

 

Dim oOcc As ComponentOccurrence

 

For Each oOcc In oOccurrences
//here IF condition and CALL oOcc.delete

 

If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then Call TraverseAsm(oOcc.SubOccurrences, Level + 1)

End If

Next

End Sub

0 Likes