MicroStation Python: A Journey to Hello World


 

Welcome to the world of MicroStation Python! This wiki will guide you through creating your first Python program in MicroStation, a leading computer-aided design software for infrastructure design.

 

Your First Python Program in MicroStation

Let us dive into creating a simple "Hello World!" program in Python.

 

Create and Load project

To create a new Python project in the Python Manager, click the Create a New Python Project icon image and name it "HelloWorld.py". Save it to your preferred directory.

Within the Python Manager, locate your project "HelloWorld.py" in the project list. Click the Edit Python File icon image to open the editor for writing your Python script.

 

Import Modules

The import datetime line brings in the datetime module, offering functions to work with dates and times.

 

import datetime

 

Print Messages

The print statements display text to the console "MicroStation - Text Window". Copy or type the following code into editor. Save the "HelloWorld.py" project.

import datetime

# print 
print("Hello World!")

# print variables  
s1 = "Hello"
s2 = "World!"
print(s1 + ", " + s2)

# print current date with f-strings
today = datetime.datetime.today()
print(f"{today:%B %d, %Y}")

 

 

 

 

Run/Execute project

Select project "HelloWorld.py" from the Python Manager dialog and click on icon image to Run/Execute the python script.

"MicroStation - Text Window" displays the output of your script.

image

Congratulations! You've just run your first Python program.

 

Further Reading

To delve deeper into Python programming in MicroStation, check out the following wikis:

These resources will provide you with more examples and detailed API documentation to help you on your journey with MicroStation Python.

Happy coding!

 

 

Python: Documentation | API Presentations | FAQs | GitHub | Samples | Wikis | Blogs