- 积分
- 1037
- 明经币
- 个
- 注册时间
- 2019-8-28
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2019-11-22 12:24:58
|
显示全部楼层
-
- Private Sub DrawAltitude(ByRef Altitude() As Double) 'VB输出数组要通过ByRef 引用才行,不能直接输出
- ConnectAutoCAD
- '获取交点并写入数组中
- Dim CrossPoint As Variant
- Dim pickedobjs1 As AcadEntity
- Dim pickedobjs2 As AcadEntity
- Dim nLWS, nLS As Integer
- nLWS = CorrLineObj.Count: nLS = GuideLinesObj.Count '选中的对象个数
- Dim cpnts() As Double '交点数组
- ' Dim Altitude() As Double '高程数组
- ReDim cpnts(0 To nLWS - 1, 0 To nLS - 1, 2) As Double '定义一个三维动态数组用于存放交点坐标
- ReDim Altitude(0 To nLWS - 1, 0 To nLS - 1, 2) As Double
- Dim i As Integer
- Dim j As Integer
- Dim k As Integer
- Dim textobj As AcadText
- i = 0: j = 0: k = 0
- For Each pickedobjs1 In CorrLineObj
- Thisdrawing.Utility.Prompt vbCrLf & (i + 1) & "/" & CorrLineObj.Count
- pickedobjs1.Highlight (True) '高亮选中的实体
- pickedobjs1.Update
- j = 0
- For Each pickedobjs2 In GuideLinesObj
- pickedobjs1.Highlight (True) '高亮选中的实体
- pickedobjs1.Update
- CrossPoint = pickedobjs1.IntersectWith(pickedobjs2, acExtendNone) '获取交点
-
- If VarType(CrossPoint) <> vbEmpty Then '执行计算
- Thisdrawing.Utility.Prompt vbCrLf & CrossPoint(1)
- Thisdrawing.Utility.Prompt vbCrLf & CrossPoint(0) & "," & CrossPoint(1) & "," & CrossPoint(2)
- cpnts(i, j, 0) = CrossPoint(0)
- cpnts(i, j, 1) = CrossPoint(1)
- cpnts(i, j, 2) = CrossPoint(2) '交点数组
- Altitude(i, j, 0) = CrossPoint(0)
- Altitude(i, j, 1) = CrossPoint(1) - CDbl(HeightBaseP(1)) + HeightBaseVal
- Altitude(i, j, 2) = CrossPoint(2) '高程数组
- '写入高程信息
- textInBasePoint(0) = CrossPoint(0)
- textInBasePoint(2) = CrossPoint(2)
- Set textobj = Thisdrawing.ModelSpace.AddText(CStr(Format(Altitude(i, j, 1), "0.00")), textInBasePoint, 1.5)
- textobj.Rotate textInBasePoint, pi / 2 '旋转90°布置
- End If
- j = j + 1
- Next pickedobjs2
- i = i + 1
- Next pickedobjs1
- Thisdrawing.Utility.Prompt vbCrLf & "任务已完成!"
- End Sub
|
|