CaveMan 发表于 2022-7-6 22:35:02

VB。UCS上的净绘制圆

很好的一天
 
希望在当前UCS上绘制一个圆
有代码-但生成的圆圈-在屏幕上不可见-但如果选择“复制”>“所有”则会找到对象?
 
我认为我的错误来自Vector3D??轴-是否必须将其定义为当前UCS?
 
有一个画线的例程-函数没有问题,所以裁剪代码来画一个圆。
 
感谢您的任何帮助
 

Function DrawCircle()
Dim startpoint As New Point3d(0, 0, 0)
Dim myRadius As Double = 50
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
acDoc.LockDocument()
Dim id As ObjectId
Dim acCirc As Circle = Nothing
Using db As Database = HostApplicationServices.WorkingDatabase()

Using tr As Transaction = db.TransactionManager.StartTransaction
Try
Dim btr As BlockTableRecord = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite, False)
acCirc = New Circle(startpoint, Vector3d.ZAxis, myRadius) 'Not Sure about this?
id = btr.AppendEntity(acCirc)
db.TransactionManager.AddNewlyCreatedDBObject(acCirc, True)
tr.Commit()
Catch ex As Exception
tr.Abort()
End Try
End Using
End Using
End Function

fixo 发表于 2022-7-6 23:02:13

永远不要在内部使用tr.Abort()。。。结束使用代码块:

Using tr As Transaction...
'' ........rest your code......
tr.Commit()
End using

除此之外没关系

CaveMan 发表于 2022-7-6 23:17:15

你好
 
已经修改了如下代码,还是没有得到生成的圆?
从命令行显示对象已绘制:
 
“命令:复制
选择对象:全部
找到1个
1不在当前空间中。"
 
我使用这种方法的主要原因是,我想绘制不同的UCS,然后挤出区域-但首先只是尝试绘制对象
 

Using db As Database = HostApplicationServices.WorkingDatabase()
Using tr As Transaction = db.TransactionManager.StartTransaction
Dim btr As BlockTableRecord = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite, False)
acCirc = New Circle(startpoint, Vector3d.ZAxis, myRadius)
id = btr.AppendEntity(acCirc)
db.TransactionManager.AddNewlyCreatedDBObject(acCirc, True)
tr.Commit()
End Using
End Using

BlackBox 发表于 2022-7-6 23:24:21

FWIW-开发者文档非常有用:
 
AutoCAD。NET Developer's Guide>创建和编辑AutoCAD图元>创建对象>创建曲线对象>创建圆形对象

CaveMan 发表于 2022-7-6 23:39:38

你好
 
谢谢你的链接,我已经看过这个例子了
一旦用户更改UCS,项目仍会绘制到WCS并插入。
 
做这件事的时候我有点不知所措
必须使用TransformBy(UCSMatrix)
 
谢谢,谢谢
页: [1]
查看完整版本: VB。UCS上的净绘制圆