### Run Microstation Python API Tests using bmake Source: https://github.com/smilnee/microstationpython/blob/main/MSPythonTests/README.md This command initiates the execution of pytest tests for the Microstation Python API. Successful execution requires the built `.pyd` files to be correctly placed within the Microstation delivery structure and essential Python libraries such as `pytest` and `numpy` to be installed. It is crucial that your Python version precisely matches the one delivered with powerplatformpython. ```Shell bmake PlatformTests ``` -------------------------------- ### Configure Environment Variables for MicroStation Python Build Source: https://github.com/smilnee/microstationpython/blob/main/README.md Before building the MicroStation Python bindings, specific environment variables must be set in the MicroStation SDK Developer Shell. These variables define paths for the SDK, source code, build output, Python installation, and Boost headers. ```Shell set BMAKE_OPT= -I C:\src\MicroStationPython\build\PublicSDK\ -I C:\MicroStation2024SDK\include\ set BB_DEFAULT_TOOLSET=VS2019 set SrcRoot=C:\src\MicroStationPython\ set OutRoot=C:\out\MicroStationPython\ set PythonDir=C:\Python312\ set BoostInclude=c:\boost\boost_1_82_0\ ``` -------------------------------- ### Configure VSCode settings.json for Pytest with Microstation API Source: https://github.com/smilnee/microstationpython/blob/main/MSPythonTests/README.md Add these specific configurations to your VSCode `settings.json` file to properly enable and configure Pytest for the Microstation Python API tests. These settings define the test directory, disable `unittest`, enable `pytest`, set the current working directory for test execution, and specify `pytest` as the framework for the Python Test Explorer. ```JSON "python.testing.pytestArgs": [ "c:/MicrostationPython/MSPythonTests/PlatformTests/PublishedTests/" ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, "python.testing.cwd" : "c:/MicrostationPython/MSPythonTests/PlatformTests/PublishedTests/", "pythonTestExplorer.testFramework": "pytest" ``` -------------------------------- ### Configure PYTHONPATH for Microstation Python API in VSCode Source: https://github.com/smilnee/microstationpython/blob/main/MSPythonTests/README.md To enable VSCode to locate critical files like `MSPyBentley.pyd`, set the `PYTHONPATH` environment variable within a `.env` file located in your VSCode workspace root. This path must include the Microstation installation directories where the Python API files reside. Note that directory names containing spaces might cause issues, suggesting the use of short path names (e.g., obtainable via `dir /x`). ```Shell PYTHONPATH=c:/Program Files/Bentley/Microstation 2024/;c:/Program Files/Bentley/Microstation 2024/Assemblies/;C:/Program Files/Bentley/Microstation 2024/MdlSys/Asneeded/;C:/Program Files/Bentley/Microstation 2024/MdlSys/FileHandler/; ``` -------------------------------- ### Set MSPYTESTDATA Environment Variable for Microstation Tests Source: https://github.com/smilnee/microstationpython/blob/main/MSPythonTests/README.md Before launching VSCode, set the `MSPYTESTDATA` environment variable within your MicroStationSDK command shell. This variable is crucial as it points to the data directory required by the Microstation Python API tests. Launching VSCode from this pre-configured shell ensures that it correctly inherits this environment variable. ```Shell set MSPYTESTDATA=c:MicroStationPython/MSPythonTests/PlatformTests/data/ ``` -------------------------------- ### Execute MicroStation Python Bindings Build Source: https://github.com/smilnee/microstationpython/blob/main/README.md After setting the required environment variables, navigate to the MicroStation Python source directory and run the `bmake` command to compile the project artifacts. ```Shell cd \MicrostationPython bmake MSPython ``` -------------------------------- ### Configure VSCode settings.json for MicroStation Python Intellisense Source: https://github.com/smilnee/microstationpython/blob/main/MSPythonSamples/Intellisense/README.md This configuration snippet for VSCode's settings.json file enables Intellisense for MicroStation Python APIs. It sets the default Python language server and specifies additional paths where the Intellisense .pyi files are located, allowing features like Ctrl-Space for suggestions. ```JSON "python.languageServer": "Default", "python.analysis.extraPaths": [ "C:/ProgramData/Bentley/PowerPlatformPython/Examples/Microstation/Intellisense"] ``` -------------------------------- ### Executing Python Scripts and Commands in MicroStation Source: https://github.com/smilnee/microstationpython/blob/main/MSPythonSamples/DgnElements/Reference/Reference.txt This sequence of MicroStation key-in commands demonstrates how to load the Python interpreter, load a custom Python script (e.g., 'Reference.py'), and then execute functions defined within that script ('pyreference attach', 'pyreference rotate'), interspersed with standard MicroStation commands for view manipulation and element selection. The 'pause' commands are used to observe the effects of each step. ```MicroStation Key-in mdl load ustnpython python load Reference.py pyreference attach fit view extended mdl keyin pselect choose element pause 2 pyreference rotate pause 2 ``` -------------------------------- ### Load Python and Execute Script in MicroStation Source: https://github.com/smilnee/microstationpython/blob/main/MSPythonSamples/3rdPyLibs/ExchangeDataBetweenExcelAndItemType/Repopulate Items from Excel.txt This snippet provides the command-line instructions to be executed within MicroStation to enable Python scripting. It first loads the MicroStation Python interpreter, then executes a specified Python script (e.g., 'RepopulateItemsFromExcel.py'), and finally updates all fields in the active design file to reflect any changes made by the script. ```MicroStation Command mdl load ustnpython python load RepopulateItemsFromExcel.py field update all ``` -------------------------------- ### Load MicroStation Python and Execute Script Source: https://github.com/smilnee/microstationpython/blob/main/MSPythonSamples/3rdPyLibs/ExchangeDataBetweenExcelAndItemType/Extract Item Types to Excel.txt These commands are used within the MicroStation environment to first load the Python interpreter module (`ustnpython`) and then execute a specific Python script (`ExtractItemTypesToExcel.py`). This sequence is typical for running custom Python automation within MicroStation. ```Shell mdl load ustnpython python load ExtractItemTypesToExcel.py ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.