转载自  Cad人生  的博客

链接:http://www.cnblogs.com/cadlife/articles/2668158.html

内容粘贴如下,小伙伴们可以看看哦。

 using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.AutoCAD.EditorInput ;
using Autodesk.AutoCAD.Runtime ;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices ;
namespace CH02
{
public class Class1
{
//--------------------------------------------------------------
// 功能:获取用户输入
// 作者:
// 日期:2007-7-20
// 说明:
//
//----------------------------------------------------------------
[CommandMethod("GetData")]
public void GetData()
{
//获取Editor对象
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
//获取整型数据
PromptIntegerOptions intOp = new PromptIntegerOptions("请输入多边形的边数:");
PromptIntegerResult intRes;
intRes = ed.GetInteger(intOp);
//判断用户输入
if (intRes.Status == PromptStatus.OK)
{
int nSides = intRes.Value;
ed.WriteMessage("多边形的边数为:" + nSides);
} if (intRes.Status == PromptStatus.Cancel)
{
ed.WriteMessage("用户按了取消ESC键/n" );
}
}
//--------------------------------------------------------------
// 功能:要求用户输入点
// 作者:
// 日期:2007-7-20
// 说明:
//
//----------------------------------------------------------------
[CommandMethod("PickPoint")]
static public void PickPoint()
{
//获取Editor对象
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptPointOptions promptPtOp = new PromptPointOptions("选择一个点:");
//指定的基点,如果指定了该点,则在选择的时候绘制一条橡皮线。
promptPtOp.BasePoint = new Autodesk.AutoCAD.Geometry.Point3d(, , );
PromptPointResult resPt;
resPt = ed.GetPoint(promptPtOp);
if (resPt.Status == PromptStatus.OK)
{
ed.WriteMessage("选择的点为:" + resPt.Value.ToString());
}
} //--------------------------------------------------------------
// 功能:获取选择集
// 作者:
// 日期:2007-7-20
// 说明:
//
//----------------------------------------------------------------
[CommandMethod("SelectEnt")]
static public void SelectEnt()
{
//获取Editor对象
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptSelectionOptions selectionOp = new PromptSelectionOptions();
PromptSelectionResult ssRes = ed.GetSelection(selectionOp);
if (ssRes.Status == PromptStatus.OK)
{
SelectionSet SS = ssRes.Value;
int nCount = SS.Count;
ed.WriteMessage("选择了{0}个实体" , nCount);
}
}
//--------------------------------------------------------------
// 功能:获取选择集(带过滤)
// 作者:
// 日期:2007-7-20
// 说明:
//
//----------------------------------------------------------------
[CommandMethod("SelectEnt2")]
static public void SelectEnt2()
{
//获取Editor对象
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
// 定义选择集选项
PromptSelectionOptions selectionOp = new PromptSelectionOptions();
//创建选择集过滤器,只选择块对象
TypedValue[] filList = new TypedValue[];
filList[] = new TypedValue((int)DxfCode.Start, "INSERT");
SelectionFilter filter = new SelectionFilter(filList);
PromptSelectionResult ssRes = ed.GetSelection(selectionOp, filter);
if (ssRes.Status == PromptStatus.OK)
{
SelectionSet SS = ssRes.Value;
int nCount = SS.Count;
ed.WriteMessage("选择了{0}个块" , nCount);
}
}
} }
using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
namespace CH03
{
public class Class1
{
//--------------------------------------------------------------
// 功能:创建一个新层
// 作者:
// 日期:2007-7-20
// 说明:
//
//----------------------------------------------------------------
[CommandMethod("CreateLayer")]
public void CreateLayer()
{
ObjectId layerId;
Database db = HostApplicationServices.WorkingDatabase;
//开始一个事务
Transaction trans = db.TransactionManager.StartTransaction();
try
{
//首先取得层表
LayerTable lt = (LayerTable)trans.GetObject(db.LayerTableId, OpenMode.ForWrite);
//检查MyLayer层是否存在
if (lt.Has("MyLayer"))
{
layerId = lt["MyLayer"];
}
else
{
//如果MyLayer层不存在,就创建它
LayerTableRecord ltr = new LayerTableRecord();
ltr.Name = "MyLayer"; //设置层的名字
layerId = lt.Add(ltr);
trans.AddNewlyCreatedDBObject(ltr, true);
}
//提交事务
trans.Commit();
}
catch (Autodesk.AutoCAD.Runtime.Exception e)
{
//放弃事务
trans.Abort();
}
finally
{
// 显式地释放
trans.Dispose();
}
}
//--------------------------------------------------------------
// 功能:创建一个圆
// 作者:
// 日期:2007-7-20
// 说明:
//
//----------------------------------------------------------------
[CommandMethod("CreateCircle")]
public void CreateCircle()
{
Database db = HostApplicationServices.WorkingDatabase;
// 使用 "using" ,结束是自动调用事务的 "Dispose"
using (Transaction trans = db.TransactionManager.StartTransaction())
{
//获取块表和模型空间
BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
//创建一个圆并添加到块表记录(模型空间)
Point3d center = new Point3d(, , );
Circle circle = new Circle(center, Vector3d.ZAxis, 10.0);
circle.ColorIndex = ;
btr.AppendEntity(circle);
trans.AddNewlyCreatedDBObject(circle, true);
trans.Commit();
}
}
//--------------------------------------------------------------
// 功能:创建一个块定义(块表记录)
// 作者:
// 日期:2007-7-20
// 说明:
//
//----------------------------------------------------------------
public ObjectId CreateBlkDef()
{
//定义函数的返回值ObjectId
ObjectId blkObjId = new ObjectId();
Database db = HostApplicationServices.WorkingDatabase;
// 使用 "using"关键字指定事务的边界
using (Transaction trans = db.TransactionManager.StartTransaction())
{
//获取块表
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForWrite);
//通过块名myBlkName判断块表中是否包含块表记录
if ((bt.Has("myBlkName")))
{
blkObjId = bt["myBlkName"];//如果已经存在,通过块名获取块对应的ObjectId
}
else
{
//创建一个圆
Point3d center = new Point3d(, , );
Circle circle = new Circle(center, Vector3d.ZAxis, );
circle.ColorIndex = ;
//创建文本Text:
MText text = new MText();
text.Contents = " ";
text.Location = center;
text.ColorIndex = ;
//创建新的块表记录 myBlkName
BlockTableRecord newBtr = new BlockTableRecord();
newBtr.Name = "myBlkName";
newBtr.Origin = center;
//保存块表记录到块表
blkObjId = bt.Add(newBtr); // 返回块对应的ObjectId
trans.AddNewlyCreatedDBObject(newBtr, true); //Let the transaction know about any object/entity you add to the database! //保存新创建的实体到块表记录
newBtr.AppendEntity(circle);
newBtr.AppendEntity(text);
// 通知事务新创建了对象
trans.AddNewlyCreatedDBObject(circle, true);
trans.AddNewlyCreatedDBObject(text, true);
}
trans.Commit(); //提交事务
}
return blkObjId;
} //--------------------------------------------------------------
// 功能:创建一个块引用
// 作者:
// 日期:2007-7-20
// 说明:
//
//----------------------------------------------------------------
[CommandMethod("CreateBlk")]
public void CreateBlkRef()
{ //获取块的插入点
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptPointOptions ptOps = new PromptPointOptions("选择块的插入点");
PromptPointResult ptRes;
ptRes = ed.GetPoint(ptOps);
Point3d ptInsert;
if (ptRes.Status == PromptStatus.OK)
{
ptInsert = ptRes.Value ;
}
else
{
ptInsert = new Point3d(, , );
}
Database db = HostApplicationServices.WorkingDatabase;
// 使用 "using"关键字指定事务的边界
using (Transaction trans = db.TransactionManager.StartTransaction())
{
//获取块表和模型空间
BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForWrite));
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); //创建块引用
BlockReference blkRef = new BlockReference(ptInsert,CreateBlkDef());// 指定插入点和所引用的块表记录
blkRef.Rotation = 1.57;//指定旋转角,按弧度
//保存新创建的块引用到模型空间
btr.AppendEntity(blkRef);
trans.AddNewlyCreatedDBObject(blkRef, true); // 通知事务新创建了对象
trans.Commit(); //提交事务
} }
//--------------------------------------------------------------
// 功能:读取对象的属性
// 作者:
// 日期:2007-7-20
// 说明:
//
//----------------------------------------------------------------
[CommandMethod("OpenEnt")]
public void OpenEnt()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptEntityOptions entOps = new PromptEntityOptions("选择要打开的对象");
PromptEntityResult entRes;
entRes = ed.GetEntity(entOps);
if (entRes.Status != PromptStatus.OK)
{
ed.WriteMessage("选择对象失败,退出");
return;
}
ObjectId objId = entRes.ObjectId;
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
Entity ent = (Entity)trans.GetObject(objId, OpenMode.ForWrite);
ent.ColorIndex = ;
trans.Commit();
}
}
}
}
 using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
namespace CH04
{
public class Class1
{ //--------------------------------------------------------------
// 功能:通过ObjectId打开对象
// 作者:
// 日期:2007-7-20
// 说明:
//
//----------------------------------------------------------------
[CommandMethod("OpenEnt")]
public void OpenEnt()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("通过ObjectId打开对象\n");
PromptEntityOptions entOps = new PromptEntityOptions("选择要打开的对象\n");
PromptEntityResult entRes;
entRes = ed.GetEntity(entOps);
if (entRes.Status != PromptStatus.OK)
{
ed.WriteMessage("选择对象失败,退出");
return;
}
ObjectId objId = entRes.ObjectId;
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
Entity ent = trans.GetObject(objId, OpenMode.ForWrite) as Entity ;
ent.ColorIndex = ;
trans.Commit();
} }
//--------------------------------------------------------------
// 功能:类型识别和转换
// 作者:
// 日期:2007-7-20
// 说明:
//
//----------------------------------------------------------------
[CommandMethod("GetType")]
public void GetType()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("数据库对象的类型识别和转换\n");
PromptEntityOptions entOps = new PromptEntityOptions("选择要打开的对象");
PromptEntityResult entRes;
entRes = ed.GetEntity(entOps);
if (entRes.Status != PromptStatus.OK)
{
ed.WriteMessage("选择对象失败,退出");
return;
}
ObjectId objId = entRes.ObjectId;
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
Entity ent = trans.GetObject(objId, OpenMode.ForWrite) as Entity;
ed.WriteMessage("ent.GetRXClass().Name :" + ent.GetRXClass().Name + "\n");
if (ent is Line)
{
Line aLine = ent as Line;
aLine.ColorIndex = ;
}
else if (ent.GetType() == typeof(Circle))
{
Circle cir = (Circle)ent;
cir.ColorIndex = ;
}
trans.Commit();
}
}
//--------------------------------------------------------------
// 功能:实体对象的属性
// 作者:
// 日期:2007-7-20
// 说明:
//
//----------------------------------------------------------------
[CommandMethod("EntPro")]
public void EntPro()
{ Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("实体对象的属性\n");
PromptEntityOptions entOps = new PromptEntityOptions("选择要打开的对象\n");
PromptEntityResult entRes;
entRes = ed.GetEntity(entOps);
if (entRes.Status != PromptStatus.OK)
{
ed.WriteMessage("选择对象失败,退出\n");
return;
}
ObjectId objId = entRes.ObjectId;
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
Entity ent = trans.GetObject(objId, OpenMode.ForWrite) as Entity;
ed.WriteMessage("获取或设置实体的线型\n");
ed.WriteMessage("实体的原先的线型为 :" + ent.Linetype + "\n");
// 获取线型表记录
LinetypeTable lineTypeTbl = trans.GetObject(db.LinetypeTableId, OpenMode.ForRead) as LinetypeTable;
// 确保DOT线型名已经加载到当前数据库
LinetypeTableRecord lineTypeTblRec = trans.GetObject(lineTypeTbl["DOT"], OpenMode.ForRead) as LinetypeTableRecord;
// 设置实体的线型
ent.LinetypeId = lineTypeTblRec.ObjectId;
// 设置实体的线型比例
ed.WriteMessage("设置实体的线型比例为2.0\n");
ent.LinetypeScale = 2.0;
//设置实体的可见性
ent.Visible = true;
//设置实体所在的层
ed.WriteMessage("实体的原先所在的层为 :" + ent.Layer + "\n");
ent.Layer = "layer0";
trans.Commit();
}
}
}
}
 using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
namespace CH05
{
public class Class1
{
//--------------------------------------------------------------
// 功能:添加扩展数据XDATA
// 作者:
// 日期:2007-7-20
// 说明:
//
//----------------------------------------------------------------
[CommandMethod("AddXData")]
public void AddXData()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("添加扩充数据XDATA\n");
PromptEntityOptions entOps = new PromptEntityOptions("选择要打开的对象\n");
PromptEntityResult entRes;
entRes = ed.GetEntity(entOps);
if (entRes.Status != PromptStatus.OK)
{
ed.WriteMessage("选择对象失败,退出");
return;
}
ObjectId objId = entRes.ObjectId;
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
Entity ent = trans.GetObject(objId, OpenMode.ForWrite) as Entity ;
ent.ColorIndex = ;
RegAppTable appTbl = trans.GetObject(db.RegAppTableId, OpenMode.ForWrite) as RegAppTable ;
if (!appTbl.Has("MyAppName"))
{
RegAppTableRecord appTblRcd = new RegAppTableRecord();
appTblRcd.Name = "MyAppName";
appTbl.Add(appTblRcd);
trans.AddNewlyCreatedDBObject(appTblRcd, true);
}
ResultBuffer resBuf = new ResultBuffer();//new TypedValue(1001, "MyAppName"), new TypedValue(1000, "开发部门"));
resBuf.Add(new TypedValue(, "MyAppName"));//注册程序名称
resBuf.Add(new TypedValue( , " 张三"));//姓名
resBuf.Add(new TypedValue( , " 工程部"));//部门
resBuf.Add(new TypedValue(, 2000.0));//薪水
ent.XData = resBuf;
trans.Commit();
} } //--------------------------------------------------------------
// 功能:获取扩展数据XDATA
// 作者:
// 日期:2007-7-20
// 说明:
//
//------------------------------------------------------------
[CommandMethod("GETXDATA")]
public void GETXDATA()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("获取扩充数据XDATA\n");
PromptEntityOptions entOps = new PromptEntityOptions("选择带扩展数据的对象");
PromptEntityResult entRes = ed.GetEntity(entOps);
if (entRes.Status != PromptStatus.OK)
{
ed.WriteMessage("选择对象失败,退出");
return;
}
Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
Entity ent = (Entity)trans.GetObject(entRes.ObjectId, OpenMode.ForRead);
ResultBuffer resBuf = ent.XData;
if (resBuf != null)
{
//
IEnumerator iter = resBuf.GetEnumerator();
while (iter.MoveNext())
{
TypedValue tmpVal = (TypedValue)iter.Current;
ed.WriteMessage(tmpVal.TypeCode.ToString() + ":");
ed.WriteMessage(tmpVal.Value.ToString() + "\n");
}
}
}
}
//--------------------------------------------------------------
// 功能:在命名对象词典中添加数据
// 作者:
// 日期:2007-7-20
// 说明:
//
//------------------------------------------------------------
[CommandMethod("AddInNOD")]
public void AddInNOD()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("在命名对象词典中添加数据\n");
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
//获取命名对象词典(NOD)
DBDictionary NOD =trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForWrite) as DBDictionary ;
// 声明一个新的词典
DBDictionary copyrightDict;
// 判断是否存在COPYRIGHT词典,没有则创建
try
{
// 获取COPYRIGHT词典
copyrightDict = (DBDictionary)trans.GetObject(NOD.GetAt("COPYRIGHT"), OpenMode.ForRead);
}
catch
{
//在NOD下创建COPYRIGHT词典
copyrightDict = new DBDictionary();
NOD.SetAt("COPYRIGHT", copyrightDict);
trans.AddNewlyCreatedDBObject(copyrightDict, true);
}
// 在copyrightDict中,获取或创建 "author" 词典
DBDictionary authorDict;
try
{
authorDict = (DBDictionary)trans.GetObject(copyrightDict.GetAt("Author"), OpenMode.ForWrite);
}
catch
{
authorDict = new DBDictionary();
//"author" doesn't exist, create one
copyrightDict.UpgradeOpen();
copyrightDict.SetAt("Author", authorDict);
trans.AddNewlyCreatedDBObject(authorDict, true);
}
// 通过Xrecord和ResultBuffer添加扩展数据
Xrecord authorRec;
try
{
authorRec = (Xrecord)trans.GetObject(authorDict.GetAt("AuthorInfo"), OpenMode.ForWrite);
}
catch
{
authorRec = new Xrecord();
authorRec.Data = new ResultBuffer(new TypedValue((int)DxfCode.Text, "张三"));
authorDict.SetAt("AuthorInfo", authorRec);
trans.AddNewlyCreatedDBObject(authorRec, true);
}
trans.Commit();
}
}
//--------------------------------------------------------------
// 功能:获取命名对象词典中的数据
// 作者:
// 日期:2007-7-20
// 说明:
//
//------------------------------------------------------------
[CommandMethod("GetInNOD")]
public void GetInNod()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("获取命名对象词典中数据\n");
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
// 获取NOD
DBDictionary NOD = (DBDictionary)trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead, false);
// 获取COPYRIGHT词典
DBDictionary copyrightDict = (DBDictionary)trans.GetObject(NOD.GetAt("COPYRIGHT"), OpenMode.ForRead);
// 获取Author词典
DBDictionary AuthorDict = (DBDictionary)trans.GetObject(copyrightDict.GetAt("Author"), OpenMode.ForRead);
// 获取AuthorInfo扩展记录Xrecord
Xrecord authorXRec = (Xrecord)trans.GetObject(AuthorDict.GetAt("AuthorInfo"), OpenMode.ForRead);
ResultBuffer resBuf = authorXRec.Data;
TypedValue val = resBuf.AsArray()[];
ed.WriteMessage("该图纸由{0}设计\n", val.Value);
}
}
//--------------------------------------------------------------
// 功能:添加数据到数据库对象的扩展词典中
// 作者:
// 日期:2007-7-20
// 说明:
//
//------------------------------------------------------------
[CommandMethod("AddExtDict")]
public void AddExtDict()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("创建对象扩展词典\n");
PromptEntityOptions entOps = new PromptEntityOptions("选择要添加扩展数据的块\n");
PromptEntityResult entRes = ed.GetEntity(entOps);
if (entRes.Status != PromptStatus.OK)
{
ed.WriteMessage("选择对象失败,退出");
return;
}
Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
DBObject obj = trans.GetObject(entRes.ObjectId, OpenMode.ForWrite) as DBObject;
BlockReference blkRef;
if (obj is BlockReference)
{
blkRef = obj as BlockReference;
}
else
{
return;
}
// 创建对象的扩展词典
blkRef.CreateExtensionDictionary();
DBDictionary extensionDict = (DBDictionary)trans.GetObject(blkRef.ExtensionDictionary, OpenMode.ForWrite, false); // 通过Xrecord准备附加属性数据
Xrecord xRec = new Xrecord();
xRec.Data = new ResultBuffer(
new TypedValue((int)DxfCode.Text, "张三"),// 姓名
new TypedValue((int)DxfCode.Real, 1200.0),//薪水
new TypedValue((int)DxfCode.Text, "技术部"));// 部门
// 在扩展词典中添加扩展记录
extensionDict.SetAt("EmployeeInfomation", xRec);
trans.AddNewlyCreatedDBObject(xRec, true);
trans.Commit();
}
} //--------------------------------------------------------------
// 功能:获取数据库对象的扩展词典中的数据
// 作者:
// 日期:2007-7-20
// 说明:
//
//------------------------------------------------------------
[CommandMethod("GetExtDict")]
public void GetExtDict()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("获取对象扩展词典信息\n");
PromptEntityOptions entOps = new PromptEntityOptions("选择添加了扩展数据的块\n");
PromptEntityResult entRes = ed.GetEntity(entOps);
if (entRes.Status != PromptStatus.OK)
{
ed.WriteMessage("选择对象失败,退出");
return;
}
Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
DBObject obj = trans.GetObject(entRes.ObjectId, OpenMode.ForWrite) as DBObject;
BlockReference blkRef;
if (obj is BlockReference)
{
blkRef = obj as BlockReference;
}
else
{
ed.WriteMessage("选择对象不是块,退出\n");
return;
}
// 创建对象的扩展词典
DBDictionary extensionDict = (DBDictionary)trans.GetObject(blkRef.ExtensionDictionary, OpenMode.ForWrite, false);
// 获取AuthorInfo扩展记录Xrecord
Xrecord EmpXRec = (Xrecord)trans.GetObject(extensionDict.GetAt("EmployeeInfomation"), OpenMode.ForRead);
ResultBuffer resBuf = EmpXRec.Data;
TypedValue val = resBuf.AsArray()[];
ed.WriteMessage("是员工姓名:{0}\n", val.Value);
val = resBuf.AsArray()[];
ed.WriteMessage("该员工的薪水:{0}\n", val.Value);
val = resBuf.AsArray()[];
ed.WriteMessage("该员工属于:{0}\n", val.Value); trans.Commit();
}
}
}
}

推荐net开发cad入门阅读代码片段的更多相关文章

  1. WebApp 开发中常用的代码片段

    其实这里面的多数都是 iOS 上面的代码.其他平台的就没有去验证了. HTML, 从HTML文档的开始到结束排列: <meta name=”viewport” content=”width=de ...

  2. 提高php开发效率的9大代码片段

    在网站开发中,我们都期望能高效快速的进行程序开发,如果有能直接使用的代码片段,提高开发效率,那将是极好的.php开发福利来了,今天小编就将为大家分享9大超实用的.可节省大量开发时间的php代码片段. ...

  3. (转:亲测)cnblogs博文浏览[推荐、Top、评论、关注、收藏]利器代码片段

    authour: Others(hoojo) updatetime: 2015-04-25 09:30:23 friendly link: http://www.cnblogs.com/hoojo/a ...

  4. chrome devtools tip(2)--自定义代码片段,构建你的工具箱

    平常开发中,有些代码片段常常用到的,比如,获取 url 参数,rgb转16进制,打印下当前页面的性能数据,给所有的 span 加个样式, 防抖节流,fetch接口,类似 jquery这样的顺手 选择 ...

  5. 9段高效率开发PHP程序的代码

    php是世界上最好的语言 在php网站开发中,大家都希望能够快速的进行程序开发,如果有能直接使用的代码片段,提高开发效率,那将是起飞的感觉.今天由杭州php工程师送出福利来了,以下9段高效率开发PHP ...

  6. 自学 Python 3 最好的 入门 书籍 推荐(附 免费 在线阅读 下载链接)

    请大家根据自己的实际情况对号入座,挑选适合自己的 Python 入门书籍: 完全没有任何编程基础:01 号书 少量编程基础,不求全,只希望能以最快的速度入门:02 号书 少量编程基础,有一定的英文阅读 ...

  7. 10个 jQuery 代码片段,可以帮你快速开发。

    转载自:http://mp.weixin.qq.com/s/mMstI10vqwu8PvUwlLborw 1.返回顶部按钮 你可以利用 animate 和 scrollTop 来实现返回顶部的动画,而 ...

  8. js/jquery/html前端开发常用到代码片段

    1.IE条件注释 条件注释简介 IE中的条件注释(Conditional comments)对IE的版本和IE非IE有优秀的区分能力,是WEB设计中常用的hack方法.条件注释只能用于IE5以上,IE ...

  9. 非常实用的PHP代码片段推荐

    当使用PHP进行开发的时候,如果你自己收 藏 了一些非常有用的方法或者代码片段,那么将会给你的开发工作带来极大的便利.今天我们将介绍10个超级好用的PHP代码片段,希望大家能够喜欢! 1.  使用te ...

随机推荐

  1. ssr panel魔改前端登陆面板配置邮件服务

    1.注册 打开mailgun官网http://www.mailgun.com/ (昨天他反应打开比较慢,所以你得有点耐心,或者跟换你的DNS试试)   QQ截图20140731095618.png 点 ...

  2. CentOS配置本地yum源

    如果CentOS服务器处在内网环境中时,如果缺少依赖手动安装那么会非常麻烦,要花费很多时间来寻找rpm包,现在如果搭建本地的yum源,就非常方便了,使用yum源首先需要一个CentOS安装镜像,去官网 ...

  3. video常用功能

    本文的目录: 1.获取影片总时长2.播放.暂停3.获取影片已播放时间和设置播放点4.音量的获取和设置 第一.获取影片总时长 对播放器(video)操作,首先要得到的是影片的一些信息,其中一个就是总时长 ...

  4. Spring Mobile——探测客户端设备和系统

    Spring Mobile--探测客户端设备和系统 今天闲来无事,浏览Spring的官方网站,发现了Spring Mobile项目,之前也看到过,还以为是针对手机端的项目,并没有细看.今天仔细看了一下 ...

  5. 案例:中科院光机所应用大数据可视化工具-LightningChart | 见证高性能图表

    中国科学院上海光学精密机械研究所 中国现代光学和激光科学领域领先研究所 中国科学院上海光学精密机械研究所(简称中科院上海光机所)是我国建立最早.规模最大的激光专业研究所,成立于1964年,现已发展成为 ...

  6. passwd命令使用

    2018-03-01  10:01:06 例1:passwd username 直接修改用户的密码普通用户可以且只能修改自己的密码,root用户可以修改任何人的密码[root@localhost ~] ...

  7. git远程提交失败

    同步仓库并解决403报错 这时候对本地仓库和github进行同步 # git push -u origin master error: The requested URL returned error ...

  8. iOS 组件化的几篇文章

    随着工程的成长,开发人员的增多,合理的模块划分及低耦合的重要性显得愈发重要.最近在思考这方面的问题,也读了不少通过组件化解耦的文章,这里记录一下. 前 5 篇文章有些关联,建议阅读顺序,1.3.2.4 ...

  9. MySql (MariaDB)的varchar字段的存储的是字符还是字节

    关于varchar字段: 在version4之前,按字节: version5之后,按字符. 现在普遍都按字符算:无论中文英文,都算一个字符 既: varchar(10) == '123456789a' ...

  10. 利用国外服务器搭建ss

    wget --no-check-certificate  https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/s ...