我所做的就是在一条多边形线上高亮显示一个3d顶点,然后我想以某种方式改变它。就像使用属性托盘来滚动顶点一样。参见代码。AutoCAD 2014、Windows 7、VB.net
- Public Sub UtilityLine()
- Dim acDoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
- Dim acCurDb As Database = acDoc.Database
- Dim ed As Editor = acDoc.Editor
- Dim east, north, ele As Double
- 'Dim strText As String
- '' Start a transaction
- Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
- '' Request for objects to be selected in the drawing area
- Dim acSSPrompt As PromptSelectionResult = acDoc.Editor.GetSelection()
- '' If the prompt status is OK, objects were selected
- If acSSPrompt.Status = PromptStatus.OK Then
- Dim acSSet As SelectionSet = acSSPrompt.Value
- '' Step through the objects in the selection set
- For Each acSSObj As SelectedObject In acSSet
- '' Check to make sure a valid SelectedObject object was returned
- If Not IsDBNull(acSSObj) Then
- '' Open the selected object for write
- Dim acEnt As Entity = acTrans.GetObject(acSSObj.ObjectId, _
- OpenMode.ForWrite)
- acEnt.Highlight()
- ed.Regen()
- If Not IsDBNull(acEnt) Then
- Dim obj As DBObject = acTrans.GetObject(acEnt.ObjectId, OpenMode.ForWrite)
- ' lightweight polyline
- Dim lwp As Polyline = TryCast(obj, Polyline)
- If lwp IsNot Nothing Then
- ' Loop to get each vertex
- Dim vn As Integer = lwp.NumberOfVertices
- For i As Integer = 0 To vn - 1
- Dim pt As Point3d = lwp.GetPoint3dAt(i)
- east = pt(0)
- north = pt(1)
- ed.WriteMessage(vbLf & pt.ToString())
- Next
- Else
- ' 2D polyline
- Dim p2d As Polyline2d = TryCast(obj, Polyline2d)
- If p2d IsNot Nothing Then
- ' Use foreach to get each contained vertex
- For Each vId As ObjectId In p2d
- Dim v2d As Vertex2d = DirectCast(acTrans.GetObject(vId, OpenMode.ForWrite), Vertex2d)
- ed.WriteMessage(vbLf & v2d.Position.ToString())
- Next
- Else
- ' 3D polyline
- Dim p3d As Polyline3d = TryCast(obj, Polyline3d)
- If p3d IsNot Nothing Then
- Dim p3dColour As String = p3d.Color.ToString
- For Each vId As ObjectId In p3d
- Dim zM As New ZoomObj
- Dim v3d As PolylineVertex3d = DirectCast(acTrans.GetObject(vId, OpenMode.ForWrite), PolylineVertex3d)
- east = v3d.Position(0)
- north = v3d.Position(1)
- ele = v3d.Position(2)
- Dim zMax = New Point3d(east + 1, north + 1, 1)
- Dim zMin = New Point3d(east - 1, north - 1, 1)
- zM.Zoom(zMin, zMax, v3d.Position, 1)
- p3d.Highlight()
- Dim dText As New PromptEntityOptions(vbLf & "Select Depth: ")
- dText.SetRejectMessage("not text")
- dText.AddAllowedClass(GetType(DBText), False)
- Dim resdText As PromptEntityResult = ed.GetEntity(dText)
- If resdText.Status = PromptStatus.OK Then
- Dim depthText As DBText = DirectCast(acTrans.GetObject(resdText.ObjectId, _
- OpenMode.ForRead), DBText)
- Dim depthLen = depthText.TextString.Length
- Dim dthTxt As String = depthText.TextString
- dthTxt = Mid(dthTxt, 3, depthLen - 1)
- Dim depthOff As Double = CDbl(dthTxt)
- v3d.Position = New Point3d(east, north, ele - depthOff)
- ed.WriteMessage(vbLf & "Depth= " & dthTxt)
- End If
- Next
- End If
- End If
- End If
- End If
- End If
- Next
- '' Save the new object to the database
- acTrans.Commit()
- End If
- '' Dispose of the transaction
- End Using
- End Sub
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |