Community
Hi All,
I'm looking at developing an exporter (or an export enhancer) plugin for Autodesk Architecture.
I've watched webinars and looked at the AEC samples at C:\Program Files\Autodesk\AutoCAD 2015\Sample\CS.NET
but I'm still having problems with getting started.
Can anyone please help (or point me in the direction of resources) with some sample code to extract building levels and names from a project (as per image)?
Thanks in advance,
Jon
Dear Jon,
Sorry to hear that you are having a hard time finding answers to such fundamental questions.
Here is some code that achieves just what you need:
//. . . using Autodesk.Aec.Building.ApplicationServices; // for BuildingDBVariables //. . . // Helper to get MEP Named Elevations (keys) and their heights (values) static public Dictionary<string, double> GetNamedElevations(Database db) { Dictionary<string, double> res = newDictionary<string, double>(); try { using (Transaction trans = db.TransactionManager.StartTransaction()) { // NOD DBDictionary nod = trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead) asDBDictionary; // AEC_VARS Dict DBDictionary dbDict = trans.GetObject(nod.GetAt("AEC_VARS"), OpenMode.ForRead) asDBDictionary; // AEC_VARS_BUILDING_SYSTEMS Record ObjectId objId = dbDict.GetAt("AEC_VARS_BUILDING_SYSTEMS"); BuildingDBVariables vars = trans.GetObject(objId, OpenMode.ForWrite) asBuildingDBVariables; // Loop all Named Elevations StringCollection elevations = vars.Elevations; foreach (string str in elevations) { // They are in format "[name] |[height] |[description]" string[] tokens = str.Split('|'); if (tokens.GetUpperBound(0) > 1) { string key = tokens[0].Trim(); double val; if(double.TryParse(tokens[1].Trim(), out val)) { try { res.Add(key, val); } catch { } } } } //// To ADD one //string newElevation = "Test |500 |Just a test"; //elevations.Add(newElevation); //vars.Elevations = elevations; trans.Commit(); } } catch { } return res; }
I hope this helps.
Cheers,
Jeremy