Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So i am stumped here
If I open the part and run this external rule it does exactly what i need it to but if i run the external rule while editing a part through a assembly it doesn't work. If I am editing it through a assembly it will not detect the rule exist already and add another one but with a _1. I know it has something to do with the activedocument part but if i am editing a part within a assembly wouldn't the activedocument be the one i am editing? I don't know, any help would be appreciated
Dim oRuleName As String = "Master_Parts_List" Dim oTxtFileName As String = "C:\_VAULT_WORKSPACE\JOBS\FAB\Ilogic Rules\External Rules\Referenced Rules\Master Parts List Link (REF).txt" Dim oRuleText As String = IO.File.ReadAllText(oTxtFileName) Dim oDoc As Document = ThisApplication.ActiveEditDocument Dim oRuleExists As Boolean = False Dim iLogicAuto = iLogicVb.Automation iLogicAuto.RulesEnabled = True iLogicAuto.RulesOnEventsEnabled = True Dim oRule As iLogicRule Dim TargetRuleName As String = "Master_Parts_List" Dim auto As IiLogicAutomation = iLogicVb.Automation Dim doc As Inventor.Document = ThisApplication.ActiveDocument ' Get the rules Dim ruleCol As System.Collections.IEnumerable = auto.Rules(doc) Dim bRuleExists As Boolean = False ' make sure the rules collection exists If Not ruleCol Is Nothing Then ' string to hold the rule names Dim name As String = "" ' Go through each of the rules For Each rule As iLogicRule In ruleCol ' check the name of the rule If TargetRuleName.ToUpper = rule.Name.ToUpper Then bRuleExists = True Exit For End If Next End If If bRuleExists Then MessageBox.Show("The Master Parts List Rule exists in this file, i will replace it with the most current version", "Rule Exists") iLogicAuto.DeleteRule(oDoc, oRuleName) oRule = iLogicAuto.AddRule(oDoc, oRuleName, "") oRule.Text = oRuleText iLogicVb.DocumentUpdate oDoc.Save Else oRule = iLogicAuto.AddRule(oDoc, oRuleName, "") oRule.Text = oRuleText iLogicVb.DocumentUpdate oDoc.Save End If
Solved! Go to Solution.