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.
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
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
RE: First attempt VB.net with Solidworks
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
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:/
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
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
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
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
Ken
RE: First attempt VB.net with Solidworks
RE: First attempt VB.net with Solidworks
Thanks for the help.
RE: First attempt VB.net with Solidworks