6 Replies Latest reply on May 23, 2014 2:21 PM by Checkcheck Master

    Try to open a Part or Assy invisible or in Background

    Checkcheck Master

      Hi there,

       

      With a drawing open I start a macro who opens a Part or Assy to get for example the BoxSize from the model.

      I like to open te Part or Assy invisible or in Background, I don't have/don't like to see this operation.

      I've tried:

       

                  ' Allow SolidWorks to run in the background

                  ' and be invisible

                  swApp.UserControl = False

                

                  ' If the following property is true, then the

                  ' SolidWorks frame will be visible on a call to

                  ' ISldWorks::ActivateDoc2; so set it to false

                  swApp.Visible = False

             

                  ' Keep SolidWorks frame invisible when

                  ' ISldWorks::ActivateDoc2 is called

                  Dim pFrame As Frame

                  Set pFrame = swApp.Frame

                  pFrame.KeepInvisible = True

       

      And Reverse:

       

                  ' Show SolidWorks frame and SolidWorks

                  pFrame.KeepInvisible = False

                  swApp.Visible = True

       

      But I can't get it to work correctly, I still can watch the 'opening file' operation.

       

      Anyone knows how to handle this ?

       

       

      Greetings,

      Check Master     

        • Re: Try to open a Part or Assy invisible or in Background
          Artem Taturevych

          You need to use SldWorks::DocumentVisible method in this case. Like following:

           

          'Set to not show the opening operation for next opened parts and assemblies

          swApp.DocumentVisible False, swDocumentTypes_e.swDocPART

          swApp.DocumentVisible False, swDocumentTypes_e.swDocASSEMBLY

           

          'TODO:Open Document

           

          'Restore flag otherwise all documents will be opened invisibly

          swApp.DocumentVisible True, swDocumentTypes_e.swDocPART

          swApp.DocumentVisible True, swDocumentTypes_e.swDocASSEMBLY

          ______________________________________________

          Regards, Artem Taturevych | Snr. Developer | IC3D ANZ

           

          IC3DSteel – New Steel Solution for SolidWorks

          translationXpert – SolidWorks files language translator

          LinkedIn - SolidWorks API Group

            • Re: Try to open a Part or Assy invisible or in Background
              Checkcheck Master

              Thanks Artem for your reaction !

               

              I've tried your code and study the API help, but still I can see the part opening.

              swApp is defined and set as:

               

              Dim swApp                   As SldWorks.SldWorks
              Dim swModel                 As SldWorks.ModelDoc2
              Dim swDraw                  As SldWorks.DrawingDoc
              Dim swView                  As SldWorks.View
              Dim bRet                    As Boolean

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

              Set swDraw = swModel

               

              This is how I open the part, activate and switch to the right configuration:

              Set swModel = swApp.OpenDoc6(ModelFromDrawingView, nDocType, swOpenDocOptions_Silent, Data.ConfigName, nErrors, nWarnings)

              Set swModel = swApp.ActivateDoc2(ModelFromDrawingView, True, nErrors)

              swModel.ShowConfiguration2 (Data.ConfigName)

               

              Any idea what's going wrong ?

               

               

              Greetings,

              Check Master