A cell library is a DGN file.
Usually, it has file extension .cel
.
Just like any other DGN file, a cell library contains models.
Each model may be designated as a cell.
A cell may be 2D or 3D.
To read the cells from a library is the same as reading models from a DGN file.
First, get a reference to the active cell library file object.
We show how to obtain a cell library object reference. We wrapped that in a simple function call …
GetActiveCellLibraryObject(lib_reference)->bool
That function attempts to obtain the cell library reference for the active cell library.
If successfull, it returns True
and lib_reference
is a valid DgnFile
.
The way to enumerate the models in a DGN file (or the cells in a cell library) is to get a
ModelIndex
…
model_index = lib_reference.GetModelIndex()
A
ModelIndex
is a collection of
ModelIndexItem
.
We can enumerate the ModelIndex
to get the details of each model (cell) in the DGN file.
You can use a for
loop, but here's how to do it using a
Python list comprehension
…
cell_list = [model_item.GetName() for model_item in model_index if model_item.IsCell()]
cell_list
is a Python list
of cell names.
Unpack the ZIP file and copy the Python files into a folder that MicroStation knows about.
Use MicroStation's Python Manager to find and execute the script …
Post questions about MicroStation Python programming to the MicroStation Programming Forum.