2016 iLogic Event Triggers are Broken

2016 iLogic Event Triggers are Broken

mrattray
Advisor Advisor
2,686 Views
10 Replies
Message 1 of 11

2016 iLogic Event Triggers are Broken

mrattray
Advisor
Advisor

Something was changed in Inventor 2016 that is interferring with my iLogic event triggers. I create a local rule with one line: run an external rule. This local rule is then added to the event triggers under before document save. This is a fully automated process. The external rule then does a bunch of error checking, sets bend allowances & bend radii, and exports various parameters to iProperties to populate title blocks and parts lists as required by our manufacturing department. Rules should be running automatically but are not. I've been using the same technique for this since version 2012.

I have my whole office complaining about inccorrect BOM's and titleblocks and wasted hours manually opening details and running rules. It's only a matter of a couple days before my saw hand comes in here letting me know how much stock he wasted with inccorect cut lengths. I'm going to take a LOT of heat for this if it doesn't get resolved very quickly.

We're all on Inventor Pro 2016 UD2 build #: 138.

 

Mike (not Matt) Rattray

0 Likes
Accepted solutions (1)
2,687 Views
10 Replies
Replies (10)
Message 2 of 11

mrattray
Advisor
Advisor

I've spent all afternoon debugging this and I think I found the source of the issue. It appears that something has changed with the way that Inventor handles the isDirty property of documents. My code contained some logic checks to prevent documents which haven't changed from being changed unnecessarily. I've commented out these sections and while it is causing Inventor to want to save every single file now, regardless of it's isDirty status, at least my BOM's are coming out right.

I would still like it if an A'Desker (or other knowledgeable individual) could fill us in on what, if anything, has changed in regards to the way Inventor handles the dirtying of documents or the isDirty property.

Mike (not Matt) Rattray

0 Likes
Message 3 of 11

tegstette
Advocate
Advocate
Hi

Did you find out more about this issue?
Best regards
TG

Autodesk Inventor/Vault Professional 2021
0 Likes
Message 4 of 11

mrattray
Advisor
Advisor
All I can tell you is that my document dirtying theory is false. Something changed in the way that event triggers are handled and I can't seem to get even an acknowledgment that my screams aren't falling on deaf ears.
This issue has been my bane since we upgraded to 2016. I probably get complained at a minimum of twice a day about this even though it's six months old.
Perhaps, if you shared some of the details of your specific issue we could work out a solution together?
Mike (not Matt) Rattray

0 Likes
Message 5 of 11

mcgyvr
Consultant
Consultant

Did you submit a trouble ticket ?

 

Could just be an issue specific to your code and hopefully they can sort it out for you..

But I'd be going to trouble ticket route (and maybe posting here too)

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 6 of 11

jalger
Collaborator
Collaborator

Hi Mike,

 

Have you tried going direct to the External rule instead of piggybacking on the Internal rule?

It sounds like its failing the call to run the other rule. (like its timing out)

Do you have "Fire Dependant Rules Imeditately" flagged? ( That should be forcing the rules to run but it seems to favor internal rules)

The other one to check is "Don't Run Automatically" (It will prevent the flag above from working).

 

I work with ilogic (training classes, helping clients build models, etc) I haven't seen many cases where the Event Triggers were not working.

As silly as it sounds try changing the Order you call in the rules, and see if that makes a difference.

 

Not sure if any of that helps, but maybe it will spark more ideas.

 

Regards, 

 

 

James Alger
(I'm on several hundred posts as "algerj")

Work:
Dell Precision 5530 (Xeon E 2176M)
1tb SSD, 64GB RAM
Nvidia Quadro P2000, Win10
0 Likes
Message 7 of 11

mrattray
Advisor
Advisor

I'm using the internal rule as a work around because external rules can't be added to event triggers programaticly. My external rule actually adds the internal rule and adds that to the triggers. I do this so that it's very easy to update legacy or downloaded parts with no manual steps required.

 

I've played around with the flags, but with no results.


@jalger wrote:
As silly as it sounds try changing the Order you call in the rules, and see if that makes a difference.

 


I'm not sure what you mean by that. The internal rule only has one line in it.

 

McGyver: I thought this post had been escalated, but it appears to no longer be. I'll escalate it now. Is there any advantage to a trouble ticket over an escalated post?  *Edit: I thought we can escalate our own posts now, but that appears to not be true since I get an error there, too.*

 

I really didn't do a very good job of describing my specific issue when I posted this (or my understanding of it has evolved). I no longer believe it is the actual event triggers, I believe it has to do with the changes made to the way Inventor handles directories containing external rules. Actually, I know it's not the trigger because I error out even if I manually run the internal rule. The issue really that my internal rule can't seem to call the external one. However, here's the weird part: if I run the external rule once manually everything will work fine for the rest of my session.

 

Capture.PNG

That "Code FIles" directory didn't show up like that previous to 2016. In 2015 all the rules would just be under the "Standard Directories" node. The "sheet metal template 2.0" is the rule I'm having trouble running.

 

Here is the error I get, I'm not really sure in hind sight why I initially blamed the triggers. Maybe, I was frustrated and needed a scape goat.

Capture.PNG

 

 

Mike (not Matt) Rattray

0 Likes
Message 8 of 11

mrattray
Advisor
Advisor
This is still a problem in version 2017.
Mike (not Matt) Rattray

0 Likes
Message 9 of 11

Curtis_Waguespack
Consultant
Consultant

@mrattray wrote:

I'm using the internal rule as a work around because external rules can't be added to event triggers programaticly.

 

 

 


Hi mrattray ,

 

First let me say, I have not followed this thread (I'm still using 2015 in production), so please excuse me for any noise or distraction I might create on the subject.

 

But I wanted to point you to this rule that I use to copy event triggers from my templates. I set up external rules with event triggers in the templates, and then I have this "Copy Event Triggers rule" called from various other external rules as needed. I almost never use internal rules.

 

So maybe the point of this thread is that my workflow won't work with 2016 and 2017, we haven't started that testing yet, but will soon.

 

In any case I thought this rule my be of interest. Keep in mind, I repurposed a rule I found on line, and so there is likely some extra stuff in there that is not needed, etc. I never did go back through it and clean it up.

 

 

Edit: I also just found this:

http://forums.autodesk.com/t5/inventor-general-discussion/inventor-2016-ilogic-and-external-rules-bu...

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Imports System.Collections.Generic
'code taken and modified from:
'http://adndevblog.typepad.com/manufacturing/2015/01/add-external-ilogic-rule-to-event-trigger.html

Sub Main
Trace.WriteLine("Event Driven Rules Copy", "iLogic") 'debug 

	Dim oTemplateDoc As Document
	Dim oTemplate As String 
	
	'check file type 
	If ThisApplication.ActiveEditDocument.DocumentType = kDrawingDocumentObject Then
	'If ThisDoc.Document.DocumentType = kDrawingDocumentObject Then
		oTemplate = "\\server\departments\CAD\Inventor\Templates\Standard.idw"   'file to copy events from
	ElseIf ThisApplication.ActiveEditDocument.DocumentType = kPartDocumentObject Then
	'ElseIf ThisDoc.Document.DocumentType = kPartDocumentObject Then
		oTemplate = "\\server\departments\CAD\Inventor\Templates\Standard.ipt"   'file to copy events from
	Else
		oTemplate = "\\server\departments\CAD\Inventor\Templates\Standard.iam"   'file to copy events from
	End If
	
	'file to copy events to
	oInput =  ThisApplication.ActiveEditDocument.FullFileName 
	If oInput = "" Then 'catch a new file with no path
		Return
	End If	
	
	'open the template
	oTemplateDoc = ThisApplication.Documents.Open(oTemplate, False)
	CopyEventsToDocuments(oTemplateDoc)
	oTemplateDoc.Close 
End Sub

Private Const m_ourGuid As String = "{2C540830-0723-455E-A8E2-891722EB4C3E}"
Private savedEnabled As Boolean
Dim oInput As String

Public Sub CopyEventsToDocuments(ByVal sourceDoc As Document)
	Dim sourcePropSet As PropertySet = GetEventRulesPropertySet(sourceDoc)
	Dim inputs() As String = { oInput} 
	Dim destinationFileNames As List(Of String) = New List(Of String)(inputs)
	If (destinationFileNames Is Nothing) Then Return
	savedEnabled = iLogicVb.Automation.RulesOnEventsEnabled
	iLogicVb.Automation.RulesOnEventsEnabled = False
	Try	
		CopyEventsToAllDocuments(sourcePropSet, sourceDoc, destinationFileNames)
	Finally		
		iLogicVb.Automation.RulesOnEventsEnabled = savedEnabled
	End Try

End Sub

Function GetEventRulesPropertySet(ByVal sourceDoc As Document) As PropertySet
	Try
		Return sourceDoc.PropertySets(m_ourGuid)
	Catch ex As Exception
		Return Nothing
	End Try
End Function

Function VerifyRulesPropertySet(ByVal propSet As PropertySet) As Boolean
	If (propSet Is Nothing) Then Return True
	' See if any rules are internal instead of external.  We can't copy those.
	For Each prop As Inventor.Property In propSet
		Dim strValue As String = prop.Value.ToString
		If (Not strValue.StartsWith("file://")) Then Return False
	Next
	Return True
End Function


Sub CopyEventsToAllDocuments(ByVal sourcePropSet As PropertySet, ByVal sourceDoc As Document, ByVal destinationFileNames As List(Of String))
	For Each fileName As String In destinationFileNames
		If (String.Equals(sourceDoc.FullFileName, fileName)) Then Continue For
		CopyEventsToDocument(sourcePropSet, fileName)
	Next
End Sub

Sub CopyEventsToDocument(ByVal sourcePropSet As PropertySet, ByVal fileName As String)
	'Dim doc As Document = FindOpenDocument(fileName)

	Dim openedHere As Boolean = False

	If (doc Is Nothing) Then
		doc = ThisApplication.Documents.Open(fileName, True)
		openedHere = True
	End If
		
	CopyEventsPropertySetToDocument(sourcePropSet, doc)
	iLogicVb.Automation.RulesOnEventsEnabled = savedEnabled

End Sub

Sub CopyEventsPropertySetToDocument(ByVal sourcePropSet As PropertySet, ByVal doc As Document)
	' If an event-driven rules property set already exists, delete it.
	Dim oldPropSet As PropertySet = GetEventRulesPropertySet(doc)
	If (oldPropSet IsNot Nothing) Then
		oldPropSet.Delete()
	End If
	If (sourcePropSet Is Nothing OrElse sourcePropSet.Count = 0) Then Return
	Dim destPropSet As PropertySet = doc.PropertySets.Add("_iLogicEventsRules", m_ourGuid)
	For Each prop As Inventor.Property In sourcePropSet
		destPropSet.Add(prop.Value, prop.Name, prop.PropId)
	Next
	EnsureDocumentInterest(doc)
End Sub

Const iLogicId As String = "{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}"

Sub EnsureDocumentInterest(ByVal doc As Document)
	If (ThisApplication.SoftwareVersion.Major < 15) Then Return ' Inventor 2010 or before
	If (DocumentHasiLogicInterest(doc)) Then Return
	Dim dataVersion As Integer = 20090512
	Dim newInterest As DocumentInterest = doc.DocumentInterests.Add(iLogicId, "iLogic", DocumentInterestTypeEnum.kInterested, dataVersion, Nothing)
End Sub

Function DocumentHasiLogicInterest(ByVal doc As Document) As Boolean
	Dim interest As DocumentInterest = FindDocumentInterest(doc, iLogicId)
	If (interest IsNot Nothing) Then
		If (interest.InterestType = DocumentInterestTypeEnum.kInterested) Then
			Return True
		End If
		interest.Delete()
	End If
	Return False
End Function

Function FindDocumentInterest(ByVal doc As Document, ByVal clientId As String) As DocumentInterest
	For Each interest As DocumentInterest In doc.DocumentInterests
		If (String.Equals(interest.ClientId, clientId, StringComparison.OrdinalIgnoreCase)) Then
			Return interest
		End If
	Next
	Return Nothing
End Function

 

EESignature

Message 10 of 11

mrattray
Advisor
Advisor
Accepted solution

Well, I finally figured this out. The file name of my rule was "sheet metal template 2.0.iLogicVb", but I called it without the file extension ("sheet metal template 2.0"). It appears that Inventor 2016+ interpreted the ".0" as a file extension instead of part of the file name, while it did not do so in 2015-. The issue appears to be resolved by referencing the rule with the file extension included.

This is an important lesson that I'm afraid will not be heard by AutoDesk: Any change, no matter how small, will cause a problem for someone somewhere.

Mike (not Matt) Rattray

Message 11 of 11

Anonymous
Not applicable

my rule doesn't show extension..how can I fix my problem of not loading the rule? when I set it to close document event trigger?

I'm using a .txt file by the way.

 

Thanks,

Joel

0 Likes