×
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

How save datas using macro(API)?

How save datas using macro(API)?

How save datas using macro(API)?

(OP)
Welcome,
Does anybody know how save in simply text file some datas(for exemple: Selected Edge,Center of selected surface, or Area of selected surface) from part created in Solidworks using macro(API)?

RE: How save datas using macro(API)?

PKaruzel,

See the Open statement in VBA help.

SA

RE: How save datas using macro(API)?

Are you asking how to save data that you have already found, or are you asking first how to find that data and then how to save it?  Writing output to a text file is rather simple.  Getting the data you want from SolidWorks can be more complicated.

RE: How save datas using macro(API)?

(OP)
I mean my problem concerning second part of your question. I want to create macro,where after clicking button in window I will choose some surfaces in part created in Solidworks.Next this macro will write info about kind of surface which was selected,the center of selected surface,area, normal to this surface,root in text file.
I have to add that I'm beginner in VBA.
Thanks for any help!

RE: How save datas using macro(API)?

Try going to the Main Menu/Help/SolidWorks and Add-Ins API Help Topics/Contents (tab)/SolidWorks API Help/Examples and Projects/Visual Basic (VB) Examples/R - T/Selections/... There are some example macros there that could help you get started.

You can also try looking in the Main Menu/<same as above>/Visual Basic (VB) Examples/L - Q/Mass Properties/... section.

For creating Text files, you'll have to use the VB Help. Try looking up Open, Input, or Line Input for some examples. If you don't have any luck then try searching the Internet for 'How to create text files from Excel VBA'. There are a lot more Excel examples available than SolidWorks about how to do non-SolidWorks specific tasks with VBA. You should be able to copy and paste most of that example code directly into a SolidWorks macro.

Ken

RE: How save datas using macro(API)?

A member whose handle is Picia did a lot of work that sounds similar to what you're trying to do.  You may want to read through all his threads here.  There's quite a bit of code in them.  You can see a list of all his threads and posts at:

http://www.eng-tips.com/userinfo.cfm?member=picia

Good luck!

RE: How save datas using macro(API)?

You can use KenBolen's suggestions for finding out how to obtain the entity data from within SolidWorks.

To create the text file, look up how to use "FileSystemObject" on the web.  Here's a start:

http://www.devguru.com/technologies/vbscript/quickref/filesystemobject.html

You will have to add the library "Microsoft Scripting Runtime" under References to get the FSO object to become available.

RE: How save datas using macro(API)?

Thanks handleman,
Your macro you showed picia is just what I need for a future project. Saved me a lot of work. A star for you.

Bradley
SolidWorks Premim 2007 x64 SP3.1
PDM Works, Intel(R) Pentium(R) D CPU
3.00 GHz, 4 GB RAM, Virtual memory 12577 MB, nVidia 3400

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