如何用VB.NET的ARX方法生成面域
我写了一段代码,先画一个圆,再生成面域。结果圆能画出,面域却创建失败,请各位高手看看错在哪?先谢谢了!Imports Autodesk.AutoCAD.ApplicationServices<BR>Imports Autodesk.AutoCAD.DatabaseServices<BR>Imports Autodesk.AutoCAD.Geometry<BR>Imports Autodesk.AutoCAD.Runtime<BR>Imports Autodesk.AutoCAD.Interop<BR>Imports Autodesk.AutoCAD.Interop.Common<BR>Public Class Class1<BR> <CommandMethod("test")> Public Shared Sub TestTemp()<BR> Dim bt As BlockTable<BR> Dim btr As BlockTableRecord
Dim CenPt As New Point3d(0, 0, 0) '先画一个圆<BR> Dim CircleObj As Circle<BR> Try<BR> Dim db As Database = HostApplicationServices.WorkingDatabase<BR> Dim objId As ObjectId = db.BlockTableId
bt = objId.Open(OpenMode.ForRead)<BR> objId = bt.Item(btr.ModelSpace)<BR> btr = objId.Open(OpenMode.ForWrite)<BR> CircleObj = New Circle<BR> CircleObj.Center = CenPt<BR> CircleObj.Radius = 300<BR> btr.AppendEntity(CircleObj)<BR> Catch<BR> Finally<BR> CircleObj.Close()<BR> btr.Close()<BR> bt.Close()<BR> End Try
<BR> Dim Array As DBObjectCollection = New DBObjectCollection '建立一个集合<BR> Array.Add(CircleObj) '将圆添加到集合中
Dim Reginobj As Region<BR> Try<BR> Dim db As Database = HostApplicationServices.WorkingDatabase<BR> Dim objId As ObjectId = db.BlockTableId<BR> bt = objId.Open(OpenMode.ForRead)<BR> objId = bt.Item(btr.ModelSpace)<BR> btr = objId.Open(OpenMode.ForWrite)<BR> ReginObj = New Region<BR> Region.CreateFromCurves(Array)<BR> btr.AppendEntity(Reginobj)<BR> Catch<BR> Finally<BR> Reginobj.Close()<BR> btr.Close()<BR> bt.Close()<BR> End Try<BR> End Sub<BR> <BR>End Class<BR> Region.CreateFromCurves(Array)
返回的是dbobjectcollection类型
你的ReginObj 还是null,并没有付给它
页:
[1]