Need ilogic code to continue method from rule opened file

Need ilogic code to continue method from rule opened file

jeremiah_boe
Contributor Contributor
613 Views
2 Replies
Message 1 of 3

Need ilogic code to continue method from rule opened file

jeremiah_boe
Contributor
Contributor

I am trying to create a rule to update all of the prior templates to the new logic capabilities but have run into a snag. I am attempting to run a rule that opens a new document, which then in turn executes an external rule within the newly opened document. I have gotten the to the point where I can open the file, but not execute the run external rule from the new opened document.

iLogicVb.RunExternalRule("Delete All Rules")
iLogicVb.RunExternalRule("Add Local Rule")

oPartDoc = ThisDoc.Document.documenttype=Inventor.DocumentTypeEnum.kPartDocumentObject
oAssyDoc = ThisDoc.Document.documenttype=Inventor.DocumentTypeEnum.kAssemblyDocumentObject
oDrawDoc = ThisDoc.Document.documenttype=Inventor.DocumentTypeEnum.kDrawingDocumentObject
Part_Trigger = "\\Innovation\CAD Styles and Materials\Part Triggers.ipt"
DWG_Trigger = "\\Innovation\CAD Styles and Materials\Drawing Triggers.idw"

If ThisDoc.Document Is ThisApplication.ActiveDocument  And oPartDoc = True Then
ThisApplication.Documents.Open(Part_Trigger)

iLogicVb.RunExternalRule("Set Rule Triggers")
	
ElseIf ThisDoc.Document Is ThisApplication.ActiveDocument  And oAssyDoc = True Then

ElseIf ThisDoc.Document Is ThisApplication.ActiveDocument  And oDrawDoc = True Then
ThisApplication.Documents.Open(DWG_Trigger)

iLogicVb.RunExternalRule("Set Rule Triggers")
	
End If
0 Likes
Accepted solutions (1)
614 Views
2 Replies
Replies (2)
Message 2 of 3

jeremiah_boe
Contributor
Contributor
Accepted solution

I was able to create a local rule in the opening file that ran an external rule to solve this issue. Thanks to Curtis' silent open, run rule, close code; I was able to come up with this:

oPartDoc = ThisDoc.Document.documenttype=Inventor.DocumentTypeEnum.kPartDocumentObject
oAssyDoc = ThisDoc.Document.documenttype=Inventor.DocumentTypeEnum.kAssemblyDocumentObject
oDrawDoc = ThisDoc.Document.documenttype=Inventor.DocumentTypeEnum.kDrawingDocumentObject

iLogicVb.RunExternalRule("Delete All Rules")
iLogicVb.RunExternalRule("Add Local Rule")


If ThisDoc.Document Is ThisApplication.ActiveDocument  And oPartDoc = True Then
'define path and name
Dim sFilePath As String 
sFilePath = "\\Innovation\CAD Styles and Materials\Part Triggers.ipt" 

'name of ilogic rule
Dim oRuleName As String = "Set Rule Triggers" 

'open the file invisibly
oFile =  ThisApplication.Documents.Open(sFilePath, False) 

'define the ilogicAutomation
Dim iLogicAuto As Object 
iLogicAuto = iLogicVb.Automation 

'get the rule
Dim oRule As Object 
oRule = iLogicAuto.GetRule(oFile, oRuleName) 

'run the rule
iLogicAuto.RunRuleDirect(oRule) 

'close the file
oFile.Close 
	
ElseIf ThisDoc.Document Is ThisApplication.ActiveDocument  And oAssyDoc = True Then
'define path and name
Dim sFilePath As String 
sFilePath = "\\Innovation\CAD Styles and Materials\Assy Triggers.iam" 

'name of ilogic rule
Dim oRuleName As String = "Set Rule Triggers" 

'open the file invisibly
oFile =  ThisApplication.Documents.Open(sFilePath, False) 

'define the ilogicAutomation
Dim iLogicAuto As Object 
iLogicAuto = iLogicVb.Automation 

'get the rule
Dim oRule As Object 
oRule = iLogicAuto.GetRule(oFile, oRuleName) 

'run the rule
iLogicAuto.RunRuleDirect(oRule) 

'close the file
oFile.Close 

ElseIf ThisDoc.Document Is ThisApplication.ActiveDocument  And oDrawDoc = True Then
'define path and name
Dim sFilePath As String 
sFilePath = "\\Innovation\CAD Styles and Materials\Drawing Triggers.idw" 

'name of ilogic rule
Dim oRuleName As String = "Set Rule Triggers" 

'open the file invisibly
oFile =  ThisApplication.Documents.Open(sFilePath, False) 

'define the ilogicAutomation
Dim iLogicAuto As Object 
iLogicAuto = iLogicVb.Automation 

'get the rule
Dim oRule As Object 
oRule = iLogicAuto.GetRule(oFile, oRuleName) 

'run the rule
iLogicAuto.RunRuleDirect(oRule) 

'close the file
oFile.Close 
	
End If
0 Likes
Message 3 of 3

chandra.shekar.g
Autodesk Support
Autodesk Support

@jeremiah_boe,

 

Nice to know that issue is solved. For administrative reason, please click on "Accept Solution" on respective post which is solved.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes