- 积分
- 2195
- 明经币
- 个
- 注册时间
- 2003-9-10
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
Public Function AddShape(ByVal ShapeName As String, ByVal Position As Point3d, ByVal Size As Double, ByVal Rotation As Double, ByVal WidthFactor As Double) As ObjectId
Dim Sh As New Shape(Position, Size, Rotation, WidthFactor)
Sh.Name = ShapeName
Return AddEntity(Sh, "添加形")
End Function
Public Function AddEntity(ByVal Ent As Entity, ByVal WriteMis As String) As ObjectId
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim btr As BlockTableRecord
Dim bt As BlockTable
Dim ObjId As ObjectId
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Dim ED As Editor
ED = Application.DocumentManager.MdiActiveDocument.Editor
Try
Using trans
bt = trans.GetObject(db.BlockTableId, OpenMode.ForWrite, False)
btr = trans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite, False)
ObjId = btr.AppendEntity(Ent)
trans.AddNewlyCreatedDBObject(Ent, True)
trans.Commit()
Return ObjId
End Using
trans.Dispose()
Catch EX As Exception
trans.Dispose()
ED.WriteMessage(WriteMis + EX.Message)
End Try
End Function
我采用了以上方法,就是不行,提示出错,无法找到形文件 |
|