Python scripting feature for appleseed.studio
- All goals have been met
- Over 30 pull requests were merged
- Got experience with
- Contributing to open-source product
- Remote work
- Development of C++ project with large codebase
- Frameworks: Qt and PyQt, Boost and Boost.Python in particular
After first contact with appleseed I fixed some bugs and implemented a small project to get familiar with people, codebase and workflow in organization. Project was to implement packaging appleseed projects to zip-based containers with appleseedz format.
appleseed project is consisted of main appleseed file and dependencies like textures. In appleseed file all paths to dependencies are listed. Previously you would need to keep original project structure or manually change paths in appleseed file to be able to open projet shared by another user. With applessedz projects users can easily share their scenes because all files are stored in the archive and project structure will always be the same.
During this project I designed and implemented zip-based project format called appleseedz and added ability to natively read and write appleseedz format in all appleseed components.
Key pull requests are in bold. There are also decriptions inside prs themselves.
- #1283 Explicitly set C default library locale
- #1300 Open packed project
- #1306 FIX: bug when valid packed project doesn't open
- #1311 Add tests for unzipper and packed project
- #1316 Packed project minor issues
- #1320 Restore accidentally deleted parentheses
- #1336 Implemented ability to open packed projects in studio
- #1343 Usability changes for opening packed projects
- #1345 Save packed project feature
- #1353 Enhancements for packed projects
- #1357 Add "Pack Project As..." button to menu
- #1373 FIX: Change delimiter ';' on ' ' in QT file dialog filters
- #1396 Implement using of packed projects as archive projects
- #1404 FIX: Changed "Pack as..." button behavior
- #1425 Change relative search path on absolute one
My summer project was to implement and explore possible use cases of Python scripting for appleseed.studio. appleseed.studio is a GUI for appleseed renderer that allows to inspect, modify and render scenes. Python scripting is a useful feature for applications like appleseed.studio as it allows to automate repetitive actions, speed up development and expand functionality with user plugins.
As appleseed is written in C++ it was necessary to provide Python bindings for its functionality. There already were bindings for core functionality and my goal was to add bindings for studio-specific functionality like GUI project management and direct access to GUI Qt classes. To provide bindings I implemented new Python module containing studio-specific functions using Boost.Python library. To keep the code clean this part required quite a lot of refactoring.
To use Python binding we should be able execute code inside appleseed.studio. To achieve this I integrated Python interpreter inside appleseed.studio. This part also required to change cmake configuration.
Python console widget was implemented to provide ability to write and modify Python scripts. With all its features: code highlighting, autoindentation, file management and others - I wrote a decent amount of new code to appleseed.studio and intensively used Qt framework.
With all this done, it became possible to make use of appleseed functionality exposed to Python. Next step was to let users expand functionality. It was achieved with plugins. Plugin is just a Python module with register function placed in a specific directory. To give an example of how plugins can be written, I created a plugin that converts all textures in project to tx format that is more effective than simple png or jpeg for rendering purposes. This plugin basically sums up all the work: it retrieves Qt classes to add menu to main window of applessed.studio, uses studio-specific and core appleseed bindings to replace old textures with converted ones and registers automatically with implemented plugin system.
During all development we with mentors discussed project daily. It had a huge influence on the process because they could guide me during implementation of every feature which made development process very productive. Also code was merged to master often giving whole community an ability to try new features, so I was receiving priceless feedback often and early. Thanks to many discussions prior to GSoC and thorough planning of timeline all goals were met and new functionality is ready to use.
- appleseed.studio main window with opened project (appleseed shaderball). In the top menu bar you can see menu entry which is added with Python plugin bundled with appleseed, at the bottom Python console is opened.
- Python console in details. Some features of console are highlighted.
- Gaffer (scene generation tool) opened in Qt widget that was created with script and inserted to appleseed.studio's main window.
Key pull requests are in bold. There are also decriptions inside prs themselves.
- #1440 Python console
- #1454 Console adjustments
- #1464 Studio python module
- #1493 Python console refactoring
- #1498 Fix regression
- #1509 Python console issues
- #1513 Python console minor issues
- #1537 Python console usability work
- #1546 Add appleseed.studio to Travis build
- #1554 Studio python bugfixes
- #1558 appleseed.studio module enhancements
- #1569 Implemented studio.add_dock function
- #1572 Python modules improvements
- #1578 appleseed.studio python module improvements
- #1582 General texture converter implementation and function to use it in appleseed.studio
- #1587 New UI helper and fixes for Python interpreter
- #1599 Studio python plugins
- #1606 Different fixes