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:
- 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.
- 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.
- Edit or debug the Macro. If it is a new macro, be sure to: if it is a new macro
Delete all modeldoc2: clearselection2 callappearing immediately before modeldocextension: selectbyid2.