How to - Use Incremental Loading in HPS

Incremental Loading is an optional approach to loading an assembly. Using this capability, the assembly structure is loaded without geometry. Individual components may be subsequently loaded.

Following is sample code on Incremental Loading using HPS API. Sample code has been tested on hps_mfc_sandbox loading _Aquo Bottle.CATProduct.

Incremental load is only available for certain file formats, including SolidWorks, NX (Unigraphics), Creo (Pro/E), CATIA V5 and JT (Exchange 2024)

You will need to import Exchange file in BRepOnly and Incremental mode. This code will only load the structure/assembly info.

Copy/Paste following code in CHPSDoc.pp (Line 413)

HPS::Exchange::ImportOptionsKit ioOpts = options;
		ioOpts.SetBRepMode(HPS::Exchange::BRepMode::BRepOnly);
		ioOpts.SetMode(HPS::Exchange::ImportMode::Incremental);

Once assembly info is loaded, you can load any component separately.

Copy/Paste following code in CHPSView.cpp in CHPSView::OnUserCodeX.

Sample code:

	HPS::CADModel myCADModel  = GetDocument()->GetCADModel();

	// now load the root component
	//Exchange::CADModel cadModel = file.GetCADModel();
	auto top1 = Exchange::ProductOccurrence(myCADModel.GetSubcomponents()[0]).GetSubcomponents()[0];
	ComponentPath pathToLoad(1, &top1);
	HPS::Exchange::ImportOptionsKit importOptions;
	
	importOptions.SetIncrementalComponentPath(pathToLoad);
	HPS::Exchange::ImportNotifier notifier = HPS::Exchange::File::Import("D:\\hmf_master\\exchange\\catiav5\\CV5_Aquo_Bottle\\_Aquo Bottle.CATProduct", importOptions);
	notifier.Wait();

	GetCanvas().UpdateWithNotifier().Wait();

Video using hps_mfc_sandbox.

Incremental_loading

1 Like