Happy new year,.
I am using the demo edgebar controls to create an edgebar that shows a tree of assemblies / parts from a database. (with VB.net)
I use the afterdocumentsave command for the draft file to update a database and create a PDF document.
The afterdocumentsave command seems to loop through twice, with the PDF save turned off and at least 6 times when saving the PDF.
I use the objDraftFile.SaveAs(pdfFile) command to create the PDF, and is working well but it also seems to fire the afterdocumentsave command as well causing a loop.
Even if I disable the PDF save function it still loops through twice causing two updates to the database, ( not an issue, just traffic)
Can the loop be turned off
has anyone else seen this issue?
reducing the processing of unnecessary events could be achieved by checking in the event handling routine for the document extension DFT and by additionally setting and checking some kind of a flag variable to indicate whether the document got already processed by you or not.
Thank you for the help, I have added a flag that is set when the save routine starts and is turned off when finished, this helps with the PDF save function.
In the afterdocumentsave function I check the document type then call a routine for that document,
if i manually step (F11) through the program in debug mode I can see that the afterdocumentsave processes normally as I click the save icon, it then finishes correctly and immediately runs again. it has finished the previous cycle so has reset my flag,
The control is not passed back to the main SE program until the second time has finished.
This happens on every document type, Assy, Part, and Draft, I do update document properties with the beforedocumentsave though. not sure if that is an issue,
I will need to some further testing, blocking out sections of the program to see if I can find a cause,
I have commented out all of the subroutine calls in the afterdocumentsave and can see that the afterdocumentsave is run twice, so it is being called by the save icon and something else...
Just wondered if it was something that anybody else had seen,
Would you be able to share your source code with me or provide a demo example? I'd be happy to look at it for you if you can. I could try to reproduce what you're trying to do but I suspect there is something specific in your code that may be causing the duplicate events being raised.
Thank you for the offer, I would be able to share the code as its only a pet project of mine..
However I have now found the issue,
I had changed the GUID and name for the project, and at some point run the application with the new name and the old GUID, I noticed that when opening a part it was initializing two edgebars using the same code thus i could step through it twice. (only one visible in SE).
Maybe I had not unregistered the old one. there was only one shown in the Addin's list.
Both were listed in the windows registry
So I deleted both GUID's from the registry and reregistered the new one.
It now works.
Feeling a bit stupid, but happy that it wasnt my actual code..
Thanks everybody for the help.