<CommandMethod("TestConvertPoly")> _
Public Sub testConvertPoly()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
' select the entity
Dim res As PromptEntityResult = ed.GetEntity("Select PolyLine: ")
' if ok
If res.Status = PromptStatus.OK Then
' use the using keyword so that the objects auto-dispose
'(close) at the end of the brace
' open for write otherwise ConvertFrom will fail
Using ent As Entity = CType(res.ObjectId.Open(OpenMode.ForRead), Entity)
' if it's a polyline2d
If TypeOf ent Is Polyline2d Then
Dim poly2d As Polyline2d = CType(ent, Polyline2d)
poly2d.UpgradeOpen()
' again use the using keyword to ensure auto-closing
Using poly As New Autodesk.AutoCAD.DatabaseServices.Polyline()
poly.ConvertFrom(poly2d, True)
End Using
End If
End Using
End If
End Sub
Public Sub testConvertPoly()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
' select the entity
Dim res As PromptEntityResult = ed.GetEntity("Select PolyLine: ")
' if ok
If res.Status = PromptStatus.OK Then
' use the using keyword so that the objects auto-dispose
'(close) at the end of the brace
' open for write otherwise ConvertFrom will fail
Using ent As Entity = CType(res.ObjectId.Open(OpenMode.ForRead), Entity)
' if it's a polyline2d
If TypeOf ent Is Polyline2d Then
Dim poly2d As Polyline2d = CType(ent, Polyline2d)
poly2d.UpgradeOpen()
' again use the using keyword to ensure auto-closing
Using poly As New Autodesk.AutoCAD.DatabaseServices.Polyline()
poly.ConvertFrom(poly2d, True)
End Using
End If
End Using
End If
End Sub
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |