hoops_ai.cadaccess.HOOPSLoader

class hoops_ai.cadaccess.HOOPSLoader

Bases: CADLoader

create_from_file(filename)

Reads a CAD file and initializes the CAD model.

Parameters:

filename (str)

Return type:

HOOPSModel

get_general_options()

Returns the current settings (dict) for loading the CAD file, so the user can see or modify them. Note: read_solids (new API) is returned as read_solid for backward compatibility.

Return type:

Dict[str, Any]

classmethod get_load_count()

Get the current load counter value.

Returns:

Number of successful file loads since last reinitialize.

Return type:

int

get_model()

Returns the CAD model.

Return type:

HOOPSModel

classmethod reinitialize()

Force cleanup of loaded models and reset the singleton state.

This method is useful when: - Files are not being properly released by Exchange - Memory needs to be freed after processing many files - You want to ensure a clean state before loading new files

Note: This clears the current model state to release references and help with garbage collection. The license remains set (he.set_license is idempotent).

Warning: Any existing HOOPSModel references may become invalid after calling this.

Usage:

loader = HOOPSLoader() # … process files … HOOPSLoader.reinitialize() # Clear state and release model references # … continue with new files …

classmethod set_auto_reinit_threshold(threshold)

Configure the auto-reinitialization threshold.

HOOPSLoader automatically calls reinitialize() after loading N successful files to prevent memory accumulation. Use this method to adjust the threshold.

Parameters:

threshold (int) – Number of successful file loads before auto-reinitialize. Set to 0 or negative to disable auto-reinitialization.

Usage:

HOOPSLoader.set_auto_reinit_threshold(500) # Reinit every 500 files HOOPSLoader.set_auto_reinit_threshold(0) # Disable auto-reinit

set_general_options(general_options)

Sets the settings used when loading the CAD file. Note: read_solid (old API) is now read_solids (plural) in the new API.

Parameters:

general_options (Dict[str, Any])

Return type:

None