- 积分
- 522
- 明经币
- 个
- 注册时间
- 2006-6-20
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2011-4-23 18:39:02
|
显示全部楼层
我试验了一下 发现给字典添加键值 一个commit只能添加一个键值。 程序改成下面这个样子就能执行了不知道我理解的对不对。还请大家指教。
public class testNod1
{
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ObjectId objTemp = new ObjectId();
[CommandMethod("tesc")]
public void Test()
{
using (Transaction trans = db.TransactionManager.StartTransaction())
{
DBDictionary nod = (DBDictionary)trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForWrite);
DBDictionary sw_database = new DBDictionary();
ObjectId nodSw = nod.SetAt("sky_sw9527_database", sw_database);
trans.AddNewlyCreatedDBObject(sw_database, true);
DBDictionary nod1 = (DBDictionary)trans.GetObject(nodSw, OpenMode.ForWrite);
DBDictionary swGC_database = new DBDictionary();
ObjectId nodSw1 = nod1.SetAt("GC1", swGC_database);
trans.AddNewlyCreatedDBObject(swGC_database, true);
DBDictionary nod2 = (DBDictionary)trans.GetObject(nodSw1, OpenMode.ForWrite);
DBDictionary swPM_database = new DBDictionary();
ObjectId nodSw2 = nod2.SetAt("PMCD", swPM_database);
trans.AddNewlyCreatedDBObject(swPM_database, true);
DBDictionary nod3 = (DBDictionary)trans.GetObject(nodSw2, OpenMode.ForWrite);
DBDictionary swPM1_database = new DBDictionary();
ObjectId nodSw3 = nod3.SetAt("PM1", swPM1_database);
trans.AddNewlyCreatedDBObject(swPM1_database, true);
DBDictionary nod4 = (DBDictionary)trans.GetObject(nodSw3, OpenMode.ForWrite);
Xrecord xrec = new Xrecord();
xrec.Data = new ResultBuffer(new TypedValue((int)DxfCode.ExtendedDataWorldXCoordinate, new Point3d(10, 10, 0)));
ObjectId nodSw4 = nod4.SetAt("PM_qyPoint1", xrec);
trans.AddNewlyCreatedDBObject(xrec, true);
objTemp = nodSw3;
trans.Commit();
}
using (Transaction trans = db.TransactionManager.StartTransaction())
{
DBDictionary nod4 = (DBDictionary)trans.GetObject(objTemp, OpenMode.ForWrite);
Xrecord xrec = new Xrecord();
xrec.Data = new ResultBuffer(new TypedValue((int)DxfCode.Bool, true));
ObjectId nodSw5 = nod4.SetAt("PM_qykObjectId", xrec);
trans.AddNewlyCreatedDBObject(xrec, true);
trans.Commit();
}
using (Transaction trans = db.TransactionManager.StartTransaction())
{
DBDictionary nod4 = (DBDictionary)trans.GetObject(objTemp, OpenMode.ForWrite);
Xrecord xrec = new Xrecord();
xrec.Data = new ResultBuffer(new TypedValue((int)DxfCode.ExtendedDataWorldXCoordinate, new Point3d(10, 10, 0)));
ObjectId nodSw6 = nod4.SetAt("PM_qyPoint2", xrec);
trans.AddNewlyCreatedDBObject(xrec, true);
trans.Commit();
}
}
} |
|