Hi @haphanthanhtam.work . This rule removes all internal rules in all documents of the assembly. Use it as an external rule.
Sub Main
Dim oDoc As Document = ThisDoc.Document
Dim oAuto As IiLogicAutomation = iLogicVb.Automation
If Not TypeOf oDoc Is AssemblyDocument Then Exit Sub
Dim oAsmDoc As AssemblyDocument = oDoc
oAuto.DeleteAllRules(oAsmDoc)
Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments
Dim oOccs As ComponentOccurrences = oAsmDoc.ComponentDefinition.Occurrences
Dim oPBar As Inventor.ProgressBar = ThisApplication.CreateProgressBar(False, oRefDocs.Count, "Copy ryles...")
Dim i As Integer = 1
oPBar.Message = "Loading..."
Dim oTM As Transaction = ThisApplication.TransactionManager.StartTransaction(oAsmDoc, "RemoveRulesInAllDocs")
For Each oRefDoc As Document In oRefDocs
oPBar.Message = "Remove rules in docs. Progress " & i & " of " & oRefDocs.Count & "."
If oOccs.AllReferencedOccurrences(oRefDoc).Count > 0 Then
If Not oRefDoc.IsModifiable Then Continue For
oAuto.DeleteAllRules(oRefDoc)
oRefDoc.Save()
End If
oPBar.UpdateProgress
i += 1
Next
oPBar.Close()
oTM.End()
End Sub
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
Have you tried just that one line of code yet. There are two built-in methods for deleting all internal iLogic rules. One is limited to just the input document, and will go no deeper.
iLogicVb.Automation.DeleteAllRulesInDocument(oDoc)
The other says essentially the same thing as the button in the ribbon (works on the input document, and if its an assembly, all referenced documents).
iLogicVb.Automation.DeleteAllRules(oDoc)
Wesley Crihfield
(Not an Autodesk Employee)
Thx you're a life saver. Michael
Type a product name