Scripting is a perfect way of extending RealFlow's capabilities or develop your own customized solutions. For this purpose, RealFlow offers a Python interface which provides all necessary commands and functions to control most of the software's nodes, parameters and attributes. The description of such an interface is called Software Development Kit (SDK). There you can find all available commands together with explanations how to use them. RealFlow's Python-SDK is part of the internal Help Viewer and can be used directly within the application.
Python has many advantages:
- Easy to learn. Python is perfect for beginners, because the source code is easy to read and understand.
- Flexibility. Python is available for all operating systems and there are many free extensions.
- Active community. There are lots of developers who are constantly extending Python with new modules.
- Wide distribution. Python comes with all Unix and Linux operating systems, as well as with OS X. Of course, there is also an easy-to-install version for Windows.
- Many resources. The web is full of Python resources and there are lots of very good books and publications for all levels of knowledge.
- Quasi-standard. Many 3D packages support Python, making it possible to directly access the data structures of a program. Maya, for example, introduced Python as an alternative to MEL. Over the years, Python has become the standard scripting language for many applications.
- Free license. Python is free, even for commercial projects.
All these advantages are good reasons for an implementation of Python into RealFlow. Python is a full-featured scripting language with support for modern structures, such as object-oriented programming, also called OOP, or hashes for fast search algorithms. It is also possible to establish database connections to store and administrate large amounts of data. Other packages offer functions for numerical calculations, image generation, and OpenGL support. There are also many modules available for 3D graphics and visualization Next Limit introduced a Python interface giving the user the ability to overcome many of the restrictions known from earlier RealFlow versions. With RealFlow 2012 the entire Python distribution has been extended to support all the new features.
An often-discussed issue is Python’s inability to use more than one processor, also called multi-threading. Please be aware that:
- Python is single-threaded by default, but RealFlow is not. Python’s limitation has a direct effect on RealFlow’s simulation speed when scripts are involved.
- Executing Python scripts is not completely single-threaded. Computers and operating systems always use more than one core or processor, though it is not possible to address them directly.
- Python provides some libraries for multi-threading support, but they only work on few platforms and in the worst case you have to recompile your Python distribution.
You can speed up Python scripts with effective programming and data structures. Ask yourself:
- Do I always need large lists or can I loop through my objects with a while statement?
- Is there a point where I can empty a list and free memory?
- Do I really need all global variables?
- Is there unnecessary code within my script?
- Are there ways to shorten or contract my code and statements?