Secondary Development of SolidWorks-01-recording a macro

Source: Internet
Author: User
Secondary Development of SolidWorks-01-recording a macro

Step 1:

We need to record a macro and then see what code the program generates. This is what I did when I first studied Excel. However, SolidWorks needs to be more complex and the directly recorded macros cannot be used. Some adjustments are required. When we have no experience, we 'd better follow the suggestions below.

 Edit or debug SolidWorks macro

 

Edit or debug SolidWorks macros using Microsoft VBA. Use Microsoft VBA to edit or debug macros

To edit or debug a SolidWorks macro:

  1. ClickEdit macroOn the macro toolbar, or clickTools,Macro,Edit.

Notes:Note:

    • To automatically edit a macro after recording it, clickTools,Options,Systems Options. OnGeneralTab, selectAutomatically edit macro after recordingAnd clickOK. This setting is persistent internal SS SolidWorks sessions.

This optionAutomatically edit macro after recordingAs the name implies, the editing page is automatically opened after the record macro is completed.

    • If you recently edited the macro, you can select it from the menu when you clickTools,Macro. This menu lists the last nine macros that you edited.

You have edited macros. The menu contains the last nine macro sequence tables for selection.

  1. In the dialog box, select a macro file (. SWP) And clickOpen. Select a macro SWP File

    Note:You can also edit. SWBFiles, which are older-style SolidWorks macro files. When you run or edit.SWBFile, it is automatically converted to. SWPFile. The old Macro file is suffixed with SWB. You can enable SWB and it will be automatically saved as SWP.

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

    • Delete extra lines of code: Delete unnecessary code:

      • The following variables are declared automatically in a SolidWorks Macro. delete any variables not used in the macro. These object declarations are automatically generated and useless deletions can be made.
        • Dim swapp as object

        • 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 that change the view. Delete the code to be switched

      Note: part. activeview (). rotateaboutcenter 0.0662574 and 0.0346621 will be deleted relentlessly.

      • Delete all modeldocextension: Export CILS appearing immediately before modeldoc2: clearselection2 CILS. However, do not delete modeldocextension: Export CILS appearing immediately after modeldoc2: clearselection2 CILS.

Delete all modeldoc2: clearselection2 callappearing 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.