使用Architecture 2012进行了测试,没有出现任何错误
- [CommandMethod("NoError")]
- static public void NoError()
- {
- Database db = HostApplicationServices.WorkingDatabase;
- Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
- using (Transaction trx = db.TransactionManager.StartTransaction())
- {
-
- BlockTable bt = trx.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
- BlockTableRecord btr = trx.GetObject(bt[blockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;
- foreach (ObjectId id in btr)
- {
- if (!(id.ObjectClass.Name == "AecDbDoor"))
- {
- continue;
- }
- Door doorEntity = trx.GetObject(id, OpenMode.ForRead) as Door;
- ObjectIdCollection idsPropSet = PropertyDataServices.GetPropertySets(doorEntity);
- foreach (ObjectId idPropSet in idsPropSet)
- {
- PropertySet propSet = trx.GetObject(idPropSet, OpenMode.ForRead) as PropertySet;
- PropertySetDefinition propSetDef = trx.GetObject(propSet.PropertySetDefinition, OpenMode.ForRead) as PropertySetDefinition;
- PropertyDefinitionCollection propDefs = propSetDef.Definitions;
- foreach (PropertyDefinition propDef in propDefs)
- {
- if (propDef is PropertyDefinitionLocation) //the Space
- {
- ObjectIdCollection idsDummy = new ObjectIdCollection();
- {
- //this does NOT give me eInvalidInput error
- ed.WriteMessage("\n" + propSetDef.GetValue(propDef.Id, id, idsDummy).ToString());
- }
- }
- }
- }
- }
- trx.Commit();
- }
- }
|