三维多段线求各顶点坐标 .NET API
做CAD二次开发时,如何获得三维多段线的顶点个数和相应坐标,用的得是vs2008 .net API ?本帖最后由 guohq 于 2011-6-14 23:43 编辑
Public Function GetVerPts(ByVal objPolyLine3D As Polyline3d) As List(Of Point3d)
Dim rtn As New List(Of Point3d)
Using Trans As Transaction = DB.TransactionManager.StartTransaction
Dim obj As Polyline3d = Trans.GetObject(objPolyLine3D.ObjectId, OpenMode.ForWrite)
Dim Temp_Type As Poly3dType = obj.PolyType '将先前的拟合类型先保存下来,计算完毕后复原
obj.ConvertToPolyType(Poly3dType.SimplePoly)
Dim Vtx As PolylineVertex3d = Nothing
For Each VID As ObjectId In obj
Vtx = VID.GetObject(OpenMode.ForRead)
rtn.Add(New Point3d(Vtx.Position.X, Vtx.Position.Y, Vtx.Position.Z))
Next
obj.ConvertToPolyType(Temp_Type)
Trans.Commit()
End Using
GetVerPts = rtn
End Function
说明:1.当polyline3d处于非拟合状态时可以计算其顶点坐标
2. DB =HostApplicationServices.WorkingDatabase 回复 guohq 的帖子
谢谢!我正在学C#.net 能不能用C#给我讲解一下?
页:
[1]