2 Replies Latest reply on Jun 6, 2014 8:22 AM by Avishai Dov

    Api simulation problem

    Avishai Dov

      hello    

      I am trying to run a code of simulation api that i found in the help files :

      http://help.solidworks.com/2010/English/api/swsimulationapi/Analyze_Part_Example_VB.htm

       

      whan i run it firs it give me the Msg:

      Failed to open C:\Program Files\SolidWorks Corp\SolidWorks\Simulation\Examples\Tutor1.SLDPRT

       

      so i open the file manually and changed the row code :

        Set Part = SwApp.OpenDoc("C:\Program Files\SolidWorks Corp\SolidWorks\Simulation\Examples\Tutor1.SLDPRT ", swDocPART, 1, "", longstatus, longwarnings)

           to the row code :

           Set Part = SwApp.ActiveDoc

       

      it workd but it give me another problem whan i run it:

      "study not created"

      and run time error 91.

       

       

      please help me with that.

      thanks,

      Avishai

        • Re: Api simulation problem
          Vijay Kumar

          Hi, Avishai,

           

          Run time error 91 occurs when you are not declaring the variables. Ensure that you are declaring like this before your execution of code.

           

          Dim swapp as sldworks.sldworks

          Dim swpart as sldworks.modeldoc2

           

          After this declaration you continue with your code


              Set SwApp = CreateObject("SldWorks.Application")  

          Set swpart= SwApp.OpenDoc("C:\Program Files\SolidWorks Corp\SolidWorks\Simulation\Examples\Tutor1.SLDPRT ", swDocPART, 1, "", longstatus, longwarnings)

           

          Set swpart= SwApp.ActiveDoc

           

          Regards,

           

          vkm

            • Re: Api simulation problem
              Avishai Dov

              hi

              i checked it and all the variables are declared.

              the first problem disappear and it's dont give me the warning : Failed to open C:\Program Files\SolidWorks Corp\SolidWorks\Simulation\Examples\Tutor1.SLDPRT

               

              but the second  problem in the code didn't fixed.

               

              i think there are tow problems:

              1. the Msg that : " study not created" - it's seems like the study=0

              2. run time error - whan i press debug it's show me the next line in bolt : Set SolidMgr = Study.SolidManager

              i checked and SolidMgr is declared.

               

              do the code from the web give you the same problem whan you try to run it?

               

              thanks,

              Avishai