This post was inspired by an email I saw from Philippe Leefsma, from DevTech EMEA, which made use of the Autodesk.AutoCAD.Windows.Data namespace – something I didn’t even know existed.
The specific example Philippe showed was how to access the list of hatch patterns available in the current drawing without iterating through the relevant dictionary in the named objects dictionary.
Here’s Philippe’s C# code:
public class DataStuff
static public void GetHatchPatterns()
Editor ed =
string str in HatchPatterns.Instance.AllPatterns)
ed.WriteMessage("\n" + str);
When we run it, we see the following output at the command-line:
I was curious about this namespace and so asked around to find out more about its origins. Apparently it was introduced to provide simplified access to data that needs to be displayed in the AutoCAD user interface: we expose this data through Autodesk.AutoCAD.Windows.Data to make it simpler to implement the ribbon without having to iterate database objects there directly. What’s nice is the data changes when the connected database does: whether relevant items are added to, edited in or removed from the database, or the user changes the currently active drawing in the editor, the data made accessible is adjusted accordingly.
This capability is known internally as the BOL or Bindable Object Layer. Cool stuff.
At this stage, I didn’t find a way to access other data from this namespace: HatchPatterns is the only class with a static Instance property that provides access to it. There is a very interesting DataBindings class, that appears to provide access to the data in the rest of the namespace, but I so far have been unable to find a way to instantiate (or retrieve an existing instance of it).