RealDWG and Object Enablers

Revit uses the RealDWG toolkit to implement the DWG file export and import functionality.
A frequent question is whether there is any way to hook into this functionality, and how this relates to custom objects and DBX object enablers, like for instance:
Is there a way to load a DBX application into Revit as a RealDWG extension?
It would be handy to be able to reuse the functionality of some custom ObjectDBX classes.

First of all, let us clarify some terms required in this context:

  • ObjectARX: The AutoCAD Runtime Extension, originally just ARX.
  • ObjectDBX: The AutoCAD-independent subset of ObjectARX that deals only with the AutoCAD database, the DWG file.
  • RealDWG: An AutoCAD-independent library for reading and writing DWG files using ObjectDBX in a stand-alone application. Requires a separate license.
  • Custom object: An instance of a C++ class that can be stored in an AutoCAD database, implemented by an ObjectARX or ObjectDBX plug-in.
  • Custom entity: An custom object that defines graphics and can reside in the block table of an AutoCAD database.
  • Object enabler: An AutoCAD-independent plug-in module, i.e. an ObjectDBX plug-in, that defines the properties and behaviour of a custom object or entity.
  • Proxy graphics: Hard-coded graphics data stored in a DWG file and used to render a custom object in the absence of its object enabler.

ObjectARX supports extending AutoCAD during runtime with plug-in modules implemented in C++.
An ObjectDBX plug-in makes use of only an AutoCAD independent subset of ObjectARX.
It can therefore be loaded both inside of AutoCAD, and outside into other non-AutoCAD host applications such as TrueView.

More details about RealDWG are provided in the

RealDWG Developer Center
.
Thanks to Adam Nagy from our DevTech team in Europe,
we also have a DevTV recording explaining how to make use of this API,
available for

download

(97.5 MB) or for

online viewing
. Kean Walmsley provides a list of

more DevTV recordings

on various Autodesk APIs.

RealDWG itself does include a full ObjectARX runtime kernel which provides the ability to load an object enabler.
It needs it to manage the ARX class relationships, and it includes the acrxLoadModule API call to load a DBX module.
It obviously cannot load an ARX module, i.e. a module that depends on AutoCAD, because it is not AutoCAD.

On the other hand, RealDWG within Revit is a different story. In that context, no object enablers are loaded.
Revit only uses RealDWG to display the graphics of the primitive entities within the DWG file, without bothering to load object enablers for custom classes.
It does not load object enablers, even though RealDWG itself is theoretically capable of doing so.

For export, Revit uses RealDWG to generate DWG files with primitive built-in ObjectARX entities.
For importing DWG files, it uses it to read and display entities and other data from the DWG file.
It does not use any additional classes or do anything to manage the object hierarchy, so it does not load object enablers. All it uses is primitives already available in the RealDWG system.
All custom objects just render their proxy graphics.

When you call an ObjectARX entity’s worldDraw function and its object enabler is not loaded, it just returns its proxy graphics.
If the enabler is loaded, the real entity calculates and returns its proper live graphics.
This functionality is automatically handled by worldDraw.

Revit does not register itself as a RealDWG application, and so the object enabler installers do not see it and do not set up any object enabler autoloading.

The result is that you cannot use the RealDWG functionality built in to Revit to load an object enabler or make use of ObjectDBX functionality.

You may be able to implement your own .NET based RealDWG application inside a Revit plug-in. This combination has not been tested, however, and is not explicitly supported. You may run into problems where the RealDWG licensing mechanism interferes with the Revit plug-in security features.

If this combination works, it would enable you to make use of the AcGe library within your Revit application.
It would also give you access to the acrxLoadModule, thus providing the complete required kernel functionality in able to load a DBX object enabler or handle custom objects in DWG files.
If anybody has succesfully made use of this combination, it would be interesting to hear from you and discuss further details.
However, there is another easy way to achieve the same result …

A related topic is the possibility to run AutoCAD as a hidden process and make full use of all its API functionality from within Revit, which we will look at next.


Comments

14 responses to “RealDWG and Object Enablers”

  1. Hi,
    Have you ever try to use the Import method?
    I’d like to import an image by API.

  2. Hi Pierre,
    I assume you mean the Document.Import method, for importing a DWG file or a bitmap into Revit. No, sorry, I have never done anything special with that method. The first thing to do is always to look for a Revit SDK sample demonstrating the possibilities. One such sample in this case might be the ImportExport application.
    Good luck and best regards, Jeremy.

  3. HI jeremy,
    I have already look at the RevitSDK sample. I found this sample code called : “ImportExport” but the Import fonction does not work.

  4. Hi Pierre,
    I am not aware of any problems with the Document.Import method. What are you doing with it, in what way is it failing?
    Best regards, Jeremy.

  5. Anyway, do you know how to move an element?

  6. I’m ok now with the Import fonction.
    But, now, i try to move the element….do you know how to do it?
    Best regards.

  7. Hi Pierre,
    Congratulations on solving your import issue. For moving an element, there are also various SDK samples. I suggest searching globally for “.Move” through all the SDK samples.
    Best regards, Jeremy.

  8. Hi Jeremy, thank you for this insite, it makes me question why does it not use the enablers, when all the documentation on the adesk site suggests it does, or am I reading it wrong?.
    Also state
    “Revit does not register itself as a RealDWG application, and so the object enabler installers do not see it and do not set up any object enabler autoloading”
    If I look at my registery ater installing Revit 2010, under key 69AB5C28B75C0B24697E99A66AB34651 which is the Host App Reg locations, Revit is listed.
    I guess I dont realy follow what you are suggesting, does Revit use Object Enablers to display custom entities or not? If not, are you suggesting it may be possible to load the enabler myself withon Revit, if so, how would you get the graphics to display in Revit?
    Regards
    Andy Robins

  9. Hi Andy,
    I’m sorry that the statements are not clear enough. Of course all the information stated above was written for Revit 2009. I am not sure what the situation is for Revit 2010.
    What I am saying above is:
    1. Revit does not use object enablers to display custom entities.
    2. It is not possible to load an enabler into Revit.
    The later statement about loading your own RealDWG-enabled plug-in would not provide any possibility whatsoever to affect the graphics displayed by Revit.
    I hope this clarifies.
    Cheers, Jeremy.

  10. perfect, thanks for clarification
    Cheers
    Andy

  11. Dave Kouts Avatar
    Dave Kouts

    Hi, Jeremy.
    I am working with a custom RealDWG-registered app, and trying to pull the geometric data for custom entities into an AcGiWorldDraw-derived class.
    Within this app, I am able to load the enablers just fine. Unfortunately, anytime I use a custom entity’s worldDraw() method, it returns ‘false’, and nothing is added to my AcGiWorldDraw class.
    In some cases, I can get around this by using the entity’s explode() method, but this only works part of the time.
    Any suggestions?
    Thank you in advance for any ideas you may have!
    – Dave

  12. Dear Dave,
    Your question has nothing to do with the Revit API, which is what this blog focuses on, exclusively.
    Still, if memory serves right, he fact that the worldDraw returns false means that the entity wants its viewportDraw method called instead. To see the result of those calls, you have to implement and handle the AcGiViewportDraw interface.
    This kind of behaviour is shown by AutoCAD Architecture custom entities, which display different graphics depending on the viewport they are drawn in and many other factors.
    Cheers, Jeremy.

  13. Dave Kouts Avatar
    Dave Kouts

    [I apologize, I should have clarified. I know my question doesn’t directly relate to the blog above. I asked it here, because you indirectly mentioned the very things I was looking into (enablers, worldDraw method).]
    Regarding your answer just now, thank you! That explains a lot of the behavior I was seeing, and gives me a direction in my work. I really appreciate it.

  14. Dear Dave,
    Wow, I am glad and somewhat surprised that I could help. It’s been a long time since I looked at that stuff :-)
    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