AutoCAD Architecture Customization
Welcome to Autodesk’s AutoCAD Architecture Customization Forums. Share your knowledge, ask questions, and explore popular AutoCAD Architecture Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

.NET getting started

1 REPLY 1
Reply
Message 1 of 2
GeomGym
326 Views, 1 Reply

.NET getting started

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

 

140826 levels.png

1 REPLY 1
Message 2 of 2
jeremytammik
in reply to: GeomGym

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



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost