Inventor Customization

Inventor Customization

Reply
Valued Mentor
MegaJerk
Posts: 277
Registered: ‎01-26-2011
Message 1 of 9 (2,316 Views)
Accepted Solution

API: set an Event Trigger for an ilogic Rule in a document.

2316 Views, 8 Replies
11-03-2011 10:25 PM

Is there a way to set the event trigger of an ilogic file that's already inside of a document? I have code that can automatically create and populate new rules across my assembly parts, but it would be nice to set certain rules to fire every time that part gets saved. 

If it can't be accomplished outright from the API, would it be possible to throw an OnEvent (save event in this case) inside of the iLogic code, to get the same results?

(I've not messed around with events much which is why I'm asking :smileywink: )

 

 

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------

I have done a lot of digging since I last asked this question, and feel that I have finally found an answer. 

Because I see that it is a question that has been asked a few times, and has gotten little in the way of a response, I wanted to revive this thread with my findings so that maybe others won't find themselves as lost as I was. 
A copy / paste from my comment over on the Being Inventive Blog :   http://beinginventive.typepad.com/being-inventive/2011/10/creating-ilogic-rules-automatically.html 

(For some reason, it seems that my comment has disappeared, or is being validated by an admin, so if you don't see it, I apologize)

------------------------------------------------------------------------------


Basically, the Event Triggers that can be found in the Inventor UI, can be set using a document's PropertySet "iLogicEventsRules". Each different Event Trigger has a corresponding Property Name, as well as a Property ID that (seems as if it) has to fall within a number range stemming from a set base value. In addition, each base Property Name ends with a numerical value that indicates the place in line that whatever Property Value (in this case, an iLogic Rule) assigned to it, will fire off.

 

So as an example, you would end up with a Property that looks something like this :


("Rule1", "AfterDocOpen0", 400)

 

So we want an iLogic Rule named Rule1 to go off after the document has been opened. Because it's the first rule that has had that Event Trigger applied to it, the "AfterDocOpen" has the lowest numerical value applied to it; 0.

If I wanted to add a different rule to the same Event Trigger, it might look something like this :

 

("Rule2", "AfterDocOpen1", 401)

 

Notice how the value after the "AfterDocOpen" has changed? That shows that it will fall into line right after the AfterDocOpen0.

------------------------------------------------------------------------------

 

I have made a VB.Net Project / source, that I have sent to my Box.com profile for anyone to download : http://www.box.com/s/pzoz3vq88qesz6mcpm1p 

Inside of the .zip, you will find all of the source code that I used in making an iLogic rule injector, that also sets up any Event Triggers that the user selects. Essentially it will iterate through a number of user selected files, open them one by one, create the rule that they have made inside of the editor, apply any triggers, save the part and then close it. It was a project that I started in order to make my job a bit easier, but feel that it may make the lives of others, a little easier as well. 


NOTE: This is the FIRST proper programming that I've done, so if you find something that breaks it, feel free to send me a PM detailing what went wrong. I tried to do as much testing as I could, but there's always something that a person can miss. 

------------------------------------------------------------------------------

 

Just in case that my comment doesn't end up returning back, over on the Being Inventive blog, I will post the table of the Event Triggers / Names / IDs that I have found so far :

------------------------------------------------------------------------------

 

CheckList Box Name: : Property Name : : Property ID
----------------------------------------------------------------------------------------
After Open Document : AfterDocOpen : 400
Close(Document) : DocClose : 500
Before Save Document : BeforeDocSave : 700
After Save Document : AfterDocSave : 800
Any Model Parameter Change : AfterAnyParamChange : 1000
Part Geometry Change** : PartBodyChanged : 1200
Material Change** : AfterMaterialChange : 1400
Drawing View Change*** : AfterDrawingViewsUpdate : 1500
iProperty(Change) : AfterAnyiPropertyChange : 1600
Feature Suppression Change** : AfterFeatureSuppressionChange : 2000
Component Suppression Change* : AfterComponentSuppressionChange : 2200
iPart / iAssembly Change Component* : AfterComponentReplace : 2400
New Document : AfterDocNew : 2600

----------------------------------------------------------------------------------------

 

* Indicates that it's for an Assembly file only 
** Indicates that it's for a Part file only

*** Indicates that it's for a Drawing file only. 
 


Hope this can be of use to someone.  

Valued Mentor
MegaJerk
Posts: 277
Registered: ‎01-26-2011
Message 2 of 9 (2,275 Views)

Re: API: set an Event Trigger for an ilogic Rule in a document.

02-09-2012 10:20 PM in reply to: MegaJerk

I have done a lot of digging since I last asked this question, and feel that I have finally found an answer. 

Because I see that it is a question that has been asked a few times, and has gotten little in the way of a response, I wanted to revive this thread with my findings so that maybe others won't find themselves as lost as I was. 
A copy / paste from my comment over on the Being Inventive Blog :   http://beinginventive.typepad.com/being-inventive/2011/10/creating-ilogic-rules-automatically.html 

(For some reason, it seems that my comment has disappeared, or is being validated by an admin, so if you don't see it, I apologize)

------------------------------------------------------------------------------


Basically, the Event Triggers that can be found in the Inventor UI, can be set using a document's PropertySet "iLogicEventsRules". Each different Event Trigger has a corresponding Property Name, as well as a Property ID that (seems as if it) has to fall within a number range stemming from a set base value. In addition, each base Property Name ends with a numerical value that indicates the place in line that whatever Property Value (in this case, an iLogic Rule) assigned to it, will fire off.

 

So as an example, you would end up with a Property that looks something like this :


("Rule1", "AfterDocOpen0", 400)

 

So we want an iLogic Rule named Rule1 to go off after the document has been opened. Because it's the first rule that has had that Event Trigger applied to it, the "AfterDocOpen" has the lowest numerical value applied to it; 0.

If I wanted to add a different rule to the same Event Trigger, it might look something like this :

 

("Rule2", "AfterDocOpen1", 401)

 

Notice how the value after the "AfterDocOpen" has changed? That shows that it will fall into line right after the AfterDocOpen0.

------------------------------------------------------------------------------

 

I have made a VB.Net Project / source, that I have sent to my Box.com profile for anyone to download : http://www.box.com/s/pzoz3vq88qesz6mcpm1p 

Inside of the .zip, you will find all of the source code that I used in making an iLogic rule injector, that also sets up any Event Triggers that the user selects. Essentially it will iterate through a number of user selected files, open them one by one, create the rule that they have made inside of the editor, apply any triggers, save the part and then close it. It was a project that I started in order to make my job a bit easier, but feel that it may make the lives of others, a little easier as well. 


NOTE: This is the FIRST proper programming that I've done, so if you find something that breaks it, feel free to send me a PM detailing what went wrong. I tried to do as much testing as I could, but there's always something that a person can miss. 

------------------------------------------------------------------------------

 

Just in case that my comment doesn't end up returning back, over on the Being Inventive blog, I will post the table of the Event Triggers / Names / IDs that I have found so far :

------------------------------------------------------------------------------

 

CheckList Box Name:                     : Property Name :  : Property ID
----------------------------------------------------------------------------------------
After Open Document                   : AfterDocOpen                 : 400
Close(Document)                          : DocClose                     : 500
Before Save Document                   : BeforeDocSave           : 700
After Save Document                       : AfterDocSave               : 800
Any Model Parameter Change        : AfterAnyParamChange   : 1000
Part Geometry Change**            : PartBodyChanged         : 1200
Material Change**                          : AfterMaterialChange     : 1400
Drawing View Change***                  : AfterDrawingViewsUpdate  : 1500
iProperty(Change)                          : AfterAnyiPropertyChange             : 1600
Feature Suppression Change**          : AfterFeatureSuppressionChange   : 2000
Component Suppression Change*   : AfterComponentSuppressionChange : 2200
iPart / iAssembly Change Component* : AfterComponentReplace   : 2400
New Document                               : AfterDocNew                  : 2600

----------------------------------------------------------------------------------------

 

* Indicates that it's for an Assembly file only 
** Indicates that it's for a Part file only

*** Indicates that it's for a Drawing file only. 
 


Hope this can be of use to someone.  

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Valued Mentor
MegaJerk
Posts: 277
Registered: ‎01-26-2011
Message 3 of 9 (2,267 Views)

Re: API: set an Event Trigger for an ilogic Rule in a document.

02-10-2012 04:12 AM in reply to: MegaJerk

I also forgot to mention that if you do not have Visual Studios installed, and simply want to use the application, you should still download the file from my Box.com link (posted in the comment above). Once that file has been unzipped, you can find the most recent build in the : \obj\x86\Release  folder, named : Code Injector.exe

Another notice : I've only used this on machines running Inventor 2011! I can not guarantee that this even works with 2012 as we have yet to upgrade. If it turns out that it doesn't work well with 2012, and that no one here can fix it, my workplace will be upgrading to that version of Inventor in about 2 weeks, so I will have a chance to explore fixing it after that time (if it's broken for that version). 

 

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Valued Mentor
MegaJerk
Posts: 277
Registered: ‎01-26-2011
Message 4 of 9 (2,255 Views)

Re: API: set an Event Trigger for an ilogic Rule in a document.

02-10-2012 03:41 PM in reply to: MegaJerk

Alright. Last post. I found out today that a bit of bad math had snuck into my brain, and subsequently made it into the code that would check against the Property ID of the Event Trigger. Needless to say... it caused problems (IE: Things not working as they should), so I've fixed it with the latest build / source which can be found here : http://www.box.com/s/dvoe410ct7g8kjoqo0tk

Sorry for the re-bump, but there is no way to edit my previous posts it would seem...

 

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Distinguished Contributor
CPRob
Posts: 115
Registered: ‎11-11-2004
Message 5 of 9 (2,202 Views)

Re: API: set an Event Trigger for an ilogic Rule in a document.

02-23-2012 07:03 AM in reply to: MegaJerk

Thanks for looking into this.  I have been searching for a solution to this for awhile.

 

http://forums.autodesk.com/t5/Autodesk-Inventor/Apply-iLogic-rule-to-several-files/td-p/2688688

____________________________
Inventor Professional 2014 64 Bit
Windows 7 Professional
NVIDIA Quadro FX 4600
Dual Intel Xeon E5540 CPUs
16GB DDR3 Ram
Valued Mentor
MegaJerk
Posts: 277
Registered: ‎01-26-2011
Message 6 of 9 (2,196 Views)

Re: API: set an Event Trigger for an ilogic Rule in a document.

02-23-2012 08:43 AM in reply to: CPRob

As it stands now, the exe that is included in the latest build should (with luck) solve your problem. Because this is all still a work in progress, I do plan on adding in more functionality as time progresses. If there is anything in particular that you'd like to do with it, that you can't already, drop me a message and I'll see if it can't be added into the mix of things. 

Some things that are already on the plate: 

1) Allowing for multiple files to be processed that are not in the same folder  

2) Allowing for the user to create a temporary run once iLogic rule that will essentially give the ability to make iLogic macros. It will simply create the rule, run the rule code, and then delete it. 


The iLogic macro (item 2) is really just a personal thing that I wanted after making lots of code that creates / updates parameters in files. I don't really need the code to ever carry over with the files, so I figured it would be nice to have an automated way of running the code (that is already written, which is the important part), without cluttering up my rule browser. 


  

 

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Distinguished Contributor
CPRob
Posts: 115
Registered: ‎11-11-2004
Message 7 of 9 (2,191 Views)

Re: API: set an Event Trigger for an ilogic Rule in a document.

02-23-2012 08:52 AM in reply to: MegaJerk

I didn't look too deeply into your code yet but are you able to place External rules under a specific event trigger with your solution?

____________________________
Inventor Professional 2014 64 Bit
Windows 7 Professional
NVIDIA Quadro FX 4600
Dual Intel Xeon E5540 CPUs
16GB DDR3 Ram
Valued Mentor
MegaJerk
Posts: 277
Registered: ‎01-26-2011
Message 8 of 9 (2,189 Views)

Re: API: set an Event Trigger for an ilogic Rule in a document.

02-23-2012 08:56 AM in reply to: CPRob

Sadly, not in any direct way. I'm actually glad that you mentioned that, as it's something I have failed to look into. However, one could always simply make an internal rule with an event trigger, that only has the function of running the external rule, by default, when the internal's event trigger goes off. 

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Distinguished Contributor
jeff_jordan
Posts: 128
Registered: ‎05-10-2011
Message 9 of 9 (2,179 Views)

Re: API: set an Event Trigger for an ilogic Rule in a document.

02-23-2012 12:33 PM in reply to: MegaJerk

Megajerk,

 

Thanks for posting all of this!  I look forward to giving it a try when I get a chance.  I wish there was a way to merge the two posts.

 

Again, thanks.

Autodesk Product Design Suite 2012 (Inventor 2012 Pro SP1, Vault 2012 Pro Update 1)
Windows 7, 64-bit
Intel Core i7
8GB
Nvidia Quadro FX 3800M
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.