DWG Issues and Various Other Updates

One of the highlights mentioned in the

overview of the Revit 2014 API
is
the FreeForm element API that enables modification of solid geometry imported from DWG or SAT.

Several other new DWG and DXF related features include import of DXF markup, import and link of SAT and SketchUp, and access to the DWG, IFC and DGN layer, linetype, lineweight, font and pattern tables.

One result of these enhancements is the possibility to access 3D coordinates in DWG import for the first time.

Besides looking at that, I’ll also point out a few other issues further down:

Access to 3D Coordinates in DWG Import

One DWG import aspect that has often been requested by developers in the past is the ability to explode 3D DWG files and obtain the resulting coordinates in the Revit project.

Revit 2014 families now provide the ability to explode and retain such 3D geometry.
<!–

The wiki mentions this under

–>

Daniel Gijsbers discusses making use of this functionality to

correlate Civil 3D alignments with Revit Structure
.

In Revit 2013, one alternative way to achieve this was to implement an AutoCAD add-in that analyses the geometry and exports the 3D coordinate data.
A separate Revit add-in could read the coordinate data and correlate it with the Revit geometry.

Differentiate Label and Text in DWG Export

On a related topic, how can I differentiate between Revit text and label elements after they have been exported to DWG?

Revit Export to DWG results in Labels becoming Text rather than Attributes, as most users might prefer.

It would be interesting to have some flag or embedded information in the exported text that could be used in an AutoCAD application to post-process the information received from Revit and restore the attribute information.

Happily, the exported Labels have Extended Entity Data like this attached:


TypedValue 0 - type: 1001, value: REVIT
TypedValue 1 - type: 1002, value: {
TypedValue 2 - type: 1070, value: 1
TypedValue 3 - type: 1000, value: 245287
TypedValue 4 - type: 1002, value: }
TypedValue 5 - type: 1002, value: {
TypedValue 6 - type: 1070, value: 5
TypedValue 7 - type: 1000, value: 243658
TypedValue 8 - type: 1002, value: }
TypedValue 9 - type: 1002, value: {
TypedValue 10 - type: 1070, value: 2
TypedValue 11 - type: 1000, value: -2000280
TypedValue 12 - type: 1002, value: }

The xdata on Text elements, on the other hand, look like this instead:


TypedValue 0 - type: 1001, value: REVIT
TypedValue 1 - type: 1002, value: {
TypedValue 2 - type: 1070, value: 1
TypedValue 3 - type: 1000, value: 261323
TypedValue 4 - type: 1002, value: }
TypedValue 5 - type: 1002, value: {
TypedValue 6 - type: 1070, value: 5
TypedValue 7 - type: 1000, value: 209618
TypedValue 8 - type: 1002, value: }
TypedValue 9 - type: 1002, value: {
TypedValue 10 - type: 1070, value: 2
TypedValue 11 - type: 1000, value: -2000300
TypedValue 12 - type: 1002, value: }

The differing TypedValue 11 is consistently -2000300 for a text and -2000280 for a label element.

What does this mean?

Well, is actually quite easy.

On seeing these large negative numbers in this specific range, an experienced Revit developer will quickly suspect built-in category or parameter enumeration values.

You can check what they actually represent in the Visual Studio debugger, by jumping to the definition of these enumerations and searching for the specific values.

Looking back at an ancient blog post on the
DWG and DXF export Xdata specification
confirms that these numbers do indeed represent the built-in category of the source element and thus can be used to distinguish the two.

Many thanks to Dale Bartlett, CAD-BIM System Manager at
Atkins (Oman), for suggesting this topic.

Dale adds:

It will be interesting to see if this generates any comments.

As far as the AutoCAD geometry export, the purpose was to build a 3D Space Frame from an engineer’s analysis drawing.
I did in fact write an XML file from AutoCAD of the geometry and imported it into Revit to build the frame.

It took an hour to build 20,000 elements, which was about a year less than doing it manually!

I’ll revise it with 2014 to make it a one-step-inside-Revit process.

Element Ids in Extensible Storage

Question: I need to store ElementId data using schemas within my Revit add-in.

However, the API documentation states that “ids are subject to change during an Autodesk Revit session and as such should not be retained and used across repeated calls to external commands.”

My add-in will be used in a worksharing environment.
My testing shows that if I try to save the integer value of an element id, and it changes, my saved id value will be invalid.
However, if I store the actual ElementId in a schema I do not have this problem.

Is saving the ElementId using a Schema safe?
If not, do you have any suggestions or examples of how to safely store an identifier to elements in a schema?

Answer: Yes, it is completely safe to store ElementId data in extensible storage for the purposes you describe.

The statement you quote refers to the fact that the integer value of an element id will change between sessions.
Basically, you can think of it as a pointer.
When stored as an element id in extensible storage, the actual links between the associated elements are stored, and the resulting integer values are recalculated from scratch in every new session, maintaining the links intact.
The integer value of an element id may be changed by worksharing updates as well, and these changes are also automatically handled for element ids stored in extensible storage, so it is perfectly safe to save them there.

All-zero Language Codes in the Revit Product GUID

Watch out for all-zero language code identifiers in the Revit Product GUID due to the new Multiple Language Interface, or MUI, used in Revit 2014.

For details, please refer to the

Revit Product 2014 GUID addendum
.

Another Dockable Panel Sample

Guy Robinson published another dockable dialogue sample which does not require a command to be registered.

For details, please refer to the

simpler dockable panel addendum
.


Comments

9 responses to “DWG Issues and Various Other Updates”

  1. Valdemar Avatar
    Valdemar

    While linking to CAD files (SAT) with API, there exists no option to indicate that placement should be produced with concern to “Auto-on common coordinates” (not centre or start, translated from Russian). May be such a hiden option realy exists?

  2. Dear Valdemar,
    Is this possible through the user interface?
    In general, if a feature is not available in the product through the user interface, then the Revit API will not provide it either.
    Cheers, Jeremy.

  3. Valdemar Avatar
    Valdemar

    Thanks for the quick reply! I’m not quite correctly formulated question because of poor English. The answer on my question was as follows:
    public ElementId Import(
    string file,
    SATImportOptions options,
    View pDBView
    )
    where
    BaseImportOptions MySAToptions = new BaseImportOptions();
    MySAToptions.Placement = ImportPlacement.Shared;
    MySAToptions.Unit = ImportUnit.Millimeter;

  4. Jeremy,
    If i understand this post correctly, you are implying that in Revit2014, now it IS possible to explode 3D DWG files and obtain the resulting coordinates in the project using API(does “Explode” call happen from API or is it just the geometry data retrieval) OR am i misunderstanding you?
    Thanks,
    Anu

  5. Dear Anu,
    Yes, that is my take on this.
    I guess you would have to launch the explode command via PostCommand or something.
    Cheers, Jeremy.

  6. Pavel Savine Avatar
    Pavel Savine

    I am working through the DWGImportOptions GetLayerSelection() method since I am trying to get a readout of the layers imported in the CAD file as it exists in the ‘Imported Categories’ section of Visibility/Graphic Overrides.
    I cannot seam to get any results out of this method or find any references. Any ideas?
    Thank you
    Pavel

  7. Dear Pavel,
    Please describe exactly what you are trying to achieve, and how, and what behaviour you are observing.
    The best and clearest way is normally by providing a minimal sample project and a reproducible test case, i.e.

    A complete yet minimal Revit sample model to run a test in.
    A complete yet minimal Visual Studio solution with add-in manifest so that we can compile, load and run the application with a single click and explore its behaviour live in the sample model you provide.
    Detailed step-by-step instructions for reproducing the issue.
    Specification of the exact behaviour you observe versus what you expect.

    Thank you!
    Cheers, Jeremy.

  8. Hello,
    When gaining the XData, what is the name of the app?
    GetXDATA(string AppName, out object XDataType, out object XDataValue)
    Regards
    Chris

  9. Dear Chris,
    Please generate a DXF output file yourself, take a look, and tell us what you see.
    It is a simple ASCII text file.
    Thank you!
    Cheers, Jeremy.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading