我想对用户修改的对象做一些事情,但我就是不能让它在我的事件处理程序中工作,而且在我看来,问题是ObjectID不正确。在第二个代码片段中,我做了一些测试,一切都如我所愿。如何正确访问ObjectID?
预先感谢。
- public void acPolyMod(object senderObj, EventArgs evtArgs)
- {
- Tables tables = HostMapApplicationServices.Application.ActiveProject.ODTables;
- Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
- Entity ent = senderObj as Entity;
- ObjectId id = ent.ObjectId;
- Autodesk.Gis.Map.ObjectData.Table table = tables[m_tableName];
- Records records = table.GetObjectTableRecords(0, id, Autodesk.Gis.Map.Constants.OpenMode.OpenForWrite, true);
- if (records.Count == 0)
- {
- AddODRecord(tables, m_tableName, id, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
- }
- else
- {
- UpdateOD(m_tableName, id, "Date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
- }
- }
我的测试代码:
- public void asd()
- {
- Tables tables = HostMapApplicationServices.Application.ActiveProject.ODTables;
- Editor AcadEditor = Application.DocumentManager.MdiActiveDocument.Editor;
- AcadEditor.WriteMessage("\n Please select an entity to add a record: ");
- PromptSelectionOptions options = new PromptSelectionOptions();
- options.SingleOnly = true;
- options.SinglePickInSpace = true;
- PromptSelectionResult result = AcadEditor.GetSelection(options);
- ObjectId[] ids = result.Value.GetObjectIds();
- AddODRecord(tables, m_tableName, ids[0], DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
- UpdateOD(m_tableName, ids[0], "Date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
-
- }
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |