How to set an Event Trigger for Inventor Application NOT for a Document?

How to set an Event Trigger for Inventor Application NOT for a Document?

Anonymous
Not applicable
1,078 Views
6 Replies
Message 1 of 7

How to set an Event Trigger for Inventor Application NOT for a Document?

Anonymous
Not applicable

The below iLogic code part works well for assigned part or assembly document.

 

SyntaxEditor Code Snippet

' Set reference to active document.
oDoc = ThisApplication.ActiveDocument

' Check the Document type is an assembly or part
If (oDoc.DocumentType <> kAssemblyDocumentObject And _
   oDoc.DocumentType <> kPartDocumentObject) Then

   '+
   ' No need to give a message
   '-
   'MsgBox("Error:Document type is not assembly/part")
   Exit Sub
End If

' Get document's full file name
sFname = ThisDoc.PathAndFileName(False)

sDWFname = sFname & ".dwf" ' DWF
sDWGname = sFname & ".dwg" ' DWG

' Do a 'Save Copy As' to DWF and DWG formats
oDoc.SaveAs(sDWFname, True)
oDoc.SaveAs(sDWGname, True)

MessageBox.Show("*.DWF ve *.DWG dosyalari basariyla saklanmistir...", "Model - Save As DWF/DWG")

When you assign this rule via 

         1) Toolbar Manage --> ILogic-->Event Triggers

         2) Rules Triggered By Events form, Select, After Save Document

         3) Then assign the above rule,and click OK

it works fine. When you save any time, the related extentions are also saved.

 

But when a designer creates or open another drawing, this rule must be redefined for the new document again.

 

How to define such a rule for Inventor Application level to get rid of this redefinition? We want to enable *.DWF and *.DWG files being saved for 

all documents, and define iLogic rule once,

               .without writing additional addin,

               .without trying to transfer this rule between drawings,

 

If there is no way to do this, this feature shoud be added to a new version of Inventor.

 

Thank you for any feedback

0 Likes
1,079 Views
6 Replies
Replies (6)
Message 2 of 7

Owner2229
Advisor
Advisor

HI there,

you can use it as external rule, just paste attached file (you have to delete ".txt" at the end of filename so you will get: DWF-DWG-Export.iLogicVb, inside is the code you pasted here) somewhere on your server (so other colleagues can see it to). Then u need to go to iLogic and in section called "External Rules", right-click there > add rule > find your rule. Then set up your event just like you did for normal rule (After save or something...). You have to do this on all computers you want to use it. 

 

Hope this will help you a bit,

Mike

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 7

Anonymous
Not applicable

Dear Mike thank you for your help. I followed your steps. The iLogicVB rule file can be seen in the External Rule section. But when an another design file opened, the rules is not active. The designer should click iLogic Event Triggers button and assign this external rule to After Save Document line. We are trying to get rid of this assignment per each design document. This kind of rule is an application specific rule, not a document specific. There should be a way to do. I hope there is.

 

Thanks a lot

Atila

 

 

0 Likes
Message 4 of 7

Owner2229
Advisor
Advisor

The only think that I know of could help is Megajerk's Code Injector:

http://goo.gl/ce1Qg

Nothing else seems to solve this (was looking everywhere)...

Regards, Mike

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 5 of 7

MechMachineMan
Advisor
Advisor

Modifying them templates to include the event triggers, or writing an add-in are the only 2 ways I could think of.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 6 of 7

Owner2229
Advisor
Advisor

I thought about these ^^ and some more options as well, but none of them covers this cause.

Including it in template wont work for parts created before.

Addin for "After save trigger" could work, but the same will do the Injector, as it actualy is addin. And it's probably fastest solution.

I'll look at it tomorow, if I'll have some time to spare...

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 7 of 7

Anonymous
Not applicable

Thank you Mike and Justin. Modifying the templates is a good solution for new documents. But I think Autodesk Team should propose a nice solution (other than template modification and user developed code injector) for an application level Event Triggers by some how.

 

Regards

Atila

0 Likes