A DWG/DXF file exported from Revit may not be always in a desired form. For example, a customer may wish to have more control over layer and layer colours. Developers I talked with seems to be able to use AutoCAD API to post process dwgs to meet such a need. One important information that you may want to be aware to do such a process is that dwg files exported from Revit has a extended data (xdata) attached to the AutoCAD entity. Here is the old DevNotes that I wrote long, long time ago. (In fact, it was probably my first DevNote about Revit I wrote pre-Revit API... time flies)
Issue
A DWG/DXF file exported from Revit contains Extended Data (or Xdata) attached to each entity. Could you explain what these data represent?
Solution
Every DWG (DXF) file created by Revit during the export contains Extended Data (or Xdata). Xdata created by Revit has an associated application name "REVIT." Each pair of values in the list defines the type identifier code and the value of an object parameter. Here is the definition of the codes and value types of the object parameters:
NAME OF PARAMETER CODE* DATA TYPE (GROUP CODE)
------------------------------------ ----------- -------------------------------------------
Element ID 1 Long (1071)
Category ID 2 Long (1071)
Sub-category ID 3 Long (1071)
Material ID 4 Long (1071)
Type ID 5 Long (1071)
Is Material Overridden By Face** 6 N/A***
*) The data type of the code is a 16-bit integer (its group code is 1070).
**) This parameter has meaning only for polymesh objects
***) There is no explicit value for this parameter. If the record for this parameter exists in the object, its value is true, otherwise false
Each object created by Revit export can contain one record for each parameter. The values of parameters are inherited by the hierarchy of the objects (e.g., from instance to block to polymesh). The value defined in the object overrides the inherited value.
The following is an example of an entity containing Revit's extended data in DXF format:
>>>>
AcDbEntity
8
3D-DOOR-SYMB
...
AcDbPolyFaceMesh
...
Extended entity definition data:
1001
REVIT
1002
{
1070
1
1071
52525
1070
2
1071
31431
1070
3
1071
27901
1070
4
1071
66553
1070
5
1071
12345
1070
6
1002
}
1001
<<<<
The meaning of definition is that this polymesh entity came from host object element with element ID equals 52525, category ID 31431, sub-category ID 27901, material ID 66553, type ID 12345, and its material was defined in the Revit's face itself (not inherited from the object definitions).
Named Object Dictionary:
-------------------------------------
To make the mapping between the category, sub-category and type IDs and their names, corresponding tables is created under the Named Object Dictionary (i.e., AcDbDictioinary of the name "REVIT_DICTIONARY"). REVIT_DICTIONARY contains the following idenifier and the information:
IDENTIFIER NAME IDENTIFIER MEANING
--------------------------- ----------------------------------
REVIT_CATEGORY_MAPPING The definition of the mapping between
category IDs and category names
REVIT_SUB_CATEGORY_MAPPING The definition of the mapping between
sub-category IDs and sub-category names
REVIT_TYPE_MAPPING The definition of the mapping between
type IDs and type names
Each table will be represented by Xrecord that is defined as the contents of a resbuf chain. Each entry in the table represents by the pair of data: id of type long and the name of type text.