I'm currently working onto a project linking a standalone C++ program (let's call it _Prog1_ ) to a C++ Solidworks add-In.
The idea is to load Solidworks parts within an assembly document and then update the positions of these parts according to data computed by _Prog1_.
_Prog1_ sends every 0.1 seconds the new positions to the Solidworks add-In.
In order to refresh positions into the Solidworks view, I call the API method "iView->IGraphicsRedraw(0)" (assuming iview is a SldWorks::IModelViewPtr and 0 is sent because we want to redraw all the screen). This redraw operation is called periodically every 0.1s in order to produce something like a movement into the Solidworks window.
Everything usually works fine if nobody touches the Solidworks window. Problems are however sometimes occuring if Solidworks has to redraw the same window following a user action (resizing or rotating the view...).
I believe the problem is caused by concurrent access to the IGraphicsRedraw method that is not correctly managed by my add-in and therefore conflicts with Solidworks Core application trying to do the same thing at the same time.
So my question is is there a proper way to redraw a document ?
I mean are there a set of operations to call, or a set of actions to do, or events to fire if I want to warn Solidworks that I you would like to allow some time and ressources to do a redraw operation ? I'm thinking to something like a Mutex protected operation in which you prevent third party access to specific ressources until you are finished with your operations.
It would be nice if there was a way to be informed into my add-in that Solidworks will intend to redraw the window soon. I would therefore skip the redraw step of my add-in until Solidworks is finished.
I tried without success to subscribe to some events such as swViewRepaintNotify. However, it seems like this event is not the good one (or I'm not using it as it should be).
Off course I also would like to have teh capability to inform Solidworks that I will redraw the window soon and that it should wait a bit before launching its own set of actions.
I was unable to find any answers into other messages so any help will be greatly appreciated.
Thanks a lot.