File UI Events

 

Hi,

 

I'm using the FileUIEvents in an addin to override the SaveAs dialog. The OnFileSaveAsUI event is fired every time the SaveAs dialog comes up, regardless whether the user chose save as, save copy as, save as image, save as flat...

I only want to override save and save as. At the moment I'm setting a global flag in the BeforeCommandRun event in these cases, and resetting it on the AfterCommandRun for the same command id. This is pretty ugly and I was wondering if anybody knows a better way of finding out the exact reason why the Save As dialog is popping up. Any Ideas  ?

Cheers

Calum

 

 

Posted by: Calum McLellan
Post date: 8/2/2007 12:33:17 PM

5 REPLIES

RE: File UI Events

 

I have just discoved another problem. When the user opens a new part, then opens an existing document and then at some stage clicks on Save All before saving the first part, then we end up in the OnFileSaveAsUI event. The problem is that the active document is the existing document not the document for which the dialog is appearing. We have no way of knowing which document type is being saved, making it rather difficult to come up with a file name...

I know it's a fairly obscure example, but I also know what your average user gets up to...

Any Ideas at all...

 

Posted by: Calum McLellan
Post date: 8/4/2007 9:27:23 AM

RE: File UI Events

Not to simplify what you are doing, but can you just invoke the "object.SaveAs(Newfilename)" command?

 

Posted by: Bill Ledbetter
Post date: 8/6/2007 7:05:18 AM

RE: File UI Events

Hi Bill,

 

Thanks for replying, but if only it were that simple

 

My problem is that I have to react to the saving of documents, whenever SaveAs, SaveCopyAs or SaveAll (or Save for a new document) are invoked then the SaveFileDialog pops up. This isn't allowed to happen... I have to generate a filename save the document and then perform a few more changes to the document before I leave that method. This means that I have to know if I need to call object.SaveAs(filename) or object.SaveCopyAs(filename), and I also need to know what I'm supposed to be saving (par, psm etc.)

I'm using the workaround discribed above at the moment and I've just cut support for SaveAll. But it's not very pretty and I don't 100% trust it...

 

Cheers

Calum

 

 

 

Posted by: Calum McLellan
Post date: 8/6/2007 8:56:40 AM

RE: File UI Events

 

Hi Callum!

Apparently I ran into the exactly same problem (well actually whoever is going to use this OnFileSaveAsUI should run into the same issue).

 

Did you get any better solution than to catch the before and after command and/or does it provide suitable grounds for the implementation?

Some means to get (and be able to trust) the active document in this sounds like a requirement...

Br,

Kalle Launiala

 

Posted by: Kalle Launiala
Post date: 12/3/2008 9:18:43 AM

RE: File UI Events

 

Hi Kalle,

I never did find a better solution. At the moment I am using the following code in BeforeCommandRun:if ((theCommandID == (long)AssemblyFileSave) ||

(theCommandID == (long)DetailFileSave) ||

(theCommandID == (long)PartFileSave) ||

(theCommandID == (long)SheetMetalFileSave) ||

(theCommandID == (long)WeldmentFileSave))

m_saveType = Save;

else if ((theCommandID == (long)AssemblyFileSaveAs) ||

(theCommandID == (long)DetailFileSaveAs) ||

(theCommandID == (long)PartFileSaveAs) ||

(theCommandID == (long)SheetMetalFileSaveAs) ||

(theCommandID == (long)WeldmentFileSaveAs))

m_saveType = SaveAs;

else if ((theCommandID == (long)AssemblyFileSaveCopy) ||

(theCommandID == (long)PartFileSaveCopy) ||

(theCommandID == (long)SheetMetalFileSaveCopy))

m_saveType = SaveAsCopy;

else if ((theCommandID == (long)AssemblyFileSaveAsImage) ||

(theCommandID == (long)DetailFileSaveAsImage) ||

(theCommandID == (long)PartFileSaveAsImage) ||

(theCommandID == (long)SheetMetalFileSaveAsImage) ||

(theCommandID == (long)WeldmentFileSaveAsImage))

m_saveType = SaveAsImage;

else if (theCommandID == (long)SheetMetalSheetMetalFeaturesSaveAsFlat)

m_saveType = SaveAsFlat;

else if ((theCommandID == (long)AssemblyFileSaveAll) ||

(theCommandID == (long)DetailFileSaveAll) ||

(theCommandID == (long)PartFileSaveAll) ||

(theCommandID == (long)SheetMetalFileSaveAll) ||

(theCommandID == (long)WeldmentFileSaveAll))

m_saveType = SaveAll;

else m_saveType = None;

 I then reset m_saveType (this is a custom enumeration variable) to none in AfterCommandRun.

I am only providing support for Save, SaveAs and SaveAsCopy as these all apply to the active document (solidEdge->ActiveDocument). SaveAll will rarely cause the save dialog to open and in that case I just let things run as normal.

I've been meaning to log this with GTAC but still haven't got around to it

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 12/8/2008 1:15:18 AM