- 积分
- 848
- 明经币
- 个
- 注册时间
- 2008-8-16
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2014-9-15 08:27:49
|
显示全部楼层
我列出我的问题吧:
DWGdirect.Runtime.Services dd;
Graphics graphics;
DWGdirect.GraphicsSystem.LayoutHelperDevice helperDevice;
Database database = null;
Point3dCollection grips = new Point3dCollection();
ObjectIdCollection selected = new ObjectIdCollection();
Point2d startSelPoint;
Point3d firstCornerPoint;
在 private void panel1_MouseDown(object sender, MouseEventArgs e)
{
startSelPoint = new Point2d(e.X, e.Y);
//增加entity
LayerTableRecord ltr = cadLayer.GetLayer("00000", database);
cadLayer.SetCurrentLayer(ltr, database);
DWGdirect.DatabaseServices.Polyline ent1 = new DWGdirect.DatabaseServices.Polyline();
ent1.AddVertexAt(0, startSelPoint, 0, 10, 10);
ent1.AddVertexAt(1, new Point2d(e.X + 100, e.Y + 100), 0, 10, 10);
ent1.AddVertexAt(2, new Point2d(e.X + 200, e.Y + 300), 0, 10, 10);
using (Transaction tr = database.TransactionManager.StartTransaction())
{
//ObjectId id;
BlockTable bt = (BlockTable)tr.GetObject(database.BlockTableId, OpenMode.ForWrite);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(database.CurrentSpaceId, OpenMode.ForWrite);
ent1.ColorIndex = 1;
ent1.LineWeight = LineWeight.LineWeight005;
//ent1.Layer = "00000"; //这样不注释掉,出现异常,注释掉,也看不见绘制的entity
btr.AppendEntity(ent1);
tr.AddNewlyCreatedDBObject(ent1, true);
tr.Commit();
}
//database.Save();
helperDevice.Invalidate();
Invalidate();
}
飞狐,错误在哪儿? |
|