API starter packet?

Programming and macros
MJuric
Posts: 1067
Joined: Mon Mar 08, 2021 3:21 pm
Answers: 1
x 31
x 873

API starter packet?

Unread post by MJuric »

I'm in the process of looking at ways to automate some of our CAM programming. The path I'm currently on is creating the paths inside a model that is used in Driveworks and then have those paths "Update" when the model is created. In the rather short time I've been working on this I've run into several problems on the CAMWorks side of things, updates not happening, loosing features etc.

It was suggested to me that rather than doing it this way that I use Driveworks to create the model and then once create use API/Macros etc etc to do the programming....I know nearly nothing about this approach. So where would someone start to even get an idea of whether or not this approach seems feasible and then where would one go to attempt to learn this nifty stuff?

I was going to post this in the CAM forum but my guess would be that there is more SW stuff involved in this that CAMWorks...so here I am.
User avatar
JSculley
Posts: 590
Joined: Tue May 04, 2021 7:28 am
Answers: 55
x 7
x 822

Re: API starter packet?

Unread post by JSculley »

Typically, if it is something you can do manually in SW, it is something you can automate via the API. There are some exceptions, but for the most part, everything in SW is available via the API. With that, you should be able to know if it is at least possible to do what you want. The API docs are full of examples, some better than others. If you are serious about creating a robust, usable, future proof tool, stay away from VBA and go with C# (or VB.NET if you must). If you don't have a programming background, go through a tutorial that covers the basics for the language you choose. You don't need to learn all the fancy parts, just the beginning stuff. What does a program look like, what are the basic data types, loops, if-then-else statements, flow control, etc. As your code gets more complex you can learn the more sophisticated stuff (inheritance, collections, generics, etc). If you have a manual process, try automating one part of it rather than trying to bite off the whole thing. What step, inside SOLIDWORKS, takes the most time? Attack that first and then move on from there. And follow my three rules of coding:

1. Make it run (Compiles without errors and does something)
2. Make it run right (Does what it is supposed to)
3. Make it run fast (Does what it is supposed to, faster than the manual method)
User avatar
bnemec
Posts: 1869
Joined: Tue Mar 09, 2021 9:22 am
Answers: 10
Location: Wisconsin USA
x 2464
x 1344

Re: API starter packet?

Unread post by bnemec »

It sounds like the process you want to automate is on the CAMWorks side. I have never used it and was curious what it looked like, but I cannot find help documents for any CAMWorks API.
MJuric
Posts: 1067
Joined: Mon Mar 08, 2021 3:21 pm
Answers: 1
x 31
x 873

Re: API starter packet?

Unread post by MJuric »

bnemec wrote: Wed May 12, 2021 11:54 am It sounds like the process you want to automate is on the CAMWorks side. I have never used it and was curious what it looked like, but I cannot find help documents for any CAMWorks API.
That's correct. I took a CAMWorks class a week or so back and have been discussing this with the instructor. He suggested doing basic SW API stuff first to get my feet wet and then attempt the CAMWorks stuff. CAMWorks has an entire directory of Sample stuff but it's installed with CAMWorks so unless you have CAMWorks you probably don't have the CAMWorks API stuff.
MJuric
Posts: 1067
Joined: Mon Mar 08, 2021 3:21 pm
Answers: 1
x 31
x 873

Re: API starter packet?

Unread post by MJuric »

JSculley wrote: Wed May 12, 2021 10:48 am Typically, if it is something you can do manually in SW, it is something you can automate via the API. There are some exceptions, but for the most part, everything in SW is available via the API. With that, you should be able to know if it is at least possible to do what you want. The API docs are full of examples, some better than others. If you are serious about creating a robust, usable, future proof tool, stay away from VBA and go with C# (or VB.NET if you must). If you don't have a programming background, go through a tutorial that covers the basics for the language you choose. You don't need to learn all the fancy parts, just the beginning stuff. What does a program look like, what are the basic data types, loops, if-then-else statements, flow control, etc. As your code gets more complex you can learn the more sophisticated stuff (inheritance, collections, generics, etc). If you have a manual process, try automating one part of it rather than trying to bite off the whole thing. What step, inside SOLIDWORKS, takes the most time? Attack that first and then move on from there. And follow my three rules of coding:

1. Make it run (Compiles without errors and does something)
2. Make it run right (Does what it is supposed to)
3. Make it run fast (Does what it is supposed to, faster than the manual method)
Got any suggestions for "C" programming starter tutorials? I have some pretty basic experience with it. I made my Arduino turn an LED bulb on and off along a Sine wave time frame...so that's something isn't it :)
User avatar
JSculley
Posts: 590
Joined: Tue May 04, 2021 7:28 am
Answers: 55
x 7
x 822

Re: API starter packet?

Unread post by JSculley »

MJuric wrote: Wed May 12, 2021 12:46 pm Got any suggestions for "C" programming starter tutorials? I have some pretty basic experience with it. I made my Arduino turn an LED bulb on and off along a Sine wave time frame...so that's something isn't it :)
Not C. C# (C-Sharp). It's a newer, friendlier, less dangerous language.

I think any tutorial will do the job. Have a look at https://www.w3schools.com/cs/
MJuric
Posts: 1067
Joined: Mon Mar 08, 2021 3:21 pm
Answers: 1
x 31
x 873

Re: API starter packet?

Unread post by MJuric »

JSculley wrote: Wed May 12, 2021 1:37 pm Not C. C# (C-Sharp). It's a newer, friendlier, less dangerous language.

I think any tutorial will do the job. Have a look at https://www.w3schools.com/cs/
Great, thanks
User avatar
bnemec
Posts: 1869
Joined: Tue Mar 09, 2021 9:22 am
Answers: 10
Location: Wisconsin USA
x 2464
x 1344

Re: API starter packet?

Unread post by bnemec »

JSculley wrote: Wed May 12, 2021 1:37 pm I think any tutorial will do the job. Have a look at https://www.w3schools.com/cs/
I really like that place.

@MJuric , You mentioned Arduino :roll: anyway, just like Arduino is/has an IDE (Integrated Development Platform) so does windows. Microsoft Visual Studio is what it's called, you'll just need the Community version as long as you're just making stuff for your own use. There are a lot of concepts in using that IDE, beyond the syntax (what you can play with at w3schools). I suggest taking time to do the "Hello World" first steps. For project type I just use Console App (.NET Framework) or Windows Forms App (.NET Framwork)
There is a .NET Core, but I haven't taken time to update myself to it's differences to the standard framework.
There is also the WPF (Windows Presentation Foundation) but I haven't learned the difference of that either.
Anyway, I would get familiar with a couple Visual Studio C# tutorials from Microsoft's MSDN website(s) then get started with Solidworks API basics.
MJuric
Posts: 1067
Joined: Mon Mar 08, 2021 3:21 pm
Answers: 1
x 31
x 873

Re: API starter packet?

Unread post by MJuric »

Thanks all,

I think at least I got something I can start to cut my teeth on.
User avatar
JSculley
Posts: 590
Joined: Tue May 04, 2021 7:28 am
Answers: 55
x 7
x 822

Re: API starter packet?

Unread post by JSculley »

bnemec wrote: Wed May 12, 2021 3:30 pm There is a .NET Core, but I haven't taken time to update myself to it's differences to the standard framework.
Core is simply .NET with all the Windows specific stuff removed. So, you can write .NET code for Linux and such. No use at all when talking about the SOLIDWORKS API, since SW is Windows only.
Post Reply