我写了一段代码,先画一个圆,再生成面域。结果圆能画出,面域却创建失败,请各位高手看看错在哪?先谢谢了!
Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.Geometry Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.Interop Imports Autodesk.AutoCAD.Interop.Common Public Class Class1 <CommandMethod("test")> Public Shared Sub TestTemp() Dim bt As BlockTable Dim btr As BlockTableRecord
Dim CenPt As New Point3d(0, 0, 0) '先画一个圆 Dim CircleObj As Circle Try Dim db As Database = HostApplicationServices.WorkingDatabase Dim objId As ObjectId = db.BlockTableId
bt = objId.Open(OpenMode.ForRead) objId = bt.Item(btr.ModelSpace) btr = objId.Open(OpenMode.ForWrite) CircleObj = New Circle CircleObj.Center = CenPt CircleObj.Radius = 300 btr.AppendEntity(CircleObj) Catch Finally CircleObj.Close() btr.Close() bt.Close() End Try
Dim Array As DBObjectCollection = New DBObjectCollection '建立一个集合 Array.Add(CircleObj) '将圆添加到集合中
Dim Reginobj As Region Try Dim db As Database = HostApplicationServices.WorkingDatabase Dim objId As ObjectId = db.BlockTableId bt = objId.Open(OpenMode.ForRead) objId = bt.Item(btr.ModelSpace) btr = objId.Open(OpenMode.ForWrite) ReginObj = New Region Region.CreateFromCurves(Array) btr.AppendEntity(Reginobj) Catch Finally Reginobj.Close() btr.Close() bt.Close() End Try End Sub