本文主要是介绍ObjectArx net 开发流程,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、保证有ARX
2、新建C#的类库dll;
3、添加引用(ARX目录下的inc文件夹中的所有dll)
添加类:
public class Class1{[CommandMethod("HelloWorld")]public void HelloWorld(){Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;ed.WriteMessage("Hello World");}//测试写入[CommandMethod("AddXRecordToEntity")]public void AddXRecordToEntity(){Document doc = Application.DocumentManager.MdiActiveDocument;Database db = doc.Database;PromptEntityResult per = doc.Editor.GetEntity("\nSelect an entity: ");if (per.Status != PromptStatus.OK){return;}using (Transaction tr = db.TransactionManager.StartTransaction()){Entity entity = tr.GetObject(per.ObjectId, OpenMode.ForWrite) as Entity;if (entity.ExtensionDictionary == ObjectId.Null){entity.CreateExtensionDictionary();}DBDictionary xDict = tr.GetObject(entity.ExtensionDictionary, OpenMode.ForRead) as DBDictionary;if (!xDict.Contains("CAXDEV")){xDict.UpgradeOpen();Xrecord xRec = new Xrecord();ResultBuffer rb = new ResultBuffer();rb.Add(new TypedValue((int)DxfCode.Text, "Hello www.caxdev.com"));rb.Add(new TypedValue((int)DxfCode.Int32, 123));rb.Add(new TypedValue((int)DxfCode.Real, 1.2345));xRec.Data = rb;xDict.SetAt("CAXDEV", xRec);tr.AddNewlyCreatedDBObject(xRec, true);}tr.Commit();}}}
这篇关于ObjectArx net 开发流程的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!