明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2907|回复: 1

如何用VB.NET的ARX方法生成面域

[复制链接]
发表于 2005-2-22 11:39:00 | 显示全部楼层 |阅读模式
我写了一段代码,先画一个圆,再生成面域。结果圆能画出,面域却创建失败,请各位高手看看错在哪?先谢谢了! 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

End Class
发表于 2007-4-5 16:15:00 | 显示全部楼层
Region.CreateFromCurves(Array)
返回的是dbobjectcollection类型
你的ReginObj 还是null,并没有付给它
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 07:19 , Processed in 0.228892 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表