I came here trying to solve a similar problem. We have files with triggers linked to rules that no longer exist. The popup errors are annoying and rather than turn off triggers (a valid option) I decided to build a tool to help strip those triggers from the files. Here is the code I made which might help get someone else working as well.
This rule will run from a part or assembly, and process all referenced documents within (for an assembly) removing any and all triggers in every document that contains the "SEARCH TEXT" in the original rule path/name
You'll need to modify the "SEARCH TEXT" - near the end of the program - to locate the specific rule to remove. You could modify it to locate more than one rule, or to remove only specific types of triggers, but this should get you a start, if you were looking to do something similar
Class ThisRule
Dim iLogicAuto As Object
Sub Main()
iLogicAuto = iLogicVb.Automation
Dim doc As Document = ThisApplication.ActiveDocument
Select Case doc.DocumentType
Case DocumentTypeEnum.kAssemblyDocumentObject
Dim aDoc As AssemblyDocument = doc
ProcessAssembly(aDoc)
Case DocumentTypeEnum.kPartDocumentObject
RemoveTriggers(doc)
Case Else
Exit Sub
End Select
End Sub
Sub ProcessAssembly(aDoc As AssemblyDocument)
RemoveTriggers(aDoc)
For Each subDoc As Document In aDoc.ReferencedDocuments
Select Case subDoc.DocumentType
Case DocumentTypeEnum.kAssemblyDocumentObject
ProcessAssembly(subDoc)
Case DocumentTypeEnum.kPartDocumentObject
RemoveTriggers(subDoc)
Case Else
Exit Sub
End Select
Next
End Sub
Sub RemoveTriggers(oDoc As Document)
Dim rules = iLogicAuto.Rules(oDoc)
Dim iLogicPropSet As PropertySet
Try
iLogicPropSet = oDoc.PropertySets.Item("{2C540830-0723-455E-A8E2-891722EB4C3E}")
Catch
Exit Sub
End Try
Logger.Debug(System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName))
For i = iLogicPropSet.Count() To 1 Step -1
Dim prop As Inventor.Property = iLogicPropSet.Item(i)
Logger.Debug(String.Format(" {0} ({1}...{2})", prop.DisplayName, Left(prop.Expression, 20), Right(prop.Expression, 20) ) )
If (prop.Expression).contains("SEARCH TEXT")
Logger.Debug(" ** DELETE TRIGGER**")
iLogicPropSet.Item(i).Delete
End If
Next
End Sub
End Class
Best of Luck
---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.