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

**URL:** <https://forum.techsoft3d.com/t/how-to-import-multiple-cad-models-of-different-units-into-the-same-scene-graph/1470>\
**Category:** HOOPS Visualize Desktop\
**Tags:** code, learn, knowledge-base, how-to, import\
**Created:** [May 16, 2022, 4:00am UTC](https://forum.techsoft3d.com/t/how-to-import-multiple-cad-models-of-different-units-into-the-same-scene-graph/1470 "2022-05-16T04:00:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabriel.peragine](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/gabriel.peragine/32/1535_2.png) [@gabriel.peragine](https://forum.techsoft3d.com/u/gabriel.peragine)\
**Post date:** [May 16, 2022, 4:00am UTC](https://forum.techsoft3d.com/t/how-to-import-multiple-cad-models-of-different-units-into-the-same-scene-graph/1470/1 "2022-05-16T04:00:00Z")

</div>

As mentioned in this page [![](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/8cb0c77f828e2563c20cf33b876a5a19c7d687c9.png)Exchange Integration — HOOPS Visualize HPS Documentation 2022.0.0 documentation](https://docs.techsoft3d.com/hps/latest/prog_guide/0906_exchange_integration.html#importing-multiple-models)  
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. [![](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/8cb0c77f828e2563c20cf33b876a5a19c7d687c9.png)Initializing HOOPS Exchange — HOOPS Exchange 2023 documentation](https://docs.techsoft3d.com/exchange/latest/guide/start/initialize-hoops-exchange.html)
