Help out and get a gratuity of 250€¹:
During many years PyWin32 is the Python module which provides bindings to many native Windows functions. It also includes a client to access Windows Automation (COM) services, like CAD or office software. Due to a
In the past, it was possible to create Windows Automation (COM) servers with PyWin32 and py2exe. But due to ABI changes in Python 3.5+ py2exe is dead, but it came with some necessary code on a low-level, which allowed the handling of events in the COM server. At least this is what I noticed while reading through old articles and comparing some code between cx_Freeze and py2exe.
Therefore the only alternative to use is cx_Freeze, BUT that one doesn’t come with the necessary bits to access events. The good info is that cx_Freeze is already being used to build executables for Ultimaker Cura. So there won’t be much needed to be done in the build system to create the final NSIS installer.
The following tasks shall be fulfilled while using the codebase of Ultimaker Cura 4.0. That means that the following pairs of software and version must be used as a minimum to replicate this version of Cura. As needed patchwork can be done on these projects to reach the goal of the whole subscription.
- Python (version 3.5.x)
- Qt (version 5.11)
- PyQt (version 5.11)
- cx_Freeze (version 5.0)
- PyWin32 (version 211 provided with Interface plugin)
Here is a group of tasks, which shall be completed chronologically. At least the following listing makes sense to me to be processed like this.
Task #1: Ultimaker Cura as COM server with event support
About one year before I began to develop a so-called “Interface plugin“. This one is already able to crawl through Python instances and determine functions and variables. Then these get accessible automatically via Windows Automation (COM). Sadly I tried for hours to get events working, but I couldn’t find a solution. So hereby it will be your task to do patchwork around the Interface plugin, PyWin32 and cx_Freeze to get events properly exchanged with an external COM client (see below). So it is a must that you manage to get the following working: Run a function using a COM client in Cura, which emits a Qt signal together with the data (the dummy result). This Qt signal should be connected to a Python function (Qt slot), which again sends the COM event back to the COM client. While sending this COM event back the same data must be returned to the COM client as passed from the emitted Qt signal to the Qt slot. If this is proven to work (task #3), then it should be fairly easy to replicate existing Qt events in Cura, like updated layer heights, while changing the printer or the extruders, to COM events.
Task #2: Preparing an IDL file for Ultimaker Cura
The abbreviation “IDL” stands for “Interface Definition Language” and is being used to describe interfaces of COM servers. Using IDL files it is made very easy to code in Visual Studio 2017 (community edition) and prior versions. Using the info inside these files autocompletion is possible while doing the programming of your COM client. For example, PyWin32 has also a mechanism to parse this info and generate dummy modules. Maybe this mechanism is something that is worth to take a look at. As you can see in Cura.idl inside the Interface plugin, I already tried to write such a file but was overwhelmed with that as I have no experiences with this functionality.
Task #3: Prove of concept – Ping&pong test
The following scenario must be proven:
- Running Ultimaker Cura as COM server using Python 3.5, cx_Freeze and PyWin32.
- This client must be written in Visual Basic on Visual Studio 2017 (Community edition). This client shall execute a function in the COM server.
- The server should trigger an event with a result. The type of data, which shall be transferred using this event, must be a list. Since there are no “lists” but in Visual Basic, it must be then a array of strings or numbers, of course. At least this is what I know about Visual Basic.
- The COM client should confirm that an event has been received. This can be done using a text widget, which shows the result. This should be proof that we can run a function to make changes to Cura and receive the following “consequences” as events. These can be changed choices of slicing heights, available slicing profiles or available extruders.
Task #4: Documentation of the work
As usual in professional work environments, it is necessary to document work, which needs to be done here. There must be a clear guideline, so other people including me understand how to provide events on a COM server and how to access them via a client application. This can be done using the proof of concept like above as a practical example. Additionally, it must be possible to follow, how to create and edit an IDL file, so it can be expanded with new functions and events, too.
- All needed patches on any project mentioned above need to be shared as pull requests on GitHub and need to be merged by the maintainers to ensure long-time support.
- If you manage to get the following issues solved, you can earn the promised tip. However, to earn it all the tasks mentioned above need to be achieved. You can share the workload with someone else. But communicate and plan well because I don’t want to deal with disputes about which portion of the tip someone is getting. So to make that clear the tip is NOT per person but per solving all issues mentioned.
Are you interested? – Then register!
Just write me a mail or use the contact form to apply for this project. The tip will be transferred via SEPA transfer or PayPal. Any other method of transferring money or the usage of cryptocurrencies, like BitCoin,
And another hint: From what I see from cx_Freeze’s repository and conversations on the internet, I have the feeling that there were some efforts in getting better support with PyWin32. But for some reason, this code has been dropped or it has been missed while moving the code repository. Maybe that helps somehow.
¹ The amount of the donation can change depending on whether I find sponsors in the meantime.