It might not be easy to check manually if a document and its referenced documents are relying on external iLogic rules or not.
They might be used from “Event Triggers” or called from other rules using the “RunExternalRule” function.
Here is a utility rule that can be used to help with this. The results will be printed in the “iLogic Log” panel.
Imports System.Text.RegularExpressions
Sub Main()
Dim doc As Inventor.Document
doc = ThisDoc.Document
CheckDocument(doc)
For Each doc In doc.AllReferencedDocuments
CheckDocument(doc)
Next
End Sub
Sub CheckDocument(doc As Document)
Logger.Debug("Checking document " + doc.FullDocumentName)
CheckEventTriggers(doc)
CheckRules(doc)
End Sub
' Check if any Event Trigger use an external rule
Sub CheckEventTriggers(doc As Document)
Dim propSets As PropertySets = doc.PropertySets
Dim iLogicPropSet As PropertySet
Try
iLogicPropSet = propSets.Item("{2C540830-0723-455E-A8E2-891722EB4C3E}")
Catch
Exit Sub
End Try
For Each prop As Inventor.Property In iLogicPropSet
If Not prop.Value.StartsWith("file://") Then Continue For
Logger.Debug(prop.Name + " uses " + prop.Value)
Next
End Sub
' Check if any rules try to execute an external rule
Sub CheckRules(doc As Document)
Dim iLogicAuto = iLogicVb.Automation
Dim rules = iLogicAuto.Rules(doc)
If (rules Is Nothing) Then Exit Sub
For Each rule In rules
CheckRuleText(rule.Name, rule.Text)
Next
End Sub
Sub CheckRuleText(ruleName As String, ruleText As String)
' Used https://regexr.com/ to figure out the Regex string
Dim res = Regex.Matches(ruleText, "(RunExternalRules*(s*"")(.+)("")")
Dim externalRules = New List(Of String)
For Each match As Match In res
Try
Dim name = match.Groups(2).Value
If Not externalRules.Contains(name) Then
externalRules.Add(name)
End If
Catch
End Try
Next
If externalRules.Count > 0 Then
Dim str = String.Join(", ", externalRules)
Logger.Debug(ruleName + " uses these external rules: " + str)
End If
End Sub
And the result when running it on my assembly:


Leave a Reply