当前位置:你问我答 >  详情

[CASS二次开发源代码]VBA+AutoCAD---高程点处理

Windows10
其他
CASS9
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

全部评论

等级:LV27
积分:91714
工程测绘 2019-11-03 13:23
学习了
回复 0
等级:LV1
积分:140
新手93904 2020-07-13 00:00
可以加你qq么 老师 我是一个新手
回复 0
1

提交
悬赏回复规则
1、悬赏期为24小时,从发布时间起算;
2、悬赏期内提问者如设置评论为“精选评论”,视为悬赏结束,该精选评论人将获得本题全部悬赏积分;
3、悬赏期内如提问者未设置“精选评论”,则前5位评论者平分悬赏积分(如仅有一位评论,该评论者获得50%悬赏积分);
4、悬赏积分会自动发放到生态圈账户中,请留意站内信通知。
知道了

距离打开宝箱还剩7

是否花费200积分补签?
确认
取消