<CommandMethod("BoundaryTest")> _
Public Shared Sub BoundaryTest()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim ptOptions As New PromptPointOptions("Select point ")
ptOptions.AllowNone = False
Dim ptResult As PromptPointResult = ed.GetPoint(ptOptions)
If ptResult.Status <> PromptStatus.OK Then
Return
End If
Dim collection As DBObjectCollection = ed.TraceBoundary(ptResult.Value, True)
Using Tx As Transaction = db.TransactionManager.StartTransaction()
Dim ModelSpaceId As ObjectId = SymbolUtilityServices.GetBlockModelSpaceId(db)
Dim model As BlockTableRecord = TryCast(Tx.GetObject(ModelSpaceId, OpenMode.ForWrite), BlockTableRecord)
For Each obj As DBObject In collection
Dim ent As Entity = TryCast(obj, Entity)
If ent IsNot Nothing Then
'make the color as red.
ent.ColorIndex = 1
model.AppendEntity(ent)
Tx.AddNewlyCreatedDBObject(ent, True)
End If
Next
Tx.Commit()
End Using
End Sub
Public Shared Sub BoundaryTest()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim ptOptions As New PromptPointOptions("Select point ")
ptOptions.AllowNone = False
Dim ptResult As PromptPointResult = ed.GetPoint(ptOptions)
If ptResult.Status <> PromptStatus.OK Then
Return
End If
Dim collection As DBObjectCollection = ed.TraceBoundary(ptResult.Value, True)
Using Tx As Transaction = db.TransactionManager.StartTransaction()
Dim ModelSpaceId As ObjectId = SymbolUtilityServices.GetBlockModelSpaceId(db)
Dim model As BlockTableRecord = TryCast(Tx.GetObject(ModelSpaceId, OpenMode.ForWrite), BlockTableRecord)
For Each obj As DBObject In collection
Dim ent As Entity = TryCast(obj, Entity)
If ent IsNot Nothing Then
'make the color as red.
ent.ColorIndex = 1
model.AppendEntity(ent)
Tx.AddNewlyCreatedDBObject(ent, True)
End If
Next
Tx.Commit()
End Using
End Sub
http://adndevblog.typepad.com/autocad/2012/0 ... boundary-through-api-.html
[本日志由 tiancao1001 于 2018-08-14 10:02 PM 编辑]
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |