SolidWorks Secondary Development - 01- Recording a macro

xiaoxiao2021-03-05  21

SolidWorks Secondary Development - 01- Recording a macro

first step:

We need to record a macro itself, then look at what code produces. It was doing this at the time of studying Excel. Just, SolidWorks must be complex, and the macro recorded directly cannot be used, you need to do some adjustments. We'd better do it in accordance with the following recommendations when there is no experience.

Edit Or Debug SolidWorks Macro

Edit Or Debug SolidWorks Macros Using Microsoft VBA. Edit or debug macro 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 is automatically opened after the record macro is completed.

IF you recently edited the macro, you can select it from the menu when you click the menu lists the last nine macros that you edited.

Macro has been edited, and there will be the most close nine macro sequence list in the menu.

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 Macro Files. When You Run or Edit a.swb file , IT IS Automatic Converted to a .swp file. The old macro file suffix is ​​SWB, you can also open SWB, so 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 Extra Lines of Code: Delete some extra code:

The Following Variables Are Declared Automatical IN A SolidWorks Macro. Delete any variables not buy in the macro. These objects are automatically generated, which can be deleted without use

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 ObjectDelete all lines of code that change the view of code attempted to delete switching Translator's Note: Part.activeView (). RotateaboutCenter 0.0662574, 0.0346621 ruthless deletion

Delete all ModelDocExtension :: SelectByID2 calls appearing immediately before ModelDoc2 :: ClearSelection2 calls. However, do not delete ModelDocExtension :: SelectByID2 calls appearing immediately after ModelDoc2 :: ClearSelection2 calls.

Delete All Modeldoc2 :: CLEARSELECTION2 CALLS APPEARING IMMEDITELY Before ModelDoceXtension :: selectbyid2.

转载请注明原文地址:https://www.9cbs.com/read-39289.html

New Post(0)