加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

VBA+AutoCAD高程点高程值及注记

(2018-06-11 16:16:23)
标签:

高程点

注记

分类: AutoCAD二次开发
Sub SetGcdHeightByLabel()'根据高程点注记修改高程点高程值
  Dim sSet As AcadSelectionSet
  Dim dType(0 To 2) As Integer, dData(0 To 2) As Variant
  Dim objBlock As AcadBlockReference, iCount As Integer
  Dim varAttributes As Variant, pnt As Variant, i As Integer
  dType(0) = 0: dData(0) = "INSERT"
  dType(1) = 2: dData(1) = "GC200"
  dType(2) = 8: dData(2) = "GCD"
  Set sSet = ThisDrawing.Application.ActiveDocument.SelectionSets.Add("GCD")
  sSet.Select acSelectionSetAll, , , dType, dData
  If sSet.Count = 0 Then
     MsgBox "图形中未发现高程点。", vbInformation, "修改高程点高程值"
  Else
     For Each objBlock In sSet
         varAttributes = objBlock.GetAttributes
         pnt = objBlock.InsertionPoint
         pnt(2) = CDbl(varAttributes(0).TextString)
         objBlock.InsertionPoint = pnt
         i = i + 1
         ThisDrawing.Application.ActiveDocument.Utility.Prompt vbCr & vbCr & "已完成 " & i & "/" & sSet.Count & " ..."
     Next
  End If
  sSet.Delete
End Sub

Sub SetGcdLabelByHeight()'根据高程点高程值修改高程点注记
  Dim sSet As AcadSelectionSet
  Dim dType(0 To 2) As Integer, dData(0 To 2) As Variant
  Dim objBlock As AcadBlockReference, iCount As Integer
  Dim varAttributes As Variant, pnt As Variant, i As Integer
  dType(0) = 0: dData(0) = "INSERT"
  dType(1) = 2: dData(1) = "GC200"
  dType(2) = 8: dData(2) = "GCD"
  Set sSet = ThisDrawing.Application.ActiveDocument.SelectionSets.Add("GCD")
  sSet.Select acSelectionSetAll, , , dType, dData
  If sSet.Count = 0 Then
     MsgBox "图形中未发现高程点。", vbInformation, "修改高程点注记"
  Else
     For Each objBlock In sSet
         varAttributes = objBlock.GetAttributes
         varAttributes(0).TextString = objBlock.InsertionPoint(2)
         i = i + 1
         ThisDrawing.Application.ActiveDocument.Utility.Prompt vbCr & vbCr & "已完成 " & i & "/" & sSet.Count & " ..."
     Next
  End If
  sSet.Delete
End Sub

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有