    

 ## On this page

  

 

 # Database

 Last update: 20.02.2025 

### *class* compolyx.DB(\*args, \*\*kwargs)

Class to represent ComPoLyX database.

Access:

```pycon
>>> import compolyx
>>> db = compolyx.DB()

```

#### *property* active\_model

Active model.

#### clear()

Clear database.

#### clear\_generated\_data(model=None)

Function clears the eventually stored update results and deletes the generated data such as Production and Analysis Plies, Solid Models etc.

- **Parameters:**
    - model: The ACP model to be cleared.

#### close(model=None)

Close model.

- **Parameters:**
    - model: Model to close (optional). If no model is given, then all models were closed.

#### import\_model(name, path, format, ignored\_entities=None, convert\_section\_data=None, unit\_system\_type=None, reference\_surface\_input\_unit\_system\_type=None)

Create a model from file.

- **Parameters:**
    - name: Custom name of the model.
    - path: Path to the data file.
    - format: File format string. Choose one of ‘abaqus:inp’, ’ansys:cdb’, ‘ansys:dat’, ‘nastran:bdf’, or ‘ansys:h5’.
    - ignored\_entities: Entities to ignore. Can be a subset of the following list: \[‘mesh’, ‘element\_sets’, ‘materials’, ‘coordinate\_systems’, ‘shell\_sections’\].
    - convert\_section\_data: Whether to import and convert the shell section data into ACP composite definitions. Default is false.
    - unit\_system\_type: Set the unit system of the model to this type. Ignored if a unit system was already defined in the data file.
    - reference\_surface\_input\_unit\_system\_type: Set the unit system of the reference surface if the unit system cannot be read from the input.

#### *property* material\_data

Material Data Base.

#### *property* models

Models.

#### open(path, replace\_workbench\_inputs=None, pre\_db=None, unit\_system\_type=None, load\_cached\_data=False, apply\_shared\_commands=False)

Open ACP file and append the model to models container.

- **Parameters**
    - path: Path to ACP file.
    - replace\_mesh\_kwargs: Optional keyword arguments to replace the mesh to load in db.import\_model(…) upfront.
    - replace\_workbench\_inputs: Optional dictionary with Workbench inputs to replace before executing the .acp file.

#### open\_h5(path, cache\_data=False, apply\_shared\_commands=False)

Load a model from an ACPH5 database.

- **Parameters:**
    - path: acph5 file path.
    - cache\_data: Boolean whether to load the update results or not.
    - apply\_shared\_commands: Boolean to specify whether to load the Python commands from the ACP Shared section of the h5 file.

#### refresh\_acph5(path, external\_sources, input\_parameters=None, initialize=False, unit\_system\_type=None, upgrade\_from=None)

Refresh an acph5 db (Workbench mode only).

- **Parameters:**
    - path: File path to acph5 file.
    - external\_sources: Nested dict provided by ACP WB Add-in containing all the external sources info (the file path, whether the source was modified, its ID etc.).
        
        The keys of the dict are: \[‘model’, ‘materials’, ‘cad\_geometries’, ‘imported\_solid\_models’, ‘pre\_db’, ‘solutions’\].
        
        
        - Values for ‘model’ and ‘materials’ are dicts with the following fields \[‘path’, ‘external\_id’, ‘modified’\].
        - Values for ‘cad\_geometries’, ‘imported\_solid\_models’ and ‘pre\_db’ are list of dicts with fields \[‘name’, ‘path’, ‘external\_id’, ‘modified’\].
        - alues for ‘solutions’ are dicts with fields \[‘name’, ‘path’, ‘external\_id’, ‘modified’, ‘renumbering\_mapping\_paths’\] where renumbering\_mapping\_paths is a list of file paths.
    - input\_parameters: A dict of (name, value) pairs of WB input parameters.
    - initialize: specifies whether the acph5 database needs to be initialized (i.e. the file does not yet exist).
    - unit\_system\_type: Defines the unit system of the main/downstream ACP file.
    - upgrade\_from: Defines the path of a legacy (.acp) ACP DB that has to be upgrade to the new format (load composite definitions and save as ACPH5).

#### reload(model)

Reloads the reference surface (mesh) of the model. See reload\_mesh in the model for more details.

- **Parameters:**-model: The model to be reloaded.

#### save(path=None, model=None, cache\_data=None)

Save active model.

- **Parameters:**
    - path: File path.
    - model: Active model.
    - cache\_data: Whether to store the update results or not.

#### set\_unit\_system(unit\_system\_type)

Set the unit system of all models opened in the database.