The 3DCoat Python API is intended to trigger UI commands, operate over the scene, and create new tools. It is very similar to the C++ Core API, but has its own advantages and drawbacks.
- No need for any additional setup to make your scripts; Python is embedded into the 3DCoat distributive.
- Python is like a Swiss-knife, allowing you to bring the whole power of Python libraries into 3DCoat.
- Python is much slower than C++, so it may be used only for general management, not for deep and complex algorithms.
- If you are already familiar with the C++ Core API, the Python API is very similar, almost 1:1, with the same logic and function names.
- Use Scripts->Create Python Script to create a new script. You may choose an initial template to start. The .py file will open in your current editor associated with .py files.
- We use embedded Python 3.8.10 to operate. This is the last Python version that may run on Windows 7.
- If needed, you may create a file called requirements.txt with a list of used modules; in this case, the modules will be auto-installed before the script runs.
- We recommend Visual Studio Code, as it will automatically recognize 3DCoat-specialized commands syntax and offer the correct hints.
- Pay attention: the file coat.pyi located in the project folder is responsible for the coat module hints in Visual Studio. You may open that file, as it contains the list of all classes and commands, which may be helpful for quick reference.
- Use Scripts->Show Python Console to see the console output from Python. Currently this is the only way to debug scripth. Later we plan to add native debugging using the Visual Studio Code.
- You may install additional modules for Python using Scripts->Install Python Modules. Another way is to use requirements.txt in the same folder as the .py file’s location.
- Access to live booleans via the python/CoreAPI.
General I/O: coat.io
Dialog management: coat.dialog
Mesh operations: coat.Mesh
Scene roots: coat.Scene
Scene element: coat.SceneElement
Volume management: coat.Volume
UI management: coat.ui
2D-vectors math: coat.vec2
3D-vectors math: coat.vec3
4D-vectors math: coat.vec4
3D-matrix math: coat.mat3
4D-matrix math: coat.mat4
Symmetry management: coat.symm