December 18, 2006

The Mysteries of AutoCAD Object Data: Part 3

Custom Objects

My talented neighbors have recently finished another amazing automotive restoration. This one is a 70’s era pickup truck. Before the restoration the pickup wasn’t much to look at, and it left me thinking, why invest any time or money on this hunk of junk. The artistic eye of this teenage boy saw something more… a dream machine in the rough! And, possibly his choice may have had something to do with the fact that he had to buy the car himself. I think the original plan was that the son would work at his restaurant job and save the money to buy the necessary parts and materials… That lasted about a week and then dad couldn’t help himself. Now with a better bank roll… off came the paint, upholstery, the doors, bumpers, the truck bed, some of the side panels, the engine, the wheels… Many of these items would never return. It got to the point that so many parts we’re completely replaced and meticulously reworked that it would seem to me that it would have been certainly easier, and even cost effective to just open up the catalog and order an entire truck from parts and have UPS ship it to the garage for assembly! At one point the son and his sister’s boyfriend were just hanging-out on the front step scrubbing a bucket full of rusty bolts all day long.

Autodesk Map 3D is a collection add-on customization code to extend the data structures of the basic CAD data model of AutoCAD to support the attribution of its geometric primitives for use in mapping. Autodesk 3D Civil is the same type of application to extend AutoCAD for Civil Engineering. Their primary method of attribute storage is object data. Autodesk Map/Civil 3D cannot function solely with standard CAD graphic entities. They introduces more sophisticated GIS data structures in the form of AutoCAD custom objects.

The definitions of the AutoCAD custom objects are stored in the AutoCAD data dictionary like object data, in some ways these custom objects are like a block definition that is stored in the AutoCAD symbol tables. However like the x-records used to store object data the custom objects and their complex geometries are not discernable without the controlling application that created them. To manipulate these custom objects AutoCAD must be re-educated on how draw and manipulate these foreign data structures. It is the responsibility of the controlling application to instruct AutoCAD what the various methods and properties are that will be supported by the custom object.

Neither AutoCAD nor LT can understand these objects. Read/Only versions of certain applications called object enablers can be obtained by AutoCAD users to understand these complex objects and sometimes their attribute data. The other method of making a custom object more readable to applications like AutoCAD and AutoCAD LT is for the custom application to create a proxy geometry definition along with the custom object. ArcGIS 9.2 now reads proxy geometries of AutoCAD custom objects as GIS features. A proxy geometry may be a pretty good representation of the original geometry, without its clever behaviors and attribution or it may be something less than that, all depending on the application that defines it.

December 08, 2006

The Mysteries of AutoCAD Object Data: Part 2

Für Elise

My wife’s piano students had their Christmas recital this past weekend, and they were all splendid. Briana played Beethoven’s Fur Elise, but that is not my story at all. My daughter’s basketball team at her tiny school is gearing up for the basketball season and after the initial recruiting effort here is how it stacks up. Remembering this is a ninth grade team, we have three ninth graders, four eight graders, five seventh graders and one eleventh grader?!

…The problem is the eleventh grader, Elise. She is six foot tall and played point guard last year on the varsity team. The rest of last year’s varsity team were all 12th graders and they are gone. Remembering this school is tiny, Elise is the lone basketball player older than ninth grade. The solution… form two teams; a ninth grade team where most of the girls are already too young to play, and another team with the same girls and Elise to play varsity! I am just the assistant coach and I guess I must share in the blame for not saying no, but I guess it’s Für Elise!

Sometimes you work with what you’ve got, and object data is the right thing to use when attributing objects in the Autodesk infrastructure ad-on products to AutoCAD, I don’t have a choice. Problems only arises when I need to move the data into GIS. The first and most logical path for moving data with its attributes is to simply use the Map 3D function to convert the data to an ESRI Shapefile. You’re done... happy day.

…Ahhh, then there is the unfortunate fact that the double precision 3D ESRI Shapefile doesn’t support curves. The 3D double precision ESRI personal geodatabase does support curves and splines. For Autodesk Map users there is a new FDO plug-in for ESRI personal geodatabases. I am a strong proponent of the benefits of editing GIS data with a GIS application, with this Autodesk Map FDO provider, you can directly view features from an ESRI personal geodatabase using your existing seat of Autodesk Map, I have no idea if it works and not everything in the personal geodatabase is supported, but it sounds pretty cool.

Another method to retain both the attributes and curvilinear data not supported by a 3D ESRI Shapefile is to export the object data attributes and link them back up in the to the CAD entities in ArcGIS. I need to export the object data into some industry standard data format such as .dbf file or a text file or some other standard database-like format. I will want to ensure that included with a dump of the proprietary object data attributes that there is some key field upon which I can re-link the data once I am in a GIS. I will be able to perform a table join directly on the CAD data without converting the data or after I convert it if needed.

Another trick to get object data with curvilinear geometry is to create a Shapefile and only use the attribute table part. With ArcGIS, read the AutoCAD file directly, the AutoCAD entity handles will still be in the original drawing. Make sure the entity handle property is included in the output Shapefile’s attribute table. I can then ignore the geometry part of the Shapefile and link the AutoCAD file with the curvilinear data directly within ArcGIS to the .dbf part of the matching Shapefile’s attribute table. (This only works when I am working with Object Data on real AutoCAD entities rather than custom entities. …More about custom AutoCAD geometry later)

I can create my own AutoCAD applications that utilize Object Data. It may be necessary to utilize the AutoCAD API tools of AutoLISP, Visual LISP, VBA/VB, or VB .net to output a database file according to my controlling application’s logic using a customized script. I would then re-join to the CAD features from within ArcGIS to my output table of attributes using the AutoCAD entity handle as a key field.
Please read the comments from Dale Lutz below (click the comments link).

December 06, 2006

The Mysteries of AutoCAD Object Data: Part 1

I just had a conversation with my mother in law regarding ideas for gifts for my 13 year old daughter. She called to get some suggestions from me. I asked her if she had seen the Christmas list my daughter had compiled that was posted on our refrigerator at home. Her comment was, "Yes … (then a pause)… I read it, but I didn’t know what any of the words meant. "

Sample entries: … a Bluetooth Earbud, Aurvana Headset, Zen Microphoto MP3 silicon Skin, Manheim Steamroller CD…

My daughter lives in an era once removed from her grandmother. The world has been rewired (or rather unwired) since the gift buying days for her once teenage daughter (my wife). Even though my mother-in-law could read the list it doesn’t make any sense to her without help from the "controlling application" in this case, my wife and I, her granddaughter’s parents.

Initially the mechanical drawing pencil of AutoCAD was developed without the concept of user defined attributes. With the later introduction of the AutoCAD block attribute, text tags could be added to a point symbol to hold user defined attributes. I use AutoCAD block attributes to store descriptive information about points in AutoCAD as if they were GIS point features. These block attributes have a tag name that can be utilized like a field name. Multiple block attributes can be associated with a single block/point symbol to mimic a database record. The block attributes is limited in field type to ASCII text. ArcGIS supports these block symbols and attributes as fields in the CAD virtual attribute table and attempts to apply a field type to numbers or integers if the values are consistent throughout the drawing. Block attributes although easy to create, edit and read are only valid for point symbols (block inserts). There is no way to create similar attributes for AutoCAD lines or polygons.

The modern method of attribute data storage for AutoCAD entities is to use AutoCAD Object Data or external database links. For example the AutoCAD ad-on customization code that extends AutoCAD for mapping, Autodesk Map 3D uses this technique. Standard AutoCAD entities can be tagged with x-records that are stored in a section of the AutoCAD drawing called the data dictionary. Also stored in the AutoCAD data dictionary are things like M-Line Styles, Line Types and Groups. Both the schema (the fields names and data types), as well as the attribute values themselves are stored in the AutoCAD dictionary data constructs.
Industry standard interoperability tools have the ability to access and read the AutoCAD data dictionary like all other parts of the AutoCAD DWG/DXF file. However, the x-record values for object data style attributes are stored as binary chunks of information simplified for storage according to the encodings used by the controlling application. This means that although I as an AutoCAD user could use AutoLisp to read the value of x-records from the dictionary, what I see is just a proprietary blob of binary data. The information in the binary chunk could be analyzed, but because the meaning of the binary data is held by the controlling application it is like removing all the vowels, punctuation and spaces from a paragraph and then converting all the letters to numbers. Without any context whatsoever, the data is unusable. All that to say ArcGIS 9.2 still does not support AutoCAD Object Data.

Here is one resource that discusses the creation of GIS friendly CAD data for mapping.
FREE hit counter and Internet traffic statistics from freestats.com