×
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!

*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

I am interested in writing a macro

I am interested in writing a macro

I am interested in writing a macro

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

RE: I am interested in writing a macro

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

RE: I am interested in writing a macro

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.

RE: I am interested in writing a macro

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!

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! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close