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.
Following your idea I try this:
CComQIPtr<IModelDoc2> iSwModel = variantDocsArray; // only one document open per SolidWorks session!
for (int arrayIndex = 0; arrayIndex != count; ++arrayIndex)
// here I can display a message box to indicate the path of the current file in the array
/* for (int arrayIndex = 0; arrayIndex != count; ++arrayIndex)
CComQIPtr<IModelDoc2> iSwOpenModel = variantDocsArray[arrayIndex];
The path of the only one file opened is correctly display in the message box, but the file is not active!
I have also tried IGetFirstDocument2() with the same result.
What else can I try? There are alternatives? All I want to do is to open a file using SolidWorks completely in background and that invisible file to be active in order to modify geometry it contains..
why do you think it needs to be active.
do not worry about it being active.
if you use ISldworks::IActivateDoc3
i think that the document will become visible.
if you can have it visible, then do this, or dont open it silently
otherwise, launch solidworks up using
or perhaps you will have to launch solidworks another way using C++
until you set ISldworks:Visible to true it will not be visible
I'm not sure what DocumentVisible(VARIANT_FALSE,swDocPART) changes in document validation. Of course if the document is opened visible, the code executes perfectly, but I want exactly the opposite.
I supposed (to your suggestion) that changes in activation caused this error.
ok. well there are certain things that solidworks can not do to non visible documents
it explains what documentvisible does.
what are you trying to do with the document invisible. tell me that because it may not be possible.
Basically after the file is open I want to access some API functions from other SolidWorks third party add-in as explained in my previous help request.
The access of these API functions started as below:
//iSwApp->get_IActiveDoc2(&iSwModel); // line in the documentation of API ADDIN so the function ask for the active document
int status = ADDIN1_API_Function1(iSwModel); // here the code stops when the document is open but not visible
i see i see. i wish i was more familiar with C++. some day i think i might be.
if you do this as a client server application like you want to, setting the documents to visible shouldnt be a problem.
i understand exactly what you are going through.
can you modify Addin1?
if so, instead of telling it to use the ActiveDoc. pass the model Doc you want it to execute on as a parameter.
I have no options to modify Addin1. unfortunately. It provides only a couple of functions ..
For sure an alternative exists and it will take time to find it.
But I like to thank you for your time!
Keep in touch!