'第六节 块操作
Sub InsertBlock() '插入块
Dim xy(2) As Double
xy(0) = 100: xy(1) = 200: xy(2) = 300
ThisDrawing.Application.ActiveDocument.ModelSpace.InsertBlock xy, _
"C:\Documents and Settings\Administrator\桌面\abc.dwg", 1, 1, 1, 0
End Sub
Sub BlockProperties() '高程点加常数
Dim objBlock As AcadBlockReference
Dim sSet As AcadSelectionSet
Dim intCnt As Integer
Dim mType(2) As Integer, mData(2) As Variant
Dim xyz(2) As Double
Dim varAttributes As Variant
intCnt = ThisDrawing.SelectionSets.Count
While (intCnt > 0)
Set sSet = ThisDrawing.SelectionSets.Item(intCnt - 1)
sSet.Delete
intCnt = intCn0t - 1
Wend
mType(0) = 0: mData(0) = "INSERT"
mType(1) = 8: mData(1) = "GCD"
mType(2) = 2: mData(2) = "GC200"
Set sSet = ThisDrawing.SelectionSets.Add("GCD")
sSet.Select acSelectionSetAll, , , mType, mData
If sSet.Count > 0 Then
For Each objBlock In sSet
xyz(0) = objBlock.insertionPoint(0)
xyz(1) = objBlock.insertionPoint(1)
xyz(2) = objBlock.insertionPoint(2) + 50
objBlock.insertionPoint = xyz '修改高程点的高程值
varAttributes = objBlock.GetAttributes '获得高程点的块属性
varAttributes(0).TextString = xyz(2) '修改块属性为新的高程值
Next
End If
sSet.Delete
End Sub
全部评论