The RealDWG Libraries are the only native DWG/DXF read/write libraries supplied by Autodesk. To use this integration, developers are required to license the RealDWG Toolkit. Please contact a Tech Soft 3D representative for licensing details.
To use the HOOPS/HIO component for RealDWG, please follow the steps below:
During start-up, when HOOPS/MVO finds the RealDWG HIO component in your application's path, it will perform the following steps:
Once the RealDWG HIO component is successfully loaded, your application will be able import RealDWG files without having to recompile HOOPS. To utilize the extensive services available in the RealDWG toolkit, you must compile against the RealDWG libraries directly and follow the steps described in 4.0 Integrating Directly with RealDWG.
The RealDWG HIO component was built against against a specific version of RealDWG. If you want your application to run against another version of RealDWG, we recommend that you rebuild the RealDWG HIO component with that version of the library. To do so, simply open the hio_dwg_vc<version>.vcproj project located in the <hoops>/Dev_Tools/hoops_hio/hio_dwg/source. Be sure to set the environment variable REALDWG_SDK_DIR to point to the root of your RealDWG installation before you begin building. Once the project is built against the correct libraries, an .hio file will be created. Note that you may face some obstacles building against a different version of the RealDWG if interfaces are not compatible with the original libraries that the HIO component was built against.
All entities found in RealDWG are supported by HOOPS except for:
When a RealDWG model is imported into HOOPS, the model units are also imported. This information can be found in the "info" segment under the model key as a user option. For example, if the user option value is "dwg_unit=Inches", this means that one unit length of the imported entity is equivalent to one inch. The possible units are as follows:
During the im-port of a DWG that contains text, any fonts specified in the DWG file must be on the system because fonts can not be embedded in a DWG file. If the importer does not find the given font, the text will be drawn with the default HOOPS font. This can be modified using Set_Text_Font.
The ReadDWG HIO component does not import custom AutoCAD fonts (.shx), since RealDWG does not provide any APIs to decode such fonts. DWG text that is specified to use such fonts will also be drawn with the default HOOPS font.
Within HOOPS/MVO, a variety of input options available to facilitate the importing process. For instance, you can determine how DWG visualization information is represented in the HOOPS scene graph with options like HInputHandlerOptions::m_Deviation and HInputHandlerOptions::m_numIsolines.
The HInputHandlerOptions::m_Deviation is the maximum allowable difference in world space between the true mathematical surface being imported and the tesselated surface that will be rendered in HOOPS. For instance, if the deviation is set to 1.0, the surfaces in HOOPS would be comparatively more tesselated than if the deviation was the default value of 10.0. Specifying a value for HInputHandlerOptions::m_numIsolines option lets you determine the number of isolines for surfaces like cylinders, spheres and tori. Setting this option to zero will suppress isolines.
In addition to settings that help determine the representation of your visualization data, there are also options for importing metadata. When the HInputHandlerOptions::m_bImportMetadata flag is set to true, the xdata, including entity, layer and group names, found in your DWG file are imported as user options attached to the associated segment. Some DWG files have large amounts of xdata. Consequently, you might want to load only the metadata that is relevant to your application. To do this, you can populate the HInputHandlerOptions::m_listRegAppNames with a list of registered application names. Thus, only metadata associated with these registered applications are imported. Note that HInputHandlerOptions::m_listRegAppNames is only applicable when HInputHandlerOptions::m_bImportMetadata is true.
For some users, information of interest in a RealDWG is the handle id information associated with every database-resident DWG entity. These handle ids are persistent from session to session. To import handle ids, set the HInputHandlerOptions::m_bAttachDWGHandles flag to true. This will tell HOOPS to import the handle ids as user options and attach them to the associated segment.
Along with metadata information and handle ids, wireframe representations for BREP solids can also be imported. To do this, set the HInputHandlerOptions::m_bImportWireframeForBrep flag to true. The default value for this flag is false.
In RealDWG, models often come with one or more layouts. This information could be useful or even crucial when importing to HOOPS. To enable the importation of layouts, set the HInputHandlerOptions::m_bImportAllLayouts to true. When this flag is enabled, HOOPS imports all Model_Space and Paper_Space layouts. Model_Space will have visibility enabled while all other layouts will have visibility set to off. If you have only interested in importing a limited number of layouts, you can list them in HInputHandlerOptions::m_listDWGLayouts. HOOPS will then only import those layouts. Note that if you have HInputHandlerOptions::m_bImportAllLayouts enable, this will override your HInputHandlerOptions::m_listDWGLayouts list.
When a DWG file is imported into the HOOPS database, the DWG file is opened using the RealDWG toolkit. As the DWG file is being read, HOOPS imports the data into the HOOPS database. For DWG files with a large number of SOLID3D entities, simultaneously reading and importing can consume a significant amount of memory causing your application to appear unresponsive to user interactiion. For this situation, HOOPS offers the HInputHandlerOptions::m_bInputViaHSF option. When this flag is set to true, HOOPS imports DWG files in the following way:
Whenever there is an xref, a new hsf file is created. As a result, there is a one to one mapping between the DWG files and the HSF files. HOOPS will attempt to remove any cyclical references and resolve missing locations for any xrefs that are found. When HInputHandlerOptions::m_bInputViaHSF is true, HIOUtilityDWG looks at the value of HInputHandlerOptions::m_bMergeEntityShells. If this flag is set to true, HOOPS will merge all the facets of a shell into one shell. Note that when HInputHandlerOptions::m_bInputViaHSF is true, HIOConnector functionality is not available.
When there is a request to import a DWG file and HOOPS finds that the file has already been imported via HSF, it will compare the timestamp of the HSF file with the DWG file. If the HSF file's timestamp is later, HOOPS will forego re-importation. To force reimportation of a DWG file, set the HInputHandlerOptions::m_bForceReimport flag to true.
The HOOPS RealDWG imported implements the progress and error importing interfaces. Thus, during importation, you can poll using HInputHandler::GetInputProgress to get the current progress information or register as a callback to get this information via HInputHandler::SetInputProgressNoticeCallback.
The following code sample shows how you can set options for the HIOUtilityDWG input handler.
HInputHandlerOptions dwg_input_options; dwg_input_options.m_pExtendedData = (void*) p_dwg_textures_dir; //Importing DWG information into an HSF file before loading it into the HOOPS database dwg_input_options.m_bInputViaHSF = true; //Setting the amount of tesselation for imported surfaces dwg_input_options.m_Deviation = 10; dwg_input_options.m_bImportMetadata = true; //Creating a list of registered applications for metadata importation. char* XDataNames[] = { "CPM", "CPD1", "CPD2", "CPD3", "CPD4", "CPD5", "CPD6" }; for(int x = 0;x<_countof(XDataNames);x++) vlist_add_last(dwg_input_options.m_listRegAppNames,(void*)XDataNames[x]); dwg_input_options.m_bMergeEntityShells = true; dwg_input_options.m_pHBaseView = view; view->GetModel()->Read(FileName, 0, true, &dwg_input_options);
The RealDWG HIO component allows developers to easily import visualization information into the HOOPS database. However, DWG files also contain more than just visualization information. If your application needs to access/manipulate the extensive information found in DWG files and/or utilize the full range of the RealDWG library services, you will require a tighter integration than what the RealDWG HIO component can provide.
Before you begin integrating directly with the RealDWG libraries, we recommend that you ensure that have licensed and installed the RealDWG Toolkit on your system. To proceed with the integration, follow the steps below:
Once you have completed the above steps, you do not need to rely on the RealDWG HIO component anymore. Please remove the associated .hio file from the hio_plugins directory in your application's working directory. Note that in a direct integration, you must register HIOUtilityDWG via HIOManager::RegisterInputHandler so that the HBaseModel::Read function can recognize that the .dwg file format is supported. For more information on HOOPS/MVO file input/output architecture, please see section 4.0 File Input/Output and the I/O Manager of the HOOPS/MVO Programming Guide.
Now you can begin working with HIOUtilityDWG class which is the HOOP/MVO's input handler for RealDWG. The code sample below shows how to instanciate the input handlers and import a DWG file.
HIOUtilityDWG dwg_reader; HFileInputResult result = dwg_reader.FileInputByKey("c:\\temp\\myFile.dwg", m_pHView->GetModelKey(), NULL);
It is very important for developers to be able to map between objects within their HOOPS/3dGS database and the corresponding entities within the RealDWG database. To do this, developers should use the HIOConnector class. When you call HIOConnector::GetKernelEntity and pass a HOOPS key, the HIOConnector will return a pointer to the corresponding object in the RealDWG database. Alternatively, if you provide a pointer to a RealDWG object when calling HIOConnector::GetHoopsEntity, the HIOConnector will return the key(s)of object(s) within the HOOPS/3dGS database which are used to represent that object.
Here is some sample code which shows you how to use the HIOConnector capabilities.
char FileName[1024]; sprintf(FileName, "%s", "c:\\hoops\\third_party_files\\Small-Metric-Test.dwg"); HInputHandler * handler = HDB::GetHIOManager()->GetInputHandler("dwg"); HC_KEY modelkey = m_pHView->GetModelKey(); HInputHandlerOptions options; HIOConnector *connector = HDB::GetHIOManager()->CreateConnector("dwg"); options.m_pConnector = connector; HFileInputResult result = handler->FileInputByKey(FileName, modelkey, &options); m_pHView->FitSegment(modelkey); m_pHView->Update(); HC_Open_Segment_By_Key(modelkey); HC_Begin_Contents_Search("...", "shells"); char temp[256]; HC_KEY key; while (HC_Find_Contents(temp, &key)) { void *dwg_entity = connector->GetKernelEntity(key); HC_KEY newkey = connector->GetHoopsEntity(dwg_entity); if (newkey == key) AfxMessageBox(_T("Same Roundtripped Key")); } HC_End_Contents_Search(); HC_Close_Segment();
Our integration is only supported on the platforms supported by the RealDWG Toolkit. Currently, platform support is available for the Windows platform using the Visual Studio 2008 development environment with Service Pack 1. For the most up to date information, please refer to the RealDWG Documentation.
For Release 17.10, the RealDWG HIO component requires RealDWG 2010.