I am still on my diving vacation on Ko Tao. Unfortunately, the visibility under water was really terrible yesterday, and diving conditions are not that good in general. The rain that normally falls in November never came last year and now the water is warmer than usual. The corals that enter into a symbiosis with certain algae which give them their colour have shed their guests and are all white, or even worse, covered in dirt and grey or green.
Yesterday we dived at the Southwest Pinnacle at a depth of 22 meters and aborted the dive after 25 minutes due to almost zero underwater visibilility, the worst ever seen, said some. We went over to Hin Ngam at Aow Leuk beach for a shallower dive away from the current, and that was a bit better. Anyway, today I am taking a day off diving and writing this instead.
Returning to Revit programming news, here is a technical note that has been available for quite a while that Joe just pointed out in a recent case and that I was not previously aware of:
Revit DWG/DXF export: specification of the extended data (xdata)
Question: A DWG/DXF file exported from Revit contains Extended Data (or Xdata) attached to each entity. Could you explain what this data represents?
Answer: 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 a list of the data stored:
- Element id
- Category id
- Sub-category id
- Material id
- Type id
- Is Material Overridden By Face
The first five data items are structured in pairs:
- First the above code 1 to 6 stored as a 16-bit integer with the DXF group code 1070.
- Second the id data stored as a 32-bit integer with the DXF group code 1071.
The material override information only applies to polymesh objects. There is no explicit value for that parameter. If the record for it 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 83 D-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
This means that this polymesh entity came from the host object element with element id 52525, category id 31431, sub-category id 27901, material id 66553, type id 12345, and its material was defined in the Revit face itself and not inherited from the object definitions.
Named Object Dictionary Entries
The mapping between the category, sub-category and type ids and their names is stored in corresponding tables in the Named Object Dictionary (i.e., an AcDbDictioinary of the name "REVIT_DICTIONARY"). REVIT_DICTIONARY contains the following identifiers:
- 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 an Xrecord stored as a DXF resbuf chain. Each entry in the table represents the data pair with an id of type long and the name of type text.
Hi Jeremy,
I'm new to REVIT API, but was thinking about something:
"Is there eny way of adding XData to the families, so that we can manipulate then later on AutoCAD, after the DWG export on Revit? "
Thank you..
Felipe
SP-Brazil
Posted by: Felipe Mesquita | October 26, 2010 at 13:27
Dear Felipe,
Sure there is a possibility for a Revit add-in to add its own arbitrary data to Revit database elements. It is called 'shared parameters' and is accessible both through the user interface and the API.
I am not sure how well the shared parameter data will survive the export to AutoCAD, though. If all else fails, you can always implement your own export mechanism.
Cheers, Jeremy.
Posted by: Jeremy Tammik | October 27, 2010 at 07:53
Hi Jeremy,
Very nice blog, I've been following you for a long time now, keep up!! :) This particular post remind me a problem of mine; I would like to obtain the scale of the exported view. I've searched through the REVIT_DICTIONARY inside the dwg but couldn't find any clue. Is there any xrecord/xdata which may provide the scale? Or you may have other ideas to get it or a different way to export it to dwg...
My purpose is to make some automatic adjustments depending on the scale of the exported view by means of lisp.
Thanks,
Serhan
Posted by: Serhan BAKIR | April 28, 2014 at 06:35
Dear Serhan,
Thank you for your appreciation. Glad you like it.
No, I am not aware of any such information.
Actually, it may even be hard to find within Revit itself.
As an approximation in Revit, I would suggest iterating over all elements returned by a filtered element collector specific to the given view and summing up all their bounding boxes to obtain the model extents displayed by the view.
The size of the view in paper space is easy to determine:
http://thebuildingcoder.typepad.com/blog/2014/04/determining-the-size-and-location-of-viewports-on-a-sheet.html
Cheers, Jeremy.
Posted by: Jeremy Tammik | April 28, 2014 at 06:44