×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

First attempt VB.net with Solidworks

First attempt VB.net with Solidworks

First attempt VB.net with Solidworks

(OP)
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.

RE: First attempt VB.net with Solidworks

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

http://www.savefile.com/files/574514

RE: First attempt VB.net with Solidworks

(OP)
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?

RE: First attempt VB.net with Solidworks

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

RE: First attempt VB.net with Solidworks

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):
http://www.solidworks.com/pages/services/APIDownloads.html?pid=121

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

RE: First attempt VB.net with Solidworks

Quote:


I need to use the standalone as I have a built in database, and VBA does not support that.

What do you mean by "built in database"?  I have a few macros that access mdb and dbf files using DAO and/or ADO in VBA.

RE: First attempt VB.net with Solidworks

(OP)
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?

RE: First attempt VB.net with Solidworks

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?

RE: First attempt VB.net with Solidworks

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

RE: First attempt VB.net with Solidworks

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.

RE: First attempt VB.net with Solidworks

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.

RE: First attempt VB.net with Solidworks

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources