SolidWorks two times development -01-record a macro

Source: Internet
Author: User
Tags variables
SolidWorks two times development -01-record a macro
First step:

We need to record a macro ourselves and then see what code the program produces. That's what I did when I was learning Excel. Just, SolidWorks to be more complex, directly recorded macros can not be used, need to make some adjustments. In the absence of experience we'd better follow the advice below.

Edit or Debug SolidWorks Macro







Edit or debug SolidWorks macros using Microsoft VBA. Edit or Debug macros using Microsoft VBA



To edit or debug a SolidWorks macro:


Click edit Macro on the Macro toolbar, or click Tools, Macro, edit.


NOTES: Note:


To automatically edit a macro after recording it, click Tools, Options, Systems options. On the General tab, select Automatically edit macro after recording and click OK. This setting is persistent across SolidWorks sessions.
This option automatically edit macro after recording, as the name suggests, automatically opens the editing interface after the recording macro is completed.


If you are recently edited the macro, you can select it from the menu as you click Tools, macro. This menu lists the last nine macros to you edited.
A macro has been edited, and the menu will have the most recent list of 9 macro programs to choose from.
In the dialog box, select a macro file (. swp) and click Open. Select a macro SWP file

Note:you can also edit. swb files, which are Older-style SolidWorks files. When you run or edit a. swb file, it's automatically converted to a. swp file. The old macro file suffix is SWB, you can also open SWB, then automatically save as SWP.

Edit or debug the macro. If it is a new macro, being sure to: if the macro

Delete extra lines of code: remove some extra codes:

The following variables are declared automatically SolidWorks in a macro. Delete any variables not used in the macro. The declarations of these objects are generated automatically, and you can delete the Dim Swapp as object with no use

Dim part as Object

Dim Boolstatus as Boolean

Dim Longstatus as Long, longwarnings as Long

Dim Featuredata as Object

Dim Feature as Object

Dim Component as Object

Delete All lines of code this change the view. Remove the code to switch attempts
Translator Note: A part.activeview like this (). Rotateaboutcenter 0.0662574, 0.0346621 ruthless erase it
Delete all MODELDOCEXTENSION::SELECTBYID2 calls appearing immediately before Modeldoc2::clearselection2. However, don't delete Modeldocextension::selectbyid2 calls appearing immediately after Modeldoc2::clearselection2 calls .


Delete all Modeldoc2::clearselection2 calls appearing immediately before Modeldocextension::selectbyid2.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.