10 Easy Steps for Integrating HOOPS Exchange with HOOPS Visualize

10 Easy Steps for Integrating HOOPS Exchange with HOOPS Visualize

Integrating HOOPS Exchange with HOOPS Visualize

HOOPS Exchange is Tech Soft 3D’s CAD data interoperability (data converter) library. It also helps in importing CAD model data into HOOPS Visualize (Tech Soft 3D’s 3D rendering library). Through Exchange, you can access assembly information, visualization data, and PMI annotations for inspection or manipulation within the context of a Visualize scene graph. Any file that can be loaded by the Exchange libraries can be loaded into Visualize. 

The steps below will help you to integrate HOOPS Exchange with Visualize assuming the HOOPS Exchange license is in place.

1. Before starting with HOOPS Exchange integration set up your application with HOOPS Visualize (refer to blogs 1 and 2 for HOOPS Visualize integration)

2. Download HOOPS Exchange binaries from Tech Soft 3D portal.

3. Add an environment variable ‘HEXCHANGE_INSTALL_DIR’ and set the path of Exchange binaries to use like x86 or x64 bit binaries. If you don’t want to add any new environment variable to your system then you can also achieve the same thing by updating the properties of cc_exchange_lib project in the HOOPS Visualize solution.

  • Open HOOPS Visualize solution in Visual Studio, select cc_exchange_lib project and go to properties. Then go to ‘C/C++>General> Additional include directories’ and replace ‘$(HEXCHANGE_INSTALL_DIR)\include’ with the include folder path of your HOOPS Exchange binaries.

 

4. Visualize the solution that comes with the ‘cc_exchange_lib’ project. The project can be found at location ‘HOOPS_Visualize_20XX>samples>cc_exchange_lib’. After compiling this project, it generates a ‘cc_exchange_lib.dll’ DLL which you need to add as a Reference in your application.

5. In the system path variable add the path of Exchange dlls (that you have downloaded), for example, to use ‘x64 bit’ binaries, add the corresponding path to the path variable.

6. Now the application is ready to use Exchange APIs, below steps show how to add a button in the toolbar and load a CAD model in Visualize.

7. To add a toolbar in the main window you need to add a new XAML file (choose any name for the file). In the XAML file add the below code inside the grid tag.

<ToolBarTray Background=“DarkGray” Height=“30” VerticalAlignment=“Top”>
    <ToolBar Name=“MyToolbar1” Width=“250” Height=“30” >
        <Button Background=“LightSkyBlue” Content=“LoadModel” Name=“LoadExchangeModel” Click=“LoadExchangeModelClick”/>
    </ToolBar>
</ToolBarTray>

 

8. For adding the toolbar inside the main window in ‘MainWindow.xaml’ copy the below code. 

<DockPanel x:Name=“_cPanel” AllowDrop=“True”>
    <ToolBar DockPanel.Dock=“Top”>
        <local:MyToolbar></local:MyToolbar>
    </ToolBar> 
    <Grid>
        <Border x:Name=
“_cBorder” Margin=“0,0,0,0” BorderThickness=“0”/>
    </Grid>
</DockPanel>

Also in the ‘MainWindow.xaml ’ file update the xmlns:local‘’ line (as shown below). As the toolbar is created in a separate file so you need to connect the path accordingly, else you will get build errors. Here ‘DemoViewer’ is the project name and ‘View’ is the sub-folder created in the project where the toolbar file is present.

xmlns:local=“clr-namespace:DemoViewer.View”

 

9. Inside the MyToolbar.xaml.cs file add the below function which will load the CAD file using Exchange API.

private void LoadExchangeModelClick(object sender, RoutedEventArgs e)
{
    OpenFileDialog openFileDlg = new OpenFileDialog();        
    if (openFileDlg.ShowDialog() == true)
    {
        try
        {
            HPS.Exchange.ImportOptionsKit importOptions = new HPS.Exchange.ImportOptionsKit();
            HPS.Exchange.ImportNotifier notifier;
            notifier = HPS.Exchange.File. Import(openFileDlg.FileName, importOptions);
            notifier.Wait();
            HPS.CADModel modelFile = notifier.GetCADModel();
            ModelBase.GetInstance().View.
                AttachModel(modelFile.GetModel());
            ModelBase.GetInstance().View.FitWorld().Update();
        }
        catch (HPS.Exception err)
        {
            Console.WriteLine(err);
        }
    }
}

 

10. Now build and run the application, click on the toolbar button and load the CAD file in Visualize using Exchange (below is the snapshot for the same).

        CAD file in Visualize using Exchange

Fig: CAD file in Visualize using Exchange

That’s it! You are all set. You can also use an Exchange notifier object to show a progress bar while importing CAD files. You can use this as a starting point for your product and add features viz. assembly browser, model properties explorer etc. 

We at ProtoTech Solutions are experts in all the libraries provided by Tech Soft 3D and have built numerous successful products using these in the last two decades. If you have a product idea that needs to support 3D visualization and read and write various engineering file formats, our development team can help you quickly manifest it and bring it out to the market. Connect with us at sales@prototechsolutions.com

Follow ProtoTech Solutions for software technology industry trends and Global CAD news and updates.

For more queries regarding any of the above-mentioned topics, feel free to connect with us on our website https://prototechsolutions.com, or email us at info@prototechsolutions.com

Leave a Reply

Your email address will not be published. Required fields are marked *