8 Replies Latest reply on Oct 16, 2012 2:18 AM by Mathieu Crozet

    [C++] addin from scratch

    Mathieu Crozet

      Hello,

       

      I'm a real newbye to solidworks API et a beginner in C++.

      As i don't have Visual studio but only code::block, i would like to know if someone had already done add in with this IDE and how can I prepare my project??

      Any help and or tutorial should be helpfull..

        • Re: [C++] addin from scratch
          Keith Rice

          Mathieu,

           

          You can get Microsoft's Visual C++ Express 2010 for free.

           

          The only resource I know of that covers C++ add-ins is the SolidWorks API Fundamentals book, but it doesn't go into much depth. Are you sure you need to use C++? There are also many more examples available for the other languages. It will be hard trying to learn the API with C++.  If you are willing to learn C#, then there is a free guide on creating C# add-ins here.

           

          Keith

          Video Tutorials for the SolidWorks API

            • Re: [C++] addin from scratch
              Artem Taturevych

              Note that the VS C++ Express doesn't support the ATL and MFC so it is a problem to create add-ins there:

               

              https://forum.solidworks.com/message/196152#196152

              ______________________

              Regards,

              Artem Taturevych

              Application Engineer at Intercad

              http://intercad.com.au/

              Tel: +61 2 9454 4444

                • Re: [C++] addin from scratch
                  Mathieu Crozet

                  Well I saw that problem.

                  What I need is to create the base file for an addin project under code::block IDE in C++

                   

                  Why C++ ? Because as SW will evoluate at mid term to V6 and as it will be cross platform, it connat be designed for C#.

                  C# is only designed for windows (Mono framework is not enough reliable for me). thez more advanced language which is cross platform is C++ (which is the most used the software programmation(except script languages)).

                  That's why I chooseed C++.

                   

                  I will see what i can do the angelsix tutorial based on C# to convert it in C++

                   

                  thanks for all and if anyone have a solution, I keep ears open..

                    • Re: [C++] addin from scratch
                      Artem Taturevych

                      Why C++ ? Because as SW will evoluate at mid term to V6 and as it will be cross platform, it connat be designed for C#.

                       

                      Do you think that V6 will have the same APIs so you can run your add-in for SW on V6? I do not think so. If you choose the c++ for future - that's should be fine.

                       

                      In any case in order to create an add-in all you need is to just implement the ISwAddin Interface in your main class. Refer this article: http://help.solidworks.com/2012/English/api/sldworksapiprogguide/Overview/Using_SwAddin_to_Create_a_SolidWorks_Addin.htm?id=2566f84b5a8b4d5686821ad63f708494#Pg0

                       

                      I have never used code::block IDE but I'm pretty sure that this is possible. Just find the "Create DLL project" tutorial.

                      ______________________

                      Regards,

                      Artem Taturevych

                      Application Engineer at Intercad

                      http://intercad.com.au/

                      Tel: +61 2 9454 4444

                        • Re: [C++] addin from scratch
                          Mathieu Crozet

                          For sure the V6 versions will not have the same API but I'will not have to learn another language (i'm not programmer).

                          thanks for your help and as I find what I need, I will post here the how to for folks..

                           

                          Thanks for all

                            • Re: [C++] addin from scratch
                              Mathieu Crozet

                              Well some modifications in my programm because Code::Blocks cannot access to SW API SDK. i downloaded visual studio 2012 demo to test if i can see how templates are made.

                              I'll have to see how I can work on CODE::BLOCK IDE or if I have to buy visual studio.

                               

                              I'll get the news here..

                                • Re: [C++] addin from scratch
                                  Artem Taturevych

                                  Have you followed the article I posted before? It is not too much required in order to create new add-in:

                                   

                                  1) Create DLL project.

                                  2) Implement ISwAddin interface like:

                                   

                                  ISldWorks* iSwApp;

                                  long addinID;

                                  ...

                                   

                                  HRESULT ConnectToSW(LPDISPATCH ThisSW, long Cookie, VARIANT_BOOL * IsConnected)

                                  {

                                                 ThisSW->QueryInterface(__uuidof(ISldWorks), (void**)&iSwApp);

                                                 addinID = Cookie;

                                   

                                                 iSwApp->SetAddinCallbackInfo((long)_AtlBaseModule.GetModuleInstance(), static_cast<ICPP_CreateBodyFromFaces*>(this), addinID, &status);

                                   

                                                 return S_OK;

                                  }

                                   

                                  HRESULT DisconnectFromSW(VARIANT_BOOL * IsDisconnected)

                                  {

                                                 return S_OK;

                                  }

                                   

                                  3) Add the registry keys.

                                  4) Register DLL with RegSvr32 utility.

                                   

                                  No need to setup SDK. The only thing SKD is installing is VS templates but not libraries.

                                   

                                  In any case good luck. I think when you sort it out and post sample this post will be extremely useful.

                                  ______________________

                                  Regards,

                                  Artem Taturevych

                                  Application Engineer at Intercad

                                  http://intercad.com.au/

                                  Tel: +61 2 9454 4444