Batteries Included: Using Python Scripts in BuildIT

,
BuildIT Python Scripts in Automation

Did you know that you can use Python scripts in BuildIT?  If you transform your Python files into executable files, you can import them into BuildIT processes. With this workflow, you can combine the richness of Python libraries with the ergonomic practicality of BuildIT processes.

In this post, we’ll focus on a very basic workflow for generating a random number in Python, which we will then use within a BuildIT process to move a constructed point.

Using Pyinstaller to create .exe files from Python files

In this section, we will transform an existing .py file into a .exe file. We used Pyinstaller to do this, but there are other software options available for this purpose.

  1. Install Python
  2. Install pywin32
  3. Install Pyinstaller
  4. In a text editor, add the contents of the Python file we will use:
    #! python
    import random
    a = random.gauss(10,1)
    print(a)
  5. To build the executable, write in the command line:
    pyinstaller.exe name_of_the_file.py

Or you could also follow these instructions to create an executable from a python script for more information.

Using the .exe file inside the BuildIT process file

In this section, we will explain the steps to include the created Python file in a BuildIT process.

  1. Open a BuildIT process
  2. Click on Add command: Category: General:  Command: Shell command
  3. In the added Shell command, change the parameters as follows:
    Script: The path of your .exe file created by Pyinstaller
    Return Variable: SHELLRESULTAdded Shell command parameter
  4. Click on Add command:Category: Construct:  Command: Point: Coordinates
  5. Click on Add command: Category: Edit: Command: Move
  6. In the added Move command, change the parameters as follows:
    Distance: $(SHELLRESULT)Added move command parameters

That’s it! When you run the process, the created point will move randomly.

Conclusion

Our aim here was to give a very simple example of plugging Python “batteries” into the BuildIT power tool. Using this powerful combination, we can imagine and implement many combinations and potentialities for various applications. We’ll expand more on this in the coming posts.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply