Create Document Rule from an External Rule using iLogic

Create Document Rule from an External Rule using iLogic

Anonymous
Not applicable
521 Views
3 Replies
Message 1 of 4

Create Document Rule from an External Rule using iLogic

Anonymous
Not applicable

Hi,

I want to create an External Rule which creates a Document Rule using iLogic. How can I do this?

 

Thanks,

0 Likes
Accepted solutions (1)
522 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Accepted solution
Try this

Dim
_invApp As Inventor.Application = GetObject(, "Inventor.Application") Dim _iLogic As Inventor.ApplicationAddIn = _invApp.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}") Dim oDoc As Document = _invApp.ActiveDocument _iLogic.Automation.AddRule(oDoc, "tempRule","'*PUT CODE FOR RULE HERE*")

-Chancellor
0 Likes
Message 3 of 4

Anonymous
Not applicable

Take "-Chancellor" out though, that is not part of the code 😂

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

This iLogic rule will create the other iLogic rule, without automatically running the new one when its made.

Dim oRuleName As String = ""
Dim oRuleText As String
oRuleText = ""
Dim oDoc As Document = ThisApplication.ActiveEditDocument
Dim oRuleExists As Boolean = False
'Define iLogic AddIn
Dim oiLogicAddin As ApplicationAddIn ' = ThisApplication.ApplicationAddIns.Item("iLogic")
For Each oAppAddin As ApplicationAddIn In ThisApplication.ApplicationAddIns
	If oAppAddin.DisplayName = "iLogic" Then
		oiLogicAddin = oAppAddin
	End If
Next
Dim iLogicAuto = iLogicVb.Automation
Dim oRules As ObjectCollection
oRules = iLogicAuto.Rules(oDoc)

If oRules.Count > 0 Then
	For Each oRule As Object In oRules
		If oRule.Name = oRuleName Then
			oRuleExists = True
		End If
	Next
End If
If oRuleExists = True Then
	Dim oReplaceRule As MsgBoxResult
	oReplaceRule = MsgBox("A Rule called '" & oRuleName & " already exists." & vbNewLine &
	"Do you want to replace it?", MsgBoxStyle.Question, "RULE EXISTS")
	If oReplaceRule = vbYes Then
		iLogicAuto.DeleteRule(oDoc, oRuleName)
		iLogicAuto.AddRule(oDoc, oRuleName, "")
	Else
		MessageBox.Show("Nothing was ", "")
	End If
End If
	
'iLogic.AddRule(oDoc, RuleName, "")
'iLogicVb.Automation.GetRule(ThisDoc.Document, RuleName).Text = RuleText

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes