From an external app (.exe file) i try to open some files silently using the following code:
HRESULT hr = S_OK;
hr=iSwApp->DocumentVisible(VARIANT_FALSE,swDocPART);//if this line is commented the code runs perfectly but SolidWorks window will be visible when the file is open
iSwApp->OpenDoc6(L"D:\\myPart.SLDPRT",swDocPART, swOpenDocOptions_Silent, L"Default", &lErrors, &lWarnings,&iSwModel);
If I commented the DocumentVisible () line above, the iSwModel data returned from OpenDoc6() is valid but the SolidWorks window is not completely hidden and for the short period of time - when the file is opening - it is visible and only after the loading process is finished it will close itself. If the line is not commented, and the code execute as above, the iSwModel data is not valid - it is different than in the previous case (it is not NULL but it is different)
The valid data expected in the main program, after the code above, must be something like:
so the program needs to have access to the active document obtain from OpenDoc6() function but it seems that DocumentVisible() modify it in such way that OpenDoc6 () returns a document which it is not the active document.
What I'm missing here? What is wrong? It could be a workaround to open a file in background and access it as an active document even it is not visible in that way no SolidWorks window display on the screen? I try also OpenDoc7() and the result was the same..
Any idea is much appreciated!
because its not visible, its not active.
you will need to
then loop on them somehow in your C++ world to get the document where IDocument.PathName Contains MyPart.Sldprt
i never rely on activedoc for many things personally.