Thanks,
the idea is good, but it doen't work for parts in a sub assembly
i've found simialar code, if i create a new rule and paste this code, the code works. it delete also the parts in the sub assembly
Sub Main()
Dim doc As AssemblyDocument
doc = ThisApplication.ActiveDocument
Dim acd As AssemblyComponentDefinition
acd = doc.ComponentDefinition
Call DeleteSuppressedComponent(acd.Occurrences)
' MessageBox.Show("Message", "Title")
End Sub
Sub DeleteSuppressedComponent(occs As ComponentOccurrences)
Dim occ As ComponentOccurrence
For Each occ In occs
If occ.Suppressed Then
occ.Delete
Else
Call DeleteSuppressedComponent(occ.SubOccurrences)
End If
Next
End Subat this point i'll add the rule to the main code :
Sub main
If RunRule = True Then
Dim oTopAsmDoc As AssemblyDocument
Try
oTopAsmDoc = ThisApplication.ActiveDocument
oTopAsmDoc.Save
Catch
MessageBox.Show("only assembly", "only assembly")
Exit Sub
End Try
iLogicVb.RunRule("delete parts")
' other functions
'' CopyComponents(ThisDoc.Path, ThisDoc.Document.DisplayName, "deuren")
'' iLogicVb.RunRule("Layout update")
'....
MessageBox.Show("end", "end code")
End If
RunRule = False
End Sub
'functions ...
the change of the parameter 'runrule', starts a other rule to delete all code and parameters when the main code is finish
If RunRule = False Then
Dim OAsmDoc As AssemblyDocument
OAsmDoc = ThisApplication.ActiveDocument
Dim oAsmDef As ComponentDefinition = OAsmDoc.ComponentDefinition
oAsmDef.RepresentationsManager.LevelOfDetailRepresentations.Item("Master").Activate(True)
oAsmDef.RepresentationsManager.LevelOfDetailRepresentations.Item("configuratie").delete
iLogicVb.Automation.DeleteAllRulesInDocument(OAsmDoc)
'delete parameters...
End Ifnow i thought i was done , but after run the main code, the Suppressed parts in the sub assembly are still there, in the main they're gone....
'ive try to figure out why but i don't find the answer :
- i've delete al the functions so the only code left is the code in this post.
-if i suppress the (last)rule to 'delete code/parameters' and run the main code (with only the funtion 'delete parts'), the code works, the suppressed parts in the sub assembly are gone (ok)
-now i unsuppesses the code to delete the rules (last rule) and run again
the suppressed parts in the sub assembly are not gone ( not ok)
why??