MicroStation Python: LA Solutions Project Structure

  • All Publications
  • Links
  • LA Solutions
  • Home
  • Books about Python
  • Article Index
LA Solutions
tel: +44 1398 361 800

Python

Simple projects need only one Python file (*.py) that contains code. Larger projects contain several files. Some files are used by more than one project.

When I write a Python example, I like to re-use components (Python modules) where possible. I've designed a folder structure that I hope is easy to understand and use.

Python project folder structure

Top-Level Folder

The top-level folder contains a set of example Python files that are brief. Each example imports the implementation file from an appropriately-named sub-folder.

For example, if you download the Export Text Elements project, you will find la_solutions_export_text_elements.py in the top-level folder.

Implementation Folder

Each example imports the implementation file from an appropriately-named sub-folder.

For example, if you download the Export Text Elements project, you will find …

  • la_solutions_export_text_elements.py in the top-level folder
  • export_text_elements.py module in the ExportText folder

Utilities and other Folders

Some samples are stand-alone and don't use any additional files. However, several examples use (in Python-speak, import) other Python files. You'll find those in the la_solutions folder. For example, configuration_vars.py, which contains helper functions that work with MicroStation configuration variables.

Other sub-folders include the la_solutions sub-folder that contains Python modules that are useful in several projects. For example, la_solutions\version_info.py provides the VersionInfo class. It's a simple way to encapsulate an app's version number and format it consistently.

Python __init__.py

You'll observe that those sub-folders have an empty file named __init__.py. That file is a signal to Python that the *.py code files in that folder are intended to be used by a project. Read more about __init__.py on web sites that deal with Python.


Trademarks

All trademarks are acknowledged. Trademarks may be registered in some jurisdictions.
e-mail Contact LA Solutions using this enquiry form.

Home
Home
Updated on 20-Jan-2025 Copyright © 2025…2025 Jon Summers