Sub DrawRobotCarBase()
' 声明变量
Dim s As Shape
Dim doc As Document
Set doc = ActiveDocument
Dim layer As Layer
Set layer = doc.ActiveLayer
' 1. 绘制外框(80mmХ60mm,左下角为原点)
Set s = layer.CreateRectangle(0, 0, 80, 60)
s.Outline.Width = 0.01 * 25.4 ' 转换为毫米(0.01mm)
s.Outline.Color.RGB = RGB(255, 0, 0) ' 切割层红色
' 2. 左电机孔(10mmХ5mm)
Set s = layer.CreateRectangle(15, 27.5, 25, 32.5)
s.Outline.Width = 0.01 * 25.4
s.Outline.Color.RGB = RGB(255, 0, 0)
' 3. 右电机孔(10mmХ5mm)
Set s = layer.CreateRectangle(45, 27.5, 55, 32.5)
s.Outline.Width = 0.01 * 25.4
s.Outline.Color.RGB = RGB(255, 0, 0)
' 4. ESP32安装槽(50mmХ25mm)
Set s = layer.CreateRectangle(15, 10, 65, 35)
s.Outline.Width = 0.01 * 25.4
s.Outline.Color.RGB = RGB(255, 0, 0)
' 5. 四角螺丝孔(直径2mm)
Set s = layer.CreateEllipse(4, 4, 6, 6) ' 圆心(5,5),直径2mm
s.Outline.Width = 0.01 * 25.4
s.Outline.Color.RGB = RGB(255, 0, 0)
' 复制螺丝孔到其他位置
s.Duplicate 70, 0 ' 右下方(75,5)
s.Duplicate 0, 50 ' 左上方(5,55)
s.Duplicate 70, 50 ' 右上方(75,55)
End Sub |