|
||||||||||||||||||||
![]() |
||||||||||||||||||||
|
|
||||||||||||||||||||
| Send to a friend | ||||||||||||||||||||
|
How to automate repetitive tasks using a Show/Hide Reference Macro
|
|
|||||||||||||
|
The Show/Hide Reference Macro is a good example of how VBA (Visual Basic® for Applications) can automate repetitive tasks within a 3D CAD environment. This example demonstrates the steps required to create the SolidWorks® software macro (.swp) file. The purpose of this example is to toggle between two versions of the same design, one with and the other without Reference Geometry. This saves selecting each type of entity within the View menu. This is an example of the type of simple automation that can be done with little or no programming experience.
One method you could use to create both simple macros and more complex VB (Visual Basic) applications is to use the macro recorder to define the syntax of the API (Application Programming Interface). Instead of creating macros and programs from scratch, it is a timesaver to record a section and reuse that segment in another program. For this example, we will create the entire macro using the record function. Create Hide.swp:
The final macro code created is shown below.
One addition to this application would be a comment as to the function and date the macro was created. To add a comment, edit the macro and add the line as shown below. Edit the macro and re-run the display macro. Edit Hide.swp:
Once this macro has been recorded, you can attach the macro to a button using the customize function. This allows you to toggle the display state of reference geometry with one click. It is typically a good idea to share a common macro directory located on a server within your company. That way other designers and engineers can reuse the same time-saving macros and VB applications. |
|
|||||||||||||
|
|
||||
|
SolidWorks.com |
SolidWorks
Corporation - 300 Baker Avenue Concord, MA 01742 Phone: 800-693-9000 International: +978-371-5000 Copyright © 2001 SolidWorks Corporation. |
|||