Programmation SolidWorks, Vba, .NET, API

Hello community,

As indicated in my question, I would like to look into SolidWorks programming in order to automate one of my CAD projects.
But the problem is that I get lost in the ocean of information on the internet.
This is why I turn to you for enlightenment:

- I have already done programming under Catia with the Vba language, is it the same principle and the same language under SW?
- I find very few tutorials and explanations on SW macros but I have read a lot of comments saying that you should start by programming in excel and then apply your skills in another software, what do you think? Because indeed there is more help on Excel.
- I also tried to find books or courses on the internet but without great results.
- I have also often read the SolidWorks API: Application Programming Interface, what is it? Just the environment where you type the code?
- I've also heard of the .NET language, what is it? Is it interesting to know?

Sorry for this multitude of questions but I think macros are now an integral part of CAD and I would like to familiarize myself with it.

Nice day.

1 Like

Hello

I will try to answer your questions clearly:

Vba stands for Visual Basic for Application. It is a fairly simple and basic language whose base is identical between each application. However, an application-specific library (dll) is loaded. So yes, it's the same language as Catia but they're not the same objects.

Starting with excel to understand the basics of the language can be useful, but you won't learn anything about Solidworks objects (APIs). If you have the basics (knowledge of OOP, types of variables, ...) I don't recommend you to go through excel to learn the SW APIs.

Apart from the help of the SW and google APIs, there is very little information. SW being a specific software (although used by a large number of people) remains less used than excel for example. To find as much information as possible about a SW function, type what you want to do in English on google by adding Solidworks API at the end.

The .Net language is a rich language for creating complete applications. It can be used to make macros but in a way that is external to SW. Again, if you don't know SW objects, I don't recommend using it.

The advantage of the SW macro editor is that if you do F1 on an object, you open the help on that object. This allows you to learn quite quickly.

I hope I have helped you or at least answered your questions.

Kind regards.

4 Likes

Hi there,

VBA is a programming language for applications: http://didier-gonard.developpez.com/tutoriels/office/vba-qu-est-que-c-est/

As regards the SW part: http://help.solidworks.com/2016/english/api/sldworksapiprogguide/Welcome.htm

Secondly, .net makes it possible to create applications that are independent of native applications. It is much more powerful than VBA. In addition, on SW, it allows the use of the Document Manager API.

This API is particularly interesting because it allows you to access the information in SW files without opening them. For example, you can read and edit the properties of an assembly of several hundred MB in a few seconds. This is the method used by MyCadTools applications such as SmartBom...

 

Have a good day as well. :-)

4 Likes

Thank you both very much, your answers are very clear!

It's a shame that we can't choose two "Best Answers"...

@industrialcadservices thank you for your answer, I'll take a quick look on the internet to be sure that I master Vb and then learn to use SW objects. Thank you for the time saved! Thank you for the method of searching on the internet!

@remrem thank you for the links, the first one will allow me to review the basics.

1 Like

Hello

I agree with the other answers with the addition of the question "What do I want to do and how far?". If it's to make SW macros then VBA is probably enough, but if the objective is to go further in the field of programming and write independent programs to drive SW or Epdm for example then it may be interesting to move to a slightly more complete language such as VB.net or C# (http://www.lesjeudis.com/article/cb-657-c)

For my part, I chose C#, a language that I find less "wordy" than VB.net and that I learned on my own with the help of the https://openclassrooms.com/ site that I find very well done and on which you can find excellent courses or tutorials. I use EDI http://www.icsharpcode.net/OpenSource/SD/Default.aspx to write my programs.

Kind regards

1 Like