MicroStation Help

Python Manager dialog

Used to create, interact with, and edit Python scripts in the MicroStation Application. Python scripts are not embedded in the DGN file, they are stored separately in .py file format.

You can access this dialog from the following:
  • Ribbon: Drawing > Utilities > Macros > Python Manager
  • Ribbon: Modelling > Utilities > Macros > Python Manager




SettingDescription
Create Python Project


Opens the Create Python Project dialog which allows you to create a new project.
Open a Python project from disk


Opens the Open File dialog where you can select and load an existing project. Once loaded, the macros in the selected project appear in the Python Manager list box.
Open Folder


Allows you to add the folder in which you have stored your scripts. Once loaded, the macros in the selected project appear in the Python Manager list box.
Close Folder


Unloads or removes the selected project. When you remove, the macros are removed from the Python Manager amd Macros dialog list box.
Run Python File


Runs or executes the selected Python scripts.
Edit Python File


Allows you to select the editor to edit any Python scripts from the dropdown menu. You can choose from:
  • Python Editor - Allows you to edit the Python script in Python Editor.


  • Notepad - Allows you to edit the Python script in Notepad.
  • Or any other editor available on your machine.
    Note: All available editors will be displayed in the drop-down menu. For example: If you download Visual Studio Code, it will be visible in the drop-down menu.
  • Browse - Allows you to add an editor to the drop-down menu.
Note: Once the editor gets added to the drop-down menu, it cannot be removed.
Project Name Displays the name of all the projects created.
Argument An argument is a string passed into a Python script to be edited.
Key-in Names Description
Python Load

Used to run python scripts.

For example:python load " LineExample.py".

Python Query Version

Used to display the version of current python APIs.

Python Status

Used to identify if the python interpreter is installed in MicroStation.

Python Unload
Used to clear internal status of data that was generated by running python load “Drawline.py”.
Note: The output generated from python load "LineExample.py", will not be affected.

Python Manager Variables

Variable Short Name Description
MS_PYTHON Python Interpreter Defines the path to the python interpreter embedded in the product process to run the python script when launching the product.
Note: The default value is $(ALLUSERSPROFILE)/Bentley/PowerPlatformPython/python/.
MS_PYTHONNEWPROJECTDIRECTORY Python New Project Directory Defines the directory where new python files are kept.
MS_PYTHONSAMPLES Python Samples Defines the location of the Python samples in the directory.
MS_PYTHONSCRIPTS Python Scripts Defines a list of paths to search for python files.
MS_PYTHONSEARCHDIRECTORIES Python Search Directories Directories to search for the python file while running keyin 'Python Load *.py'.