Install
openclaw skills install zw3d-macroCreate, edit, validate, and execute ZW3D CAD macro files (.mac). Use when the user needs to write ZW3D macros, convert operations to macro syntax, debug macro issues, generate macro templates, or perform CAD operations in ZW3D through macros. Special triggers - (1) "在 ZW3D 里做 xxx" means write macro for operation xxx then run it in ZW3D; (2) "修改之前的模型" means open existing file and modify parameters (NOT create new file). Supports basic statements, control structures (IF/WHILE/BUFFER), variable assignments, function calls, baseline testing commands, sketch operations, feature creation (extrude, fillet, pattern), and UDF workflows.
openclaw skills install zw3d-macroThis skill helps create and edit ZW3D CAD macro files for automation and testing.
vxConfigDefault and vxConfigRestore.mac extensionUser convention #1: When the user says "在 ZW3D 运行宏" (run macro in ZW3D), it means opening the macro file directly with ZW3D executable:
Start-Process "zw3d.exe" "path/to/macro.mac"
This launches ZW3D and automatically executes the macro, rather than using ZW3D's internal Macro menu.
User convention #2: When the user says "在 ZW3D 里做 xxx" (do xxx in ZW3D), it means:
Example workflow:
User convention #3: When the user says "修改之前的模型" (modify the previous model), it means:
$CdFileNew)$CdFileOpen or !CdFileOpen2) to load the previous modelExample workflow:
Editing Features via History Manager: When selecting features in the history manager, note that the first number in the parentheses starts from 1 (流水号).
For example, if the history tree contains:
Then:
(1,1) - Default coordinate system(2,1) - Block feature(3,1) - Fillet featureExample to select and edit the block feature (which is the 2nd item):
[vxSendEvt,"UiHistoryManager",220,(2,1),25,4] # Select block feature
[vxSendEvt,"UiHistoryManager",220,(2,1),4,4] # Activate edit
[vxSend,"$CdHistEdit"] # Enter edit mode
# Author -用户名
# Date - Thu Jan 01 00:00:00 2026
# Version - 28
# Description - 宏描述
MACRO main
[QaBlVersion,1]
[vxBuildDate,01/01/2026]
[vxConfigDefault,2800]
# 宏主体
[vxSend,"$CdFileNew"]
[vxConfigRestore]
ENDMACRO
When creating a new file, provide a filename that matches the macro name:
[vxSend,"$CdFileNew"]
[vxFormInitGlbl,UiFileNew,"89,1"]
[vxSendEvt,"UiFileNew",1,1,7,"FileNamexxx"] # Set filename (without extension)
[vxSendEvt,"UiFileNew",-1,0,0] # Confirm
Note: The filename should match the macro file name for consistency. For example, if the macro is create_block_100x100x100.mac, the filename should be create_block_100x100x100.
When working with large base plates or models (>1m), extend the view range before sketching:
# After file creation, extend view range to 2000mm
[vxSend,"$SF=UiViewExt"]
[vxSendEvt,"UiViewExt",100,1,7,"2000"]
[vxSendEvt,"UiViewExt",-1,0,0]
100,1,7,"2000" - Sets view range to 2000mm"3000" for 3m models)| Statement | Purpose | Example |
|---|---|---|
vxSend | Send command | [vxSend,"$CdFileNew"] |
vxSendEvt | Send UI event | [vxSendEvt,"UiFileNew",-1,0,0] |
vxSendEvtOpt | Send option (OK/Cancel) | [vxSendEvtOpt,-1,0,1,2] |
vxFormEvtOpt | Form option event | [vxFormEvtOpt,"FtFillet2",-1,0,1,2] |
vxSendOptFocus | Set focus | [vxSendOptFocus,2,0] |
vxInitCmd | Init command params | [vxInitCmd,FtAllBox,<14,0><8,0>] |
vxFormInitGlbl | Init form params | [vxFormInitGlbl,UiFileNew,"89,1"] |
vxViewSet2 | Set view | [vxViewSet2,1,0,0,0,1,0...] |
# Left mouse button
[vxSend,"*0,0,0,LMB_DN"] # Press
[vxSend,"*100,50,0,LMB_UP"] # Release
# Drag operations
[vxSend,"*50,25,0,DRAG"] # Drag
# Middle mouse button (view rotation)
[vxSend,"*0,0,0,MMB_DN"]
[vxSend,"*10,10,0,MMB_UP"]
IF-ELSEIF-ELSE-ENDIF:
IF (condition)
statements
ELSEIF (condition)
statements
ELSE
statements
ENDIF
WHILE-ENDWHILE:
WHILE (condition)
statements
ENDWHILE
BUFFER-ENDBUFFER:
BUFFER
[vxSend,"!CdFileOpen2"]
[vxSend,"PartA.Z3PRT"]
ENDBUFFER
# Variable assignment
NUMBER1 = 5
SUM = NUMBER1 + NUMBER2
# Function call
FUNCTION cnt = QaFnHistCnt()
FUNCTION redefine = QaFnHistCanInfomRedefine(item)
[DebugOn] # Enable step-by-step debugging
+[vxSend,"$CdFileNew"] # Breakpoint on single line
[QaAllowRetry] # Allow one command failure
[QaExpectError] # Expect an error (must precede error line)
[QaOutBary,0] # Output wireframe barycenter
[QaOutEntCnt,1] # Output entity count
[QaOutHist] # Output history
| Command | Type | Description |
|---|---|---|
$CdFileNew | GUI | New file |
$CdFileOpen | GUI | Open file |
!CdFileOpen2 | Template | Open file (template) |
~CdUDFDelete | Special | Delete UDF |
| Command | Type | Description |
|---|---|---|
!CdProfNew | Template | New sketch |
!WrCrRects | Template | Draw rectangle |
!WrCrNgons | Template | Draw polygon |
!FtAllBox | Template | Create box |
!FtAllExt | Template | Extrude feature |
!FtFillet2 | Template | Fillet (圆角) |
!FtChamfers2 | Template | Chamfer (倒角) |
!FtPtnFtr | Template | Pattern feature |
$CdEditParent | GUI | Edit parent feature |
Correct format for creating a new sketch:
[vxSend,"!CdProfNew"]
[vxInitCmd,CdMatInpSk,<4,0><19,0><11,0><6,1><5,0>]
BUFFER
[vxSendEvtOpt,-1,0,1,2] # Ok
ENDBUFFER
Correct format for exiting a sketch:
[vxSend,"$CdEditParent"]
Correct format for drawing a polygon (e.g., hexagon):
[vxSend,"!WrCrNgons"]
[vxInitCmd,WrCrNgons,<15,0><2,10><8,10><3,6>]
[vxSendEvtOpt,1,0,1,6,"0,0<mm>"] # Center point
[vxSendOptFocus,2,0] # Focus on radius field
[vxSendEvtOpt,2,0,1,6,"8.5"] # Set radius
[vxSendEvtOpt,-1,0,1,2] # Ok
| Command | Type | Description |
|---|---|---|
~CdUDFWizardShow | Special | UDF wizard |
~CdUDFInsShow | Special | Insert UDF |
UiUDFWizard | UI | UDF wizard UI |
UiUDFWizardFtr | UI | UDF feature selection |
UiUDFIns | UI | UDF insert UI |
Correct format for selecting a sketch from history manager before extrusion:
[vxSendEvt,"UiHistoryManager",220,(2,1),14,4] # Select sketch (2nd item in history)
[vxSendEvt,"UiHistoryManager",220,(2,1),2,4] # Activate for feature operation
(2,1) - Refers to the 2nd item in history tree (the sketch)14,4 - Select/highlight the feature2,4 - Activate the feature for subsequent operations (extrude, etc.)Note: Always select the sketch from history manager before using !FtAllExt for extrusion.
| Command | Description |
|---|---|
UiHistoryManager | History manager |
UiManager | UI manager |
UiInputManager | Input manager |
Setting View Range (for large models): When working with large base plates or models, extend the view range before sketching:
[vxSend,"$SF=UiViewExt"]
[vxSendEvt,"UiViewExt",100,1,7,"2000"]
[vxSendEvt,"UiViewExt",-1,0,0]
100,1,7,"2000" - Sets view range to 2000mm"3000" for 3m models)[vxConfigRestore] before ENDMACRO - missing this affects other macrosvxInitCmd, vxFormInitGlbl, QaAllowRetry execute one line earlier than writtenvxSend statements in BUFFER get wrapped as FormCommand[QaBlVersion,1]$=GUI, !=Template, ~=Special<8,0> - Corner type, <8,1> - Center typeCombine Method Options:
[vxSendEvtOpt,14,0,1,2] # Base body (基体)
[vxSendEvtOpt,14,0,2,2] # Boolean Add (布尔加)
[vxSendEvtOpt,14,0,3,2] # Boolean Subtract (布尔减)
Setting Dimensions (Length/Width/Height):
[vxSendOptFocus,3,0] # Focus on Length field
[vxSendEvtOpt,3,0,1,6,"100"] # Set Length = 100
[vxSendEvtOpt,3,0,-1,6,"100"] # Confirm Length
[vxSendOptFocus,4,0] # Focus on Width field
[vxSendEvtOpt,4,0,1,6,"100"] # Set Width = 100
[vxSendEvtOpt,4,0,-1,6,"100"] # Confirm Width
[vxSendOptFocus,5,0] # Focus on Height field
[vxSendEvtOpt,5,0,1,6,"100"] # Set Height = 100
[vxSendEvtOpt,5,0,-1,6,"100"] # Confirm Height
<2,0> - Direction, <3,15> - Depth<6,0.5> - Radius, <16,3> - Edge select modeFillet Workflow:
[vxSend,"!FtFillet2"]
[vxInitCmd,FtFillet2,<30,0><42,0><3,0><7,0><48,0><6,10><23,10><44,0><5,0><27,0><35,0><28,0><24,0><21,0><16,3><17,2><46,1><47,1><57,1>]
[vxInitCmd,FtFlltEdgSet,<2,5><22,0><6,0>]
# Select edges
[vxSend,"*50,50,50,LMB_DN"]
[vxSend,"*50,50,50,LMB_UP"]
# Confirm fillet
[vxFormEvtOpt,"FtFillet2",-1,0,1,2]
<95,5> - Chamfer type, <23,10> - Distance/Angle mode<41,3> - Edge select modeChamfer Workflow (Manual Edge Selection):
[vxSend,"!FtChamfers2"]
[vxInitCmd,FtChamfers2,<30,0><42,0><93,0><95,5><5,0><44,0><27,0><35,0><88,0><28,0><24,0><21,0><23,10><41,3><16,3><17,2><53,0>]
[vxInitCmd,FtChamEdgSet,<2,5><4,45><5,20><22,0><6,0>]
# Switch to edge selection mode
[vxSendEvtOpt,1,2,1,2]
# Select edges (or use more pick for multiple)
[vxSend,"*50,50,50,LMB_DN"]
[vxSend,"*50,50,50,LMB_UP"]
# Confirm chamfer
[vxFormEvtOpt,"FtChamfers2",-1,0,1,2]
Chamfer Workflow (Automatic Edge Selection - Recommended):
[vxSend,"!FtChamfers2"]
[vxInitCmd,FtChamfers2,<30,0><42,0><93,0><95,5><5,0><44,0><27,0><35,0><88,0><28,0><24,0><21,0><23,10><41,3><16,3><17,2><53,0>]
# Chamfer
[vxInitCmd,FtChamEdgSet,<2,2><4,45><5,2><22,0><6,0>]
[vxSend,"~CdFiMorePick"] # Auto-select all available edges
[vxFormEvtOpt,"FtChamfers2",-1,0,1,2] # Ok
FtChamEdgSet Parameters:
<2,5> - Edge set type (manual), <2,2> - Edge set type (auto)<4,45> - Angle (45 degrees)<5,20> - Distance (20mm)<22,0> - Symmetric mode<6,0> - Additional optionsTip: Use ~CdFiMorePick for automatic edge selection when chamfering all hole edges or similar features.
<3,2> - Circular pattern, <3,3> - Linear pattern<4,20> - Count, <12,45> - Angle/SpacingThis SKILL.md contains comprehensive macro examples embedded directly in the documentation. See the sections below for:
A basic template is also available: assets/macro_template.txt
The table example demonstrates a complete workflow:
Key techniques:
PntDirZ for direction control in extrusionThe base plate example demonstrates creating a large rectangular base (1170×1150×30mm):
# Author - Jarvis
# Date - Mon Mar 30 11:23:00 2026
# Version - 28
# Description - 创建底座 1170x1150x30mm
MACRO main
[QaBlVersion,1]
[vxBuildDate,03/30/2026]
[vxConfigDefault,2800]
[vxSend,"$CdFileNew"]
[vxFormInitGlbl,UiFileNew,"89,1"]
[vxSendEvt,"UiFileNew",1,1,7,"base_1170x1150"]
[vxSendEvt,"UiFileNew",-1,0,0]
# 创建草图
[vxSend,"!CdProfNew"]
[vxInitCmd,CdMatInpSk,<4,0><19,0><11,0><6,1><5,0>]
BUFFER
[vxSendEvtOpt,-1,0,1,2]
ENDBUFFER
# 绘制矩形 (1170x1150) - 使用中心点模式
[vxSend,"!WrCrRects"]
[vxInitCmd,WrCrRects,<15,1>]
[vxSendEvtOpt,1,0,1,6,"-585,-575<mm>"] # 中心点坐标 (-L/2, -W/2)
[vxSendOptFocus,5,0]
[vxSendEvtOpt,5,0,1,6,"1170"] # 宽度
[vxSendOptFocus,6,0]
[vxSendEvtOpt,6,0,1,6,"1150"] # 高度
[vxSendEvtOpt,-1,0,1,2]
# 退出草图
[vxSend,"$CdEditParent"]
# 选择草图 (历史管理器中第 2 项)
[vxSendEvt,"UiHistoryManager",220,(2,1),14,4] # 选中草图
[vxSendEvt,"UiHistoryManager",220,(2,1),2,4] # 激活
# 拉伸特征 (高度 30mm)
[vxSend,"!FtAllExt"]
[vxInitCmd,FtAllExt,<30,0><42,0><2,0><3,15><5,0><44,0><27,0><35,0><28,0><24,0><21,0>]
[vxSendOptFocus,5,0]
[vxSendEvtOpt,5,0,1,6,"30"] # 拉伸深度
[vxSendEvtOpt,-1,0,1,2]
[vxConfigRestore]
ENDMACRO
Key techniques:
<15,1> - Center point mode for rectangle (vs <15,0> for corner mode)(-L/2, -W/2) to center the rectangle at origin(2,1) refers to the sketch (2nd item in history)!FtAllExt for extrusion with depth parameter <3,15> and focus on field 5Important notes:
UiHistoryManager events(2,1) is the history item number (流水号), starting from 1$CdEditParent to exit sketch mode before selecting and extrudingThis example demonstrates creating a 100×100×100mm cube with fillets on all 12 edges:
# Author - Jarvis
# Date - Mon Mar 30 14:02:00 2026
# Version - 28
# Description - 创建 100x100x100 方块 + 所有边圆角
MACRO main
[QaBlVersion,1]
[vxBuildDate,03/30/2026]
[vxConfigDefault,2800]
[vxSend,"$CdFileNew"]
[vxFormInitGlbl,UiFileNew,"89,1"]
[vxSendEvt,"UiFileNew",1,1,7,"block_100x100x100"]
[vxSendEvt,"UiFileNew",-1,0,0]
# 创建草图
[vxSend,"!CdProfNew"]
[vxInitCmd,CdMatInpSk,<4,0><19,0><11,0><6,1><5,0>]
BUFFER
[vxSendEvtOpt,-1,0,1,2]
ENDBUFFER
# 绘制矩形 (100x100) - 使用中心点模式
[vxSend,"!WrCrRects"]
[vxInitCmd,WrCrRects,<15,1>]
[vxSendEvtOpt,1,0,1,6,"-50,-50<mm>"]
[vxSendOptFocus,5,0]
[vxSendEvtOpt,5,0,1,6,"100"]
[vxSendOptFocus,6,0]
[vxSendEvtOpt,6,0,1,6,"100"]
[vxSendEvtOpt,-1,0,1,2]
# 退出草图
[vxSend,"$CdEditParent"]
# 选择草图 (历史管理器中第 2 项)
[vxSendEvt,"UiHistoryManager",220,(2,1),14,4]
[vxSendEvt,"UiHistoryManager",220,(2,1),2,4]
# 拉伸特征 (高度 100mm)
[vxSend,"!FtAllExt"]
[vxInitCmd,FtAllExt,<30,0><42,0><2,0><3,15><5,0><44,0><27,0><35,0><28,0><24,0><21,0>]
[vxSendOptFocus,3,0]
[vxSendEvtOpt,3,0,1,6,"100"]
[vxSendEvtOpt,-1,0,1,2]
# 添加圆角 - 所有 12 条边
[vxSend,"!FtFillet2"]
[vxInitCmd,FtFillet2,<30,0><42,0><3,0><7,0><48,0><6,5><23,10><44,0><5,0><27,0><35,0><28,0><24,0><21,0><16,3><17,2><46,1><47,1><57,1>]
[vxInitCmd,FtFlltEdgSet,<2,5><22,0><6,0>]
# 选择所有边 - 方块的 12 条边
# 底面四条边 (Z=0)
[vxSend,"*-50,-50,0,LMB_DN"]
[vxSend,"*-50,-50,0,LMB_UP"]
[vxSend,"*50,-50,0,LMB_DN"]
[vxSend,"*50,-50,0,LMB_UP"]
[vxSend,"*50,50,0,LMB_DN"]
[vxSend,"*50,50,0,LMB_UP"]
[vxSend,"*-50,50,0,LMB_DN"]
[vxSend,"*-50,50,0,LMB_UP"]
# 顶面四条边 (Z=100)
[vxSend,"*-50,-50,100,LMB_DN"]
[vxSend,"*-50,-50,100,LMB_UP"]
[vxSend,"*50,-50,100,LMB_DN"]
[vxSend,"*50,-50,100,LMB_UP"]
[vxSend,"*50,50,100,LMB_DN"]
[vxSend,"*50,50,100,LMB_UP"]
[vxSend,"*-50,50,100,LMB_DN"]
[vxSend,"*-50,50,100,LMB_UP"]
# 垂直四条边 (Z=50 中点)
[vxSend,"*-50,-50,50,LMB_DN"]
[vxSend,"*-50,-50,50,LMB_UP"]
[vxSend,"*50,-50,50,LMB_DN"]
[vxSend,"*50,-50,50,LMB_UP"]
[vxSend,"*50,50,50,LMB_DN"]
[vxSend,"*50,50,50,LMB_UP"]
[vxSend,"*-50,50,50,LMB_DN"]
[vxSend,"*-50,50,50,LMB_UP"]
# 确认圆角
[vxFormEvtOpt,"FtFillet2",-1,0,1,2]
[vxConfigRestore]
ENDMACRO
Key techniques:
*-X,-Y,Z,LMB_DN/UP format for precise edge picking<6,5> parameter (5mm radius in this example)Important notes:
vxFormEvtOpt with form name "FtFillet2" to confirm the fillet operation<16,3> parameter sets edge selection mode to manual pick[vxSendEvtOpt,2,0,1,6,"50"] to set radius (field 2)This example demonstrates creating a 300×300×300mm base with fillets on the 4 vertical edges only:
# Author - Jarvis
# Date - Mon Mar 30 14:10:00 2026
# Version - 28
# Description - 创建 300x300x300 基座 + 垂直边圆角
MACRO main
[QaBlVersion,1]
[vxBuildDate,03/30/2026]
[vxConfigDefault,2800]
[vxSend,"$CdFileNew"]
[vxFormInitGlbl,UiFileNew,"89,1"]
[vxSendEvt,"UiFileNew",1,1,7,"base_300x300x300"]
[vxSendEvt,"UiFileNew",-1,0,0]
# 创建草图
[vxSend,"!CdProfNew"]
[vxInitCmd,CdMatInpSk,<4,0><19,0><11,0><6,1><5,0>]
BUFFER
[vxSendEvtOpt,-1,0,1,2]
ENDBUFFER
# 绘制矩形 (300x300) - 使用中心点模式
[vxSend,"!WrCrRects"]
[vxInitCmd,WrCrRects,<15,1>]
[vxSendEvtOpt,1,0,1,6,"-150,-150<mm>"]
[vxSendOptFocus,5,0]
[vxSendEvtOpt,5,0,1,6,"300"]
[vxSendOptFocus,6,0]
[vxSendEvtOpt,6,0,1,6,"300"]
[vxSendEvtOpt,-1,0,1,2]
# 退出草图
[vxSend,"$CdEditParent"]
# 选择草图 (历史管理器中第 2 项)
[vxSendEvt,"UiHistoryManager",220,(2,1),14,4]
[vxSendEvt,"UiHistoryManager",220,(2,1),2,4]
# 拉伸特征 (高度 300mm)
[vxSend,"!FtAllExt"]
[vxInitCmd,FtAllExt,<30,0><42,0><2,0><3,15><5,0><44,0><27,0><35,0><28,0><24,0><21,0>]
[vxSendOptFocus,3,0]
[vxSendEvtOpt,3,0,1,6,"300"]
[vxSendEvtOpt,-1,0,1,2]
# 添加圆角 - 仅垂直的 4 条边
[vxSend,"!FtFillet2"]
[vxInitCmd,FtFillet2,<30,0><42,0><3,0><7,0><48,0><6,50><23,10><44,0><5,0><27,0><35,0><28,0><24,0><21,0><16,3><17,2><46,1><47,1><57,1>]
[vxInitCmd,FtFlltEdgSet,<2,5><22,0><6,0>]
# 设置圆角半径
[vxSendEvtOpt,2,0,1,6,"50"] # Radius R
# 选择垂直 4 条边 (Z=150 中点)
[vxSend,"*-150,-150,150,LMB_DN"]
[vxSend,"*-150,-150,150,LMB_UP"]
[vxSend,"*150,-150,150,LMB_DN"]
[vxSend,"*150,-150,150,LMB_UP"]
[vxSend,"*150,150,150,LMB_DN"]
[vxSend,"*150,150,150,LMB_UP"]
[vxSend,"*-150,150,150,LMB_DN"]
[vxSend,"*-150,150,150,LMB_UP"]
# 确认圆角
[vxFormEvtOpt,"FtFillet2",-1,0,1,2]
[vxConfigRestore]
ENDMACRO
Key techniques:
[vxSendEvtOpt,2,0,1,6,"50"] to set fillet radius on field 2Important notes:
vxSendEvtOpt on field 2 before or after edge selectionThis example demonstrates creating a threaded hole (M10 × 1.25) at the center of the top face:
# 在顶面中心创建螺纹孔 (M18 x 1.5)
[vxSend,"!FtHoleMain"]
[vxInitCmd,FtHoleMain,<6,2><21,0><121,0><25,16.5><27,34.5><29,15><31,5><33,90><70,10><23,0><55,118><94,30><95,0><110,1><10,0><75,1><16,1><11,0><61,1><40,1.5><41,0><168,1><63,27><167,1><73,1><72,0><74,1><101,0><102,0>]
# Create hole feature
[vxFormInitGlbl,FtHoleChamForm,"0, 0, 0.75, 45, 0, 0, 0, 0, 0, 0, 0.75, 45"]
[vxFormInitGlbl,FtHoleMParaForm,",0,0,0,0,0,0,0,1"]
[vxSendEvtOpt,6,0,3,2] # Hole type (threaded)
[vxFormInitGlbl,FtHoleThrdForm,"M,M18 x 1.5,1,18,27,1.5,0"]
[vxSendEvtOpt,3,0,1,6,"0,0,200<mm>"] # Location (use coordinate instead of mouse pick)
[vxSendEvt,"FtHoleThrdForm",165,45,2] # Select thread type
[vxSendEvtOpt,-1,0,1,2] # Ok
Important: Use vxSendEvtOpt,3,0,1,6,"X,Y,Z<mm>" to set hole location directly with coordinates instead of mouse picking. This is more reliable, especially for pattern arrays.
This example demonstrates creating a large diameter through hole (Ø200mm) at the center of the base plate:
# 创建中心主轴通孔 (直径 200mm)
[vxSend,"!FtHoleMain"]
[vxInitCmd,FtHoleMain,<6,1><21,0><121,0><25,10.5><27,34.5><29,15><31,5><33,90><70,10><23,0><55,118><94,30><95,0><110,1><10,0><75,1><16,1><11,0><61,1><40,1.5><41,0><168,1><63,-1e-06><167,1><73,1><72,0><74,1><101,0><102,0>]
# Create hole feature
[vxFormInitGlbl,FtHoleScrewForm,"ISO,General Screw Clearance,M10,Close"]
[vxFormInitGlbl,FtHoleChamForm,"0, 0, 0.6, 45, 0, 0, 0, 0, 0, 0, 0.6, 45"]
[vxFormInitGlbl,FtHoleMParaForm,",0,0,0,0,0,0,0,1"]
[vxSendEvtOpt,6,0,1,2] # Hole type
[vxSendEvtOpt,3,0,1,6,"0,0,335<mm>"] # Location (top face center)
[vxSendEvtOpt,3,0,-1,6,"0,0,335<mm>"] # Location (confirm)
[vxSendOptFocus,25,0] # Dia (D1)
[vxSendEvtOpt,25,0,1,6,"200"] # Dia (D1)
[vxSendOptFocus,27,0] # Depth (H1)
[vxSendEvtOpt,27,0,1,6,"335"] # Depth (H1)
[vxSendEvtOpt,-1,0,1,2] # Ok
Key techniques:
<6,1> sets counterbore hole type, <63,-1e-06> indicates through hole (negative micro value)FtHoleScrewForm with "ISO,General Screw Clearance,M10,Close" for clearance hole specification1,6, once with -1,6) to confirmvxSendEvtOpt,6,0,1,2 to select the hole type from dialogCommon hole types:
<vxInitCmd,FtHoleMain,<6,0>...] # Simple hole (简单孔)
<vxInitCmd,FtHoleMain,<6,1>...] # Counterbore hole (沉头孔)
<vxInitCmd,FtHoleMain,<6,2>...] # Threaded hole (螺纹孔)
Important notes:
<63,-1e-06>FtHoleScrewForm for clearance holes, FtHoleThrdForm for threaded holesThis example demonstrates creating four counterbore guide pin holes (R66.5mm) at the corners of a base plate with rounded corners:
# 四角沉头导柱孔 (半径 66.5mm)
# 导柱孔 1 - 左下角 (-468.5, -458.5) - 往原点偏移 66.5mm
[vxSend,"!FtHoleMain"]
[vxInitCmd,FtHoleMain,<6,1><21,0><121,0><25,66.5><27,34.5><29,15><31,5><33,90><70,10><23,0><55,118><94,30><95,0><110,1><10,0><75,1><16,1><11,0><61,1><40,1.5><41,0><168,1><63,-1e-06><167,1><73,1><72,0><74,1><101,0><102,0>]
[vxFormInitGlbl,FtHoleScrewForm,"ISO,General Screw Clearance,M10,Close"]
[vxFormInitGlbl,FtHoleChamForm,"0, 0, 0.6, 45, 0, 0, 0, 0, 0, 0, 0.6, 45"]
[vxFormInitGlbl,FtHoleMParaForm,",0,0,0,0,0,0,0,1"]
[vxSendEvtOpt,6,0,1,2]
[vxSendEvtOpt,3,0,1,6,"-468.5,-458.5,335<mm>"]
[vxSendEvtOpt,3,0,-1,6,"-468.5,-458.5,335<mm>"]
[vxSendOptFocus,25,0]
[vxSendEvtOpt,25,0,1,6,"133"] # Diameter (2 × radius)
[vxSendOptFocus,27,0]
[vxSendEvtOpt,27,0,1,6,"335"] # Depth (through hole)
[vxSendEvtOpt,-1,0,1,2]
# 导柱孔 2 - 右下角 (468.5, -458.5)
[vxSend,"!FtHoleMain"]
[vxInitCmd,FtHoleMain,<6,1>...<63,-1e-06>...] # Same parameters
[vxSendEvtOpt,3,0,1,6,"468.5,-458.5,335<mm>"]
[vxSendEvtOpt,3,0,-1,6,"468.5,-458.5,335<mm>"]
[vxSendEvtOpt,25,0,1,6,"133"]
[vxSendEvtOpt,27,0,1,6,"335"]
[vxSendEvtOpt,-1,0,1,2]
# 导柱孔 3 - 右上角 (468.5, 458.5)
# 导柱孔 4 - 左上角 (-468.5, 458.5)
Key techniques:
<6,1> (counterbore type) + <63,-1e-06> (through hole)Position calculation for corner holes:
Plate half-width: 1170 / 2 = 585mm
Plate half-height: 1150 / 2 = 575mm
Corner fillet: R120mm
Hole radius: R66.5mm
Edge distance: 50mm from edge (585 - 50 = 535, 575 - 50 = 525)
Offset by radius: 535 - 66.5 = 468.5, 525 - 66.5 = 458.5
Final positions: (±468.5, ±458.5)
Important notes:
This comprehensive example demonstrates creating a complete high-precision fixture base plate with all common features:
Specifications:
# Author - Jarvis
# Date - Tue Apr 07 11:57:00 2026
# Version - 28
# Description - 高精度工装夹具基板 1170x1150x335 + R120 圆角 + 中心主轴孔 + 四角导柱孔 + M18.5 螺纹孔阵列 + 2mm 倒角
MACRO main
[QaBlVersion,1]
[vxBuildDate,04/07/2026]
[vxConfigDefault,2800]
[vxSend,"$CdFileNew"]
[vxFormInitGlbl,UiFileNew,"89,1"]
[vxSendEvt,"UiFileNew",1,1,7,"fixture_base_1170x1150x335"]
[vxSendEvt,"UiFileNew",-1,0,0]
# 扩展视图范围到 2000 (重要!大型模型必须)
[vxSend,"$SF=UiViewExt"]
[vxSendEvt,"UiViewExt",100,1,7,"2000"]
[vxSendEvt,"UiViewExt",-1,0,0]
# ===== 步骤 1: 创建基板主体 =====
[vxSend,"!CdProfNew"]
[vxInitCmd,CdMatInpSk,<4,0><19,0><11,0><6,1><5,0>]
BUFFER
[vxSendEvtOpt,-1,0,1,2]
ENDBUFFER
# 绘制矩形 (1170x1150) - 使用中心点模式
[vxSend,"!WrCrRects"]
[vxInitCmd,WrCrRects,<15,1>]
[vxSendEvtOpt,1,0,1,6,"-585,-575<mm>"]
[vxSendOptFocus,5,0]
[vxSendEvtOpt,5,0,1,6,"1170"]
[vxSendOptFocus,6,0]
[vxSendEvtOpt,6,0,1,6,"1150"]
[vxSendEvtOpt,-1,0,1,2]
[vxSend,"$CdEditParent"]
# 选择草图并拉伸
[vxSendEvt,"UiHistoryManager",220,(2,1),14,4]
[vxSendEvt,"UiHistoryManager",220,(2,1),2,4]
[vxSend,"!FtAllExt"]
[vxInitCmd,FtAllExt,<30,0><42,0><2,0><3,15><5,0><44,0><27,0><35,0><28,0><24,0><21,0>]
[vxSendOptFocus,3,0]
[vxSendEvtOpt,3,0,1,6,"335"]
[vxSendEvtOpt,-1,0,1,2]
# ===== 步骤 2: 四角圆角 R120mm =====
[vxSend,"!FtFillet2"]
[vxInitCmd,FtFillet2,<30,0><42,0><3,0><7,0><48,0><6,120><23,10><44,0><5,0><27,0><35,0><28,0><24,0><21,0><16,3><17,2><46,1><47,1><57,1>]
[vxInitCmd,FtFlltEdgSet,<2,5><22,0><6,0>]
[vxSendEvtOpt,2,0,1,6,"120"]
# 选择 4 条垂直边
[vxSend,"*-585,-575,167.5,LMB_DN"]
[vxSend,"*-585,-575,167.5,LMB_UP"]
[vxSend,"*585,-575,167.5,LMB_DN"]
[vxSend,"*585,-575,167.5,LMB_UP"]
[vxSend,"*585,575,167.5,LMB_DN"]
[vxSend,"*585,575,167.5,LMB_UP"]
[vxSend,"*-585,575,167.5,LMB_DN"]
[vxSend,"*-585,575,167.5,LMB_UP"]
[vxFormEvtOpt,"FtFillet2",-1,0,1,2]
# ===== 步骤 3: 四角沉头导柱孔 (半径 66.5mm, 直径 133mm) =====
# 导柱孔位置计算:向原点偏移半径距离
# 左下角 (-468.5, -458.5)
[vxSend,"!FtHoleMain"]
[vxInitCmd,FtHoleMain,<6,1><21,0><121,0><25,66.5><27,34.5><29,15><31,5><33,90><70,10><23,0><55,118><94,30><95,0><110,1><10,0><75,1><16,1><11,0><61,1><40,1.5><41,0><168,1><63,-1e-06><167,1><73,1><72,0><74,1><101,0><102,0>]
[vxFormInitGlbl,FtHoleScrewForm,"ISO,General Screw Clearance,M10,Close"]
[vxFormInitGlbl,FtHoleChamForm,"0, 0, 0.6, 45, 0, 0, 0, 0, 0, 0, 0.6, 45"]
[vxFormInitGlbl,FtHoleMParaForm,",0,0,0,0,0,0,0,1"]
[vxSendEvtOpt,6,0,1,2]
[vxSendEvtOpt,3,0,1,6,"-468.5,-458.5,335<mm>"]
[vxSendEvtOpt,3,0,-1,6,"-468.5,-458.5,335<mm>"]
[vxSendOptFocus,25,0]
[vxSendEvtOpt,25,0,1,6,"133"]
[vxSendOptFocus,27,0]
[vxSendEvtOpt,27,0,1,6,"335"]
[vxSendEvtOpt,-1,0,1,2]
# 右下角 (468.5, -458.5)
# 右上角 (468.5, 458.5)
# 左上角 (-468.5, 458.5)
# ... (repeat for other 3 corners with adjusted coordinates)
# ===== 步骤 4: 上表面 M18.5 螺纹孔阵列 (5x5, 间距 70mm) =====
# 左上角阵列 (-400, 400) - 使用 vxSendEvtOpt 设置位置 (不要用鼠标点击)
[vxSend,"!FtHoleMain"]
[vxInitCmd,FtHoleMain,<6,2><21,0><121,0><25,16.5><27,34.5><29,15><31,5><33,90><70,10><23,0><55,118><94,30><95,0><110,1><10,0><75,1><16,1><11,0><61,1><40,1.5><41,0><168,1><63,27><167,1><73,1><72,0><74,1><101,0><102,0>]
[vxFormInitGlbl,FtHoleChamForm,"0, 0, 0.75, 45, 0, 0, 0, 0, 0, 0, 0.75, 45"]
[vxFormInitGlbl,FtHoleMParaForm,",0,0,0,0,0,0,0,1"]
[vxSendEvtOpt,6,0,3,2]
[vxFormInitGlbl,FtHoleThrdForm,"M,M18.5 x 2.0,1,18.5,27,2.0,0"]
[vxSendEvtOpt,3,0,1,6,"-400,400,335<mm>"] # 关键:用坐标设置位置
[vxSendEvt,"FtHoleThrdForm",165,45,2]
[vxSendEvtOpt,-1,0,1,2]
# 左上角 5x5 阵列 (第一方向 +X, 第二方向 -Y)
[vxSend,"!FtPtnFtr"]
[vxInitCmd,FtPtnFtr,<10,0><3,2><4,20><12,45><93,360><6,1><7,20><18,1><19,0><17,0><28,0><31,0><9,0><40,3><41,0><42,20><43,1><44,20><45,0><60,0><48,0><49,0><59,0><63,0><65,0><66,0.1><67,15><69,0><70,0><71,0><75,0><72,0><74,0><76,0><78,0><83,0><84,0><85,0><87,0><89,0><91,0><92,0><126,0><127,0>]
[vxSendEvt,"UiManager",1,0,2,"UiHistoryManager"]
[vxSendEvt,"UiHistoryManager",220,(9,1),14,4]
[vxSendEvt,"UiHistoryManager",220,(9,1),2,4]
[vxSendEvt,"UiManager",1,0,2,"UiInputManager"]
[vxSendOptFocus,2,0]
[vxSendEvtOpt,2,0,1,6,"1,0,0<mm>"]
[vxSendOptFocus,4,0]
[vxSendEvtOpt,4,0,1,6,"70"]
[vxSendEvtOpt,3,0,1,6,"5"]
[vxSendEvtOpt,51,0,1,2]
[vxSendOptFocus,5,0]
[vxSendEvtOpt,5,0,1,6,"0,-1,0<mm>"]
[vxSendOptFocus,6,0]
[vxSendEvtOpt,6,0,1,6,"5"]
[vxSendOptFocus,7,0]
[vxSendEvtOpt,7,0,1,6,"70"]
[vxSendEvtOpt,-1,0,1,2]
# 右上角 (400, 400)、右下角 (400, -400)、左下角 (-400, -400) 阵列
# ... (repeat for other 3 corners with adjusted positions and directions)
# ===== 步骤 5: 中心主轴穿孔 (直径 200mm) =====
[vxSend,"!FtHoleMain"]
[vxInitCmd,FtHoleMain,<6,1><21,0><121,0><25,10.5><27,34.5><29,15><31,5><33,90><70,10><23,0><55,118><94,30><95,0><110,1><10,0><75,1><16,1><11,0><61,1><40,1.5><41,0><168,1><63,-1e-06><167,1><73,1><72,0><74,1><101,0><102,0>]
[vxFormInitGlbl,FtHoleScrewForm,"ISO,General Screw Clearance,M10,Close"]
[vxFormInitGlbl,FtHoleChamForm,"0, 0, 0.6, 45, 0, 0, 0, 0, 0, 0, 0.6, 45"]
[vxFormInitGlbl,FtHoleMParaForm,",0,0,0,0,0,0,0,1"]
[vxSendEvtOpt,6,0,1,2]
[vxSendEvtOpt,3,0,1,6,"0,0,335<mm>"]
[vxSendEvtOpt,3,0,-1,6,"0,0,335<mm>"]
[vxSendOptFocus,25,0]
[vxSendEvtOpt,25,0,1,6,"200"]
[vxSendOptFocus,27,0]
[vxSendEvtOpt,27,0,1,6,"335"]
[vxSendEvtOpt,-1,0,1,2]
# ===== 步骤 6: 对所有孔边缘做 2mm 倒角 (使用全选模式) =====
[vxSend,"!FtChamfers2"]
[vxInitCmd,FtChamfers2,<30,0><42,0><93,0><95,5><5,0><44,0><27,0><35,0><88,0><28,0><24,0><21,0><23,10><41,3><16,3><17,2><53,0>]
[vxInitCmd,FtChamEdgSet,<2,2><4,45><5,2><22,0><6,0>]
[vxSend,"~CdFiMorePick"] # 自动选择所有边缘
[vxFormEvtOpt,"FtChamfers2",-1,0,1,2]
[vxConfigRestore]
ENDMACRO
Key techniques:
View range extension (Critical for large models):
$SF=UiViewExt before sketch operationsBase plate with filleted corners:
<15,1>)Counterbore guide pin holes:
<6,1> for counterbore type<63,-1e-06> for through holeThreaded hole arrays (4 corners):
vxSendEvtOpt,3,0,1,6,"X,Y,Z<mm>" for location (NOT mouse pick)Center spindle hole:
FtHoleScrewForm for clearance holeChamfer all hole edges:
~CdFiMorePick for automatic edge selectionArray direction summary:
| Corner | Start Position | Direction 1 | Direction 2 |
|---|---|---|---|
| Top-Left | (-400, 400, 335) | 1,0,0 (+X) | 0,-1,0 (-Y) |
| Top-Right | (400, 400, 335) | -1,0,0 (-X) | 0,-1,0 (-Y) |
| Bottom-Right | (400, -400, 335) | -1,0,0 (-X) | 0,1,0 (+Y) |
| Bottom-Left | (-400, -400, 335) | 1,0,0 (+X) | 0,1,0 (+Y) |
Important notes:
Key techniques:
!FtHoleMain for creating threaded holesFtHoleThrdForm with format "M,M10 x 1.25,1,10,15,1.25,0"
M = Metric thread typeM10 x 1.25 = Thread size (diameter × pitch)1 = Full thread depth10 = Nominal diameter15 = Thread depth1.25 = PitchvxSendEvtOpt,3,0,1,6,"X,Y,Z<mm>" (field 3)FtHoleChamForm for entrance/exit chamfersFtHoleMParaForm for hole parametersCommon thread sizes:
"M,M6 x 1.0,1,6,10,1.0,0""M,M8 x 1.25,1,8,12,1.25,0""M,M10 x 1.25,1,10,15,1.25,0""M,M12 x 1.75,1,12,18,1.75,0"Important notes:
<6,2> parameter in FtHoleMain sets the hole type to threaded hole[vxSendEvt,"FtHoleThrdForm",165,45,2] to select the thread type before confirming"0, 0, 0.75, 45, 0, 0, 0, 0, 0, 0, 0.75, 45" for entrance/exit chamfers<63,-1e-06> and set depth equal to plate thicknessCorrect format for modifying an existing pattern feature:
[vxSendEvt,"UiHistoryManager",220,(10,1),25,4]
[vxSendEvt,"UiHistoryManager",220,(10,1),4,4]
# Popup Menu Name : UiPartFtr
[vxSend,"$CdHistEdit"]
BUFFER
ENDBUFFER
# Success to quick rollback to Pattern Feature1=4932, time=0.06 sec
# Default settings updated.
[vxInitCmd,FtPtnFtr,<10,0><3,5><4,70><12,45><93,360><6,5><7,70><18,1><19,0><17,0><28,0><31,0><9,0><40,3><41,0><42,20><43,1><44,20><45,0><60,0><48,0><49,0><59,0><63,0><65,0><66,0.1><67,15><69,0><70,0><71,0><75,0><72,0><74,0><76,0><78,0><83,0><84,0><85,0><87,0><89,0><91,0><92,0><126,0><127,0>]
# Pattern feature
[vxSendOptFocus,3,0] # Number
[vxSendEvtOpt,3,0,1,6,"10"] # Number
[vxSendOptFocus,6,0] # Number N
[vxSendEvtOpt,6,0,1,6,"10"] # Number N
[vxSendEvtOpt,-1,0,1,2] # Ok
# Default settings updated.
Key points:
BUFFER/ENDBUFFER for quick rollback to the pattern featureFtPtnFtr command to update default settingsvxSendOptFocus and vxSendEvtOptThis example demonstrates creating a 3×3 rectangular pattern of holes with 50mm spacing:
# 阵列孔特征 (3x3, 间距 250mm)
[vxSend,"!FtPtnFtr"]
[vxInitCmd,FtPtnFtr,<10,0><3,2><4,20><12,45><93,360><6,1><7,20><18,1><19,0><17,0><28,0><31,0><9,0><40,3><41,0><42,20><43,1><44,20><45,0><60,0><48,0><49,0><59,0><63,0><65,0><66,0.1><67,15><69,0><70,0><71,0><75,0><72,0><74,0><76,0><78,0><83,0><84,0><85,0><87,0><89,0><91,0><92,0><126,0><127,0>]
# Pattern feature
[vxSendEvt,"UiManager",1,0,2,"UiHistoryManager"]
[vxSendEvt,"UiHistoryManager",220,(4,1),14,4] # 选择螺纹孔特征
[vxSendEvt,"UiHistoryManager",220,(4,1),2,4]
[vxSendEvt,"UiManager",1,0,2,"UiInputManager"]
[vxSendOptFocus,2,0] # Direction
[vxSendEvtOpt,2,0,1,6,"1,0,0<mm>"] # X 方向
[vxSendOptFocus,4,0] # Spacing
[vxSendEvtOpt,4,0,1,6,"250"] # Spacing
[vxSendEvtOpt,3,0,1,6,"3"] # Number
[vxSendEvtOpt,51,0,1,2] # Second direction
[vxSendOptFocus,5,0] # Direction D
[vxSendEvtOpt,5,0,1,6,"0,1,0<mm>"] # Y 方向
[vxSendEvtOpt,6,0,1,6,"3"] # Number N
[vxSendOptFocus,7,0] # Spacing S
[vxSendEvtOpt,7,0,1,6,"250"] # Spacing S
[vxSendEvtOpt,-1,0,1,2] # Ok
Key techniques:
!FtPtnFtr for creating rectangular/circular patterns<3,2> sets rectangular pattern (use <3,3> for circular)(4,1) refers to the 4th item in history (the source hole feature)"1,0,0<mm>" for X axisvxSendEvtOpt,51,0,1,2 to enable second direction"0,1,0<mm>" for Y axis"X,Y,Z<mm>" instead of mouse picking for reliabilityPattern type options:
<vxInitCmd,FtPtnFtr,<3,2>...] # Rectangular pattern (矩形阵列)
<vxInitCmd,FtPtnFtr,<3,3>...] # Circular pattern (圆形阵列)
Important notes:
"1,0,0<mm>" (X axis) and "0,1,0<mm>" (Y axis)vxViewSet2 for proper view orientation - avoid when possible<12,45> = 45° angular spacingFor detailed syntax documentation, see references/syntax_reference.md.