Batteries included: using Python scripts in BuildIT

August 23, 2016 Onat Ekinci

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 parameters
  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 parameter

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.

Previous Article
Maximum Material Boundary & its advantages in GD&T analysis
Maximum Material Boundary & its advantages in GD&T analysis

The goal of this blog post is to present the maximum material boundary (MMB) concept in GD&T applications. ...

Next Article
BuildIT releases version 2016.5 of 3D metrology software
BuildIT releases version 2016.5 of 3D metrology software

BuildIT’s latest version adds numerous scanning and meshing features Montreal, QC, July 2016 – BuildIT Soft...

×

Try FARO BuildIT Metrology Today!

First Name
Last Name
Company
Country
State or Province
Zip or Postal Code
Primary Goal
GLOBAL_Opt-In
Access your FREE 7-Day Trial
Error - something went wrong!