1 Reply Latest reply on Nov 5, 2018 10:40 PM by Artem Taturevych

    Robust get ModelDoc using file and config name

    Michael Caulton

      What is the most robust method to get the ModelDoc data if you have access to the file and configuration name and the assembly containing the  file is active in a SW window but no other SW windows are active?


      I have been use the lines below but sometime the "GetOpenDocument" returns nothing.


      Dim swModel As IModelDoc2 = swApp.GetOpenDocument(sFileName)


        • Re: Robust get ModelDoc using file and config name
          Artem Taturevych

          Just call the OpenDoc6: if that model is already loaded with component than you will get the pointer to IModelDoc2 and model will still be invisible, otherwise (if component is suppressed or lightweight) the model will be opened in its own window. If you want to prevent opening in its own window for suppressed or lightweight components (i.e. open the document invisible) use the ISldWorks::DocumentVisible property