4 Replies Latest reply on Jun 10, 2014 8:06 AM by Klaudiusz Skiba

    Migrating macros from sw2013 to sw2012

    Klaudiusz Skiba

      I'm pretty new to VBA and macros, but i have some programming experience. I found out that since SW 2013 solidworks is using newer vesion of VBA.

      I'm making some macros on my laptop which uses SW2013 SP3.0. I'm creating a macros for computers having SW 2012 with SP ranging from 1 to 5.

      I tried running one macro today which runs nicely on mine, but on older SW  it doesn't even want to load libraries. All SW are 64 bits.

        • Re: Migrating macros from sw2013 to sw2012
          Deepak Gupta

          What kind of macros are those?? Do they include some user forms??

            • Re: Migrating macros from sw2013 to sw2012
              Klaudiusz Skiba

              First Thank You for reply.

              Yes I am using forms, and  I found out that instead of this :

              Dim swApp                       As SldWorks.SldWorks

              Dim swModel                     As SldWorks.ModelDoc2

              Dim swSelMgr                    As SldWorks.SelectionMgr

              Dim swDraw                      As SldWorks.DrawingDoc

               

              I need to do this:

              Public           SelMgr       As Object

              but I didn't try it yet.

              Am I in the right direction?

               

              Also I have a problem creating reference point using getVisibleEntities and the getStartingVertex or getEndingVertex because

              getVisibleEntities gets also invisible edges. What I mean is that  on the section view it will pick up also edges that are part of bigger view which are invisible in this section view. Is there any way to separate them on the drawing for time being while my macro works?

              Or is there any other good solution to find top, most to the righ and bottom vertexes. I just want to be able to create 3 border reference points on the view.

                • Re: Migrating macros from sw2013 to sw2012
                  Artem Taturevych

                  There are several important points you need to know while downgrading the macros from 2013 to 2012:

                   

                  1) You need to replace the SolidWorks API references (type libraries) from 2013 to 2012

                  2) 2012 VBA macros are 32 bit based while 2013 and newer are 64 bit based. That means if you have any 64 bit compatible references (usually this is the references to databases, 3rd party UI controls) this needs to be replaced with corresponding 32 bit versions. You may also check this by the path of your references (if it is installed into a Program Files folder it is x64 if Program Files (x86) - it is 32 bit version).

                  3) If you macro is using any win 32 API you need to replace all declarations and remove PtrSafe key word and replace LongPtr with Long in Win32 functions.

                  4) You need to make sure that the API methods you are using are available in previous version of SolidWorks. For example IConfigurationManager::AddSpeedPak2 added to SolidWorks 2013 so it is not available in 2012. You need to use IConfigurationManager::AddSpeedPak instead. The

                  IComponent2::MakeVirtual is added to 2013 as well but it has no analogues in 2012 so you may need to exclude this one.

                  ______________________________________________

                  Regards, Artem Taturevych | Snr. Developer | IC3D ANZ

                   

                  IC3DSteel – New Steel Solution for SolidWorks

                  LinkedIn - SolidWorks API Group