How to import multiple CAD models of different units into the same scene graph

As mentioned in this page Exchange Integration — HOOPS Visualize HPS Documentation 2022.0.0 documentation
You can import multiple models into the same scene graph using HPS::Exchange::ModelFileImportOptionsKit::SetLocation.
This sample shows how to import multiple models which have different units into the same scene graph and display the model in the correct size.

Instructions

  1. Import CAD model using HOOPS Exchange API
  2. Get the unit of A3DAsmModelFile using A3DAsmModelFileGetUnit
  3. Create a scale matrix from the units to display the model in millimeter
  4. Import A3DAsmModelFile under the existing CADModel in the scene graph with SetLocation

void CHPSView::OnUserCode()
{
A3DAsmModelFile* psModelFile;
A3DRWParamsLoadData sLoadData;
A3D_INITIALIZE_DATA(A3DRWParamsLoadData, sLoadData);
sLoadData.m_sGeneral.m_bReadSolids = true;
sLoadData.m_sGeneral.m_bReadSurfaces = true;
sLoadData.m_sGeneral.m_bReadWireframes = true;
sLoadData.m_sGeneral.m_bReadPmis = true;
sLoadData.m_sGeneral.m_bReadAttributes = true;
sLoadData.m_sGeneral.m_bReadHiddenObjects = true;
sLoadData.m_sGeneral.m_bReadConstructionAndReferences = false;
sLoadData.m_sGeneral.m_bReadActiveFilter = true;
sLoadData.m_sGeneral.m_eReadingMode2D3D = kA3DRead_3D;
sLoadData.m_sGeneral.m_eReadGeomTessMode = kA3DReadGeomAndTess;
sLoadData.m_sGeneral.m_eDefaultUnit = kA3DUnitUnknown;
sLoadData.m_sTessellation.m_eTessellationLevelOfDetail = kA3DTessLODMedium;
sLoadData.m_sAssembly.m_bUseRootDirectory = true;
sLoadData.m_sMultiEntries.m_bLoadDefault = true;
sLoadData.m_sPmi.m_bAlwaysSubstituteFont = false;
sLoadData.m_sPmi.m_pcSubstitutionFont = (char*) “Myriad CAD”;

A3DStatus iRet = A3DAsmModelFileLoadFromFile("file path", &sLoadData, &psModelFile);

A3DDouble dunit = 1.0;
iRet = A3DAsmModelFileGetUnit(psModelFile, &dunit);

HPS::Exchange::CADModel cadmodel = GetDocument()->GetCADModel();
if( cadmodel.Empty()) // for the first loading model
	cadmodel = HPS::Exchange::Factory::CreateCADModel();
HPS::ComponentPath comppath;
comppath.PushBack(cadmodel);

try
{
	HPS::Exchange::ModelFileImportOptionsKit optionkit = HPS::Exchange::ModelFileImportOptionsKit::GetDefault();
	HPS::MatrixKit matrix = HPS::MatrixKit::GetDefault();
	matrix.Scale(dunit, dunit, dunit); // Scale the model to millimeter 
	optionkit.SetLocation(comppath, matric);
	HPS::Exchange::ImportNotifier notifier = HPS::Exchange::File::Import(psModelFile, optionkit);
	notifier.Wait();

	if (GetDocument()->GetCADModel().Empty())
	{
		HPS::View view = notifier.GetCADModel().ActivateDefaultCapture();
		GetCanvas().AttachViewAsLayout(view);
		GetDocument()->SetCADModel(notifier.GetCADModel());
	}
}
catch (const HPS::IOException& ioe)
{
	// handle error
}

}

When using HOOPS Exchange API, you need to include a header file, and load and initialize the Exchange library. Initializing HOOPS Exchange — HOOPS Exchange 2023 documentation