Know intended file location before saving

Know intended file location before saving

PolemEngineering
Advocate Advocate
269 Views
4 Replies
Message 1 of 5

Know intended file location before saving

PolemEngineering
Advocate
Advocate

I have an iLogic-rule which is executed before saving (by the Global Event Trigger 'Before Save').

 

Is it possible to know the intended (already given) file location of the file that has not yet been saved?

If I can compare that location with the location where my templates are stored (

ThisApplication.DesignProjectManager.ActiveDesignProject.TemplatesPath

) I can prevent rule execution when Save Copy as Template...

 

Other suggestions are welcome as well.

Thanks!

René van der Starre

0 Likes
270 Views
4 Replies
Replies (4)
Message 2 of 5

Andrii_Humeniuk
Advisor
Advisor

Hi @PolemEngineering . If you do not want your rule to be executed when you make the first save, you can count the number of saves in the active document. Example:

Dim oDoc As Document = ThisDoc.Document
Dim iSC As Integer = oDoc.FileSaveCounter
If iSC <> 0 Then
	MessageBox.Show("Count - " & iSC, "Save counter")
End If

This way you can skip the first save.

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 3 of 5

PolemEngineering
Advocate
Advocate

Thanks for the response...

I am familiar with this save counter. In this case it does not seem to be the solution.

 

I always use too much text and I decided to be a bit shorter this time. Unfortunately, you then also leave out more relevant matters...

 

I use code to structure the properties in our documents. These are used to populate our ERP system. That's why I enforce it on a number of Events using the Global Event Triggers, so also on the first save. In a number of cases the code ends immediately (among other things due to lack of write permissions or file status).

 

I am also regularly making changes to our templates. In this action, it makes little sense to run the iLogic code.

It's not harmful, but if I can simply avoid it, then that's my preference.

René van der Starre

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

Hi @PolemEngineering.  If you need more control and/or more information while attempting to manage that event, you may need to use your own custom event handler block of code, instead of relying on the iLogic Event Triggers dialog.  You may already know about some of these, but some of the Inventor API Events that come to mind are:

  • The FileUIEvents.OnFileSaveAsDialog Event, which gets triggered when the FileSaveAsDialog is going to be shown, providing us with multiple pieces of information, and the ability to allow normal functionality, override the FileName, or cancel it.
  • The DocumentEvents.OnSave Event, which gets triggered both before & after a specific document gets saved (every time it gets saved), allowing us to check its file name, and possibly cancel the event, but I don't think we can override the file name with this one.  If canceled, no 'after' timing state is reported.
  • The ApplicationEvents.OnSaveDocument Event, which gets triggered every time any document gets saved, both before & after the save, also only allowing us to cancel the event, but not override the file name.  If canceled, it still reports that the event was aborted during the 'after' timing state.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

PolemEngineering
Advocate
Advocate

Thanks for this insight. I have indeed written my own Event Handler before (with InterActionEvents and SelectEvents), but I am certainly not familiar with it. It is also far from my profession (I try, in all honesty, to help myself and my colleagues with bits of automation to promote structure and to prevent repetitive actions).

 

I will delve into this. Thanks again.

René van der Starre

0 Likes