Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

First attempt VB.net with Solidworks

Status
Not open for further replies.

Toomey

Mechanical
Mar 23, 2007
3
0
0
Hello everyone.

I am currently trying to write a VB.net[2005] stand alone application that interfaces with SolidWorks to automate a simple design process. I need to use the standalone as I have a built in database, and VBA does not support that.

So far though, I have very little luck in creating even the most simple SolidWorks application. If anyone could point me towards some simple examples, I have had almost no luck with those in the SolidWorks help, I would greatly appreciate it. Even something as simple as firing Solidworks, opening a drawing template, and drawing a rectangle of set size, would be a huge help.

Thanks for any help.
 
Replies continue below

Recommended for you

Toomey,

I have not written anything yet myself. But I have been able to attach to a running version of SW and get the ModelDoc2 object. I have created a solution (using VB.Net Express) that draws two lines. To run it you must have SolidWorks open and a blank part model open. Hope this helps.

SA

 
Hey thanks Solidair. THat did help out. Now I just need to get solidworks open, and open a template. I am using shell("filepath") to open solidworks, but I imagine there is a better method. Any other tips?
 
Toomey,

I am not a real big fan of opening SolidWorks thru code (it messes up my settings). However if you really want to know how, just close SolidWorks and run the code again. It should open SolidWorks. Beware though, you cannot just close SolidWorks, you will have to add code to your program to do that otherwise, the window will close the SolidWorks will remain in memory. You use swApp.ExitApp to do that. You have exhausted my knowledge on VB.Net. Look in API help there are several discussions. Do a search for VB.Net.

As for opening a template, I will let you look around API help for awhile (good way to learn how to use API). Post another message if you cannot find how to do it.

SA
 
Toomey,

I recommend installing the SW Add-In Template. You have to have Visual Studio 2005. Go to this website (you'll have to log in to SolidWorks subscription services first):

Download this and install:
Visual Studio 2005 VB.Net Addin Template

You might need this on too (it's been a while):
SolidWorks 2006 API SDK

In Visual Studio 2005, start a new Project based off of that Add-In template. There is code there to draw a 3D box and sample code to make a Property Manager Style program/macro.

There are a couple other .NET examples at the website listed above as well.

Ken
 
With regard to the DB, I have a form that is interacting with the database. Comboboxes are populated with filtered or sorted results, and things of that nature. I was unaware that VBA supported any of this, but either way wish to keep the program with the form as is in an external app.

I have tried working with the template recommended by KenBolen. I currently have opened a new project with it, but VB is showing errors. "Type 'ICommandManager' not defined". Any thoughts?
 
Does anyone know if the Add-in Template discussed above works with Visual Studio 2005 Express Edition?

When I try to start a project using the SolidWorks Addin template I get the following error message:

"Error HRESULT E_FAIL has been returned from a call to a COM component."

Has anyone else experienced this error message?
 
I was told by someone else that attended SWW2007 that they heard that the Add-In would not work with VS2005Express. I have not tried that myself.

Ken
 
I think (if I recall correctly) if you'll check the specifications for VS express they state explicitly that add-ins cannot be created with VSE.
 
Handleman, I took your advice and checked the VS site and you are absolutely correct. It takes at least VS Standard to write add-ins.

Thanks for the help.
 
No problem. I was disappointed too, by the way. At least until I realized that it also requires XP SP2 and our iron age IT dept still has us on SP1.
 
Status
Not open for further replies.
Back
Top