Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am interested in writing a macro

Status
Not open for further replies.

13

Mechanical
Nov 24, 1999
59
I am interested in writing a macro for SolidWorks and I
dont know if it has been done yet. If anybody has any leads, please
let me know!

It would take an excel spreadsheet, with a format:

Name Part Number Description Date created Material Finish Notes
--- --- --- --- --- --- ---

etc....

And then the macro would open a specific drawing format and load it up
with all the info from the excel spreadsheet. It would take each "note" and place it
into its respective x and y location on the template.
I think this would save a LOT of unnecessary clicking.

Regards

 
Replies continue below

Recommended for you

Darn! I just posted an additional question to this post in the General engineering computer programs discussion.

Hey 13,
Please post your reply in the SolidWorks products forum so that other users can benefit from the post.

Thx, TC
 
This was the reply from 13 in a duplicate post. I figured that I will leave it here for other SolidWorks users.

I would like the macro to run from solidworks, not excel. i have ms visual studio c++ and also the limited capability in solidworks visual basic. what i would like the program to do is this:
1. open solidworks.
2. run the macro.
3. input excel file that contains all the part info
4. then the data from the excel file(say there are 10 parts w/ all pertinent info) would be used to generate drawings for each line in the excel file, or each part in this case there would be 10 drawings generated.
5. also (this would be great but not necessary) if the views associated with each part are inserted into the drawing--top front side or whatever.  and then the drawing would autosave as the part filename.
6. the program would loop until all the drawings were created with each part info inserted in x and y locations on the template.  maybe in the excel file there would be a drawing size variable. that way i could decide which template to use for which drawing, depending on part size. i also realize that this would increase the array quite a bit.
7. once the program finished it would allow me to dimension everything--i feel that this should be the engineers job.
this would save a tremendous amount of time for the kind of work i do.
 
I do not think you can do this the way you describe. Since you can not run a macro without having SolidWorks running, there is no need to open another instance of it programmatically. Another problem is that the SolidWorks VBA editor does not allow you to add additional references, such as the Excel Object Library, which is needed to control Excel.

I have also found that the SolidWorks programming interface is quite limited. When recording macros, some of the actions are not translated, or they are translated incorrectly. On the other hand, the SolidWorks API is quite extensive and can be used by common applications like Excel and Word, without having to buy additional language software.

Here are a couple of possible solutions.

1. If you want to use VB, write the program with the Excel VBA editor. You can add the SolidWorks Object Library to the references. This will enable you to control SolidWorks, using the same commands as the SolidWorks VBA editor. Then, the engineer only has to open the Excel file, type in the info, push a button and let the program do the rest.

2. If you know C++, use it. The API documentation includes functions in both VB and C++. You can easily create a front end to gather the data, fire up SolidWorks and take care of business.

I have been using VB extensively to automate SolidWorks. I have already created applications that have turned 80 hour design projects into 4 hour projects. This includes automating 3-D part design, assemblies configurations, drawings and BOMs. I have even written an application that generates the CNC code to manufacture the part.

Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor