我想用autocad创建一个正方形,并将它们分组成一个块。
Call CreateLine(p1, p2) 'creating top line
Call CreateLine(p2, p3) 'creating right line
Call CreateLine(p3, p4) 'creating bottom line
Call CreateLine(p4, p1) 'creating left line
Function CreateLine(firstPoint, secondPoint)
Dim StartPoint(0 To 2) As Double
Dim EndPoint(0 To 2) As Double
StartPoint(0) = firstPoint(0)
StartPoint(1) = firstPoint(1)
StartPoint(2) = 0
EndPoint(0) = secondPoint(0)
EndPoint(1) = secondPoint(1)
EndPoint(2) = 0
With ThisDrawing.ModelSpace
.AddLine StartPoint, EndPoint
.Item(.Count - 1).Update
End With
End Function
现在我想将这个正方形分组为一个具有VBA
和AutoCAD自定义名称的块。我该怎么办?
如果您想将它们连接为块,则应该在块内绘制-而不是在ModelSpace
中。然后插入块引用
:
Dim p0(0 To 2) As Double
p0(0) = 0
p0(1) = 0
p0(2) = 0
Dim block As AcadBlock
Set block = ThisDrawing.Blocks.Add(p0, "*")
Dim line As AcadLine
Set line = block.AddLine(firstPoint, secondPoint)
Dim ref As AcadBlockReference
Set ref = ThisDrawing.ModelSpace.InsertBlock(p0, block.Name, 1, 1, 1, 0)