As of HOOPS Visualize v19.30, the RealDWG HIO component has been refactored into a more robust interface called hio_dwg2. The component is still in beta status, but developers are encouraged to experiment with the new interface. Notes specifically related to hio_dwg2 can be found on this page.
Each DWG entity has a unique handle associated with it. The handle is unique within the database, and is the same session after session. The handle is represented by an unsigned 64-bit integer. Handles exhibit the following relationships:
When associating handles to keys, keep the following in mind:
To relate a DWG handle to a HOOPS key, you would do the following:
Case A - You have a HOOPS key and wants to obtain the related DWG handle:
Example:
Case B - You have a DWG handle and want to obtain the related HOOPS key(s):
Starting with Visualize 19.33, the developer has the option to query DWG handles in an optimized way. The process described in the previous section will always work, however, for large scene graphs, the processing time can be long. Using the HIO connector to associate DWG handles to Visualize keys is faster because it uses a hash lookup instead of searching the segment tree. There is a performance penalty, however, when the hash is generated.
This is how to obtain a connector:
All the associated functions (see list, below) have an optional parameter at the end. Passing the model key as that parameter causes the hash to be generated (or regenerated, if the geometry has been modified). Therefore, the first time you use this hash, you should always pass the model key.
The DWG connector can use the following functions:
HC_KEY GetHoopsEntity(void * pKernelEntity, HC_KEY modelKey = INVALID_KEY);
This function returns a HOOPS key associated with a DWG handle. Causes hash to be regenerated.
Sample usage:
void * GetKernelEntity(HC_KEY key, HC_KEY modelKey = INVALID_KEY);
This function returns a DWG handle associated with a HOOPS key. Causes hash to be regenerated.
Sample usage:
bool GetHoopsEntities(void * pKernelEntity, vlist_s *ret_HoopsKeysList, HC_KEY modelKey = INVALID_KEY);
Same as GetHoopsEntity, but is used in the case when a DWG handle is associated with more than one Visualize key. Causes hash to be regenerated.
Sample usage:
Same as GetKernelEntity
Adds a connection between a key and a handle. Does not cause the has to be regenerated.
Layers are treated as attribute containers. Whatever attributes are in the layer are applied to the geometry with a HOOPS Visualize style. This means that you can open the layer segment and override the attributes. If the geometry has attributes set on it explicitly, then the explicit attributes override the layer attributes. There's a case when the attributes of geometry are inherited from the block reference. Those attributes cannot be overridden by the layer. The layers can be found in the segment "layer table". The layers are URI encoded, to allow unicode characters in the segment names, and are prefixed with an underscore '_' character.
Layouts can be found in the "layouts" segment. The layouts are also URI encoded and prefixed with an underscore. Each layout has user options, "extents_min" and "extents_max" set defining the extents in 2D space. Each layout also sets the heuristic "exclude bounding" and sets the visibility to "off" except for the currently active/visible layout. The currently active/visible layout does not set visibility and does not set the exclude bounding heuristic. Iterating the visibility of the layouts is done by finding the layout that does not set the visibility, then setting the visibility to off, setting the exclude bounding heuristic, then moving on to the next layout segment and unsetting the visibility and unsetting the heuristics.
HIO DWG2 allows developers to use object enablers starting with Visualize v19.33. Using object enablers, customers can load DWG files which contain custom entities defined in their own .dbx files.
The only requirement for this to work is that the developer must place the .dbx files and associated DLLs into the same folder as the HIO DLL, so that they can be loaded when DWG2 starts up.
It is possible for a DWG file to be stored with uninitialized annotations and layouts. These uninitialized structures don't always exist in the DWG file. In this situation, RealDWG returns them as null pointers. Using its own internal logic, AutoCAD is able to load the uninitialized structures from null pointers, however, Visualize cannot. Therefore, we do not support uninitialized annotations or layouts.
Viewports within layouts can be in an 'active' or 'inactive' state. RealDWG doesn't provide any mechanism to find which viewports are active.
Although we make every effort to duplicate the rendering results of any file loaded using RealDWG, Visualize cannot exactly match AutoCAD in all cases when it comes time to actually draw. AutoCAD uses its own proprietary rendering engine that handles geometry in its own way. Some examples of differences we have noticed include: