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.
- Install Python
- Install pywin32
- Install Pyinstaller
- In a text editor, add the contents of the Python file we will use:
#! python import random a = random.gauss(10,1) print(a)
- To build the executable, write in the command line:
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.
- Open a BuildIT process
- Click on Add command: Category: General: Command: Shell command
- In the added Shell command, change the parameters as follows:
Script: The path of your .exe file created by Pyinstaller
Return Variable: SHELLRESULT
- Click on Add command:Category: Construct: Command: Point: Coordinates
- Click on Add command: Category: Edit: Command: Move
- In the added Move command, change the parameters as follows:
That’s it! When you run the process, the created point will move randomly.
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.