- 积分
- 24557
- 明经币
- 个
- 注册时间
- 2004-3-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2004-10-10 21:45:00
|
显示全部楼层
你的等高线是什么,下面是我以前写的Spline等高线的剖面测试- Sub t9()
- On Error GoTo ErrHandle
- Dim ss As AcadSelectionSet
- Dim ssLine As AcadSelectionSet
- Dim ft(0) As Integer, fd(0)
- Dim p1(2) As Double, p2(2) As Double
- Dim pPnts()
- Dim pLine As AcadLine, dot
- Dim i, j
- Dim pInsertPnt
- Dim pInsertPnts()
- Dim pNum As Integer
- Dim pnt(2) As DoubleDim pStart, PEnd
- Dim pCount As Integer
- Dim pDistances() As Double
- Set ss = ThisDrawing.SelectionSets.Add("*TlsTest*")
- ft(0) = 0: fd(0) = "Spline"
- ss.Select acSelectionSetAll, , , ft, fd
- ReDim pPnts(ss.Count - 1)
- For i = 0 To ss.Count - 1
- pPnts(i) = ss(i).ControlPoints
- p1(2) = pPnts(i)(2)
- ss(i).Move p1, p2
- Next i
- Set ssLine = ThisDrawing.SelectionSets.Add("*TlsTestLine*")
- ft(0) = 0: fd(0) = "Line"ssLine.Select acSelectionSetAll, , , ft, fd
- For Each pLine In ssLine
- pNum = 0
- For i = 0 To ss.Count - 1
- pInsertPnt = pLine.IntersectWith(ss(i), acExtendNone)
- n = (UBound(pInsertPnt) + 1) / 3
- For j = 0 To n - 1
- pnt(0) = pInsertPnt(j * 3)
- pnt(1) = pInsertPnt(j * 3 + 1)
- pnt(2) = pPnts(i)(2)
- ReDim Preserve pInsertPnts(pNum)
- pInsertPnts(pNum) = pnt
- pNum = pNum + 1
- Next j
- Next ipStart = pLine.StartPoint
- PEnd = pLine.EndPoint
- pCount = UBound(pInsertPnts)If Abs(Tan(pLine.Angle)) < 1 Then pNum = 0 Else pNum = 1ReDim pDistances(pCount) As Double
- For i = 0 To pCount
- pDistances(i) = Abs(pInsertPnts(i)(pNum) - pStart(pNum))
- Next i
- SortPoint pDistances, pInsertPnts, pCount
- Dim pDPnts() As Double
- pNum = UBound(pInsertPnts) * 3 + 2
- ReDim pDPnts(pNum) As Double
- For i = 0 To UBound(pInsertPnts)
- pDPnts(i * 3) = pInsertPnts(i)(0)
- pDPnts(i * 3 + 1) = pInsertPnts(i)(1)
- pDPnts(i * 3 + 2) = pInsertPnts(i)(2)
- Next i
- ThisDrawing.ModelSpace.Add3DPoly(pDPnts).Rotate3D pLine.StartPoint, pLine.EndPoint, Atn(1) * 2
- Next pLine
- ErrHandle:
- For i = 0 To ss.Count - 1
- p1(2) = pPnts(i)(2)
- ss(i).Move p2, p1
- Next i
- ThisDrawing.SelectionSets("*TlsTest*").Delete
- ThisDrawing.SelectionSets("*TlsTestLine*").Delete
- End Sub
- Private Sub SortPoint(ByRef Values As Variant, ByRef Points As Variant, ByVal Count As Integer)
- '按值将点数组排序
- Dim pTemp As Double, pnt As VariantFor i = Count To 1 Step -1For j = 0 To i - 1If Values(j) > Values(j + 1) Then
- pTemp = Values(j + 1)
- Values(j + 1) = Values(j)
- Values(j) = pTemp
- pnt = Points(j + 1)
- Points(j + 1) = Points(j)
- Points(j) = pnt
- End IfNext jNext iEnd Sub
|
|