5axes / Calibration-Shapes

A Cura plugin that adds simple shapes (cube, cylinder, tube) and also 24 Calibration and test parts + 7 Postprocessing scripts
GNU Affero General Public License v3.0
340 stars 69 forks source link

Use postprocessing scripts without copying them #1

Closed fieldOfView closed 3 years ago

fieldOfView commented 3 years ago

It should be possible to use your postprocessing scripts without first having to copy them over and restart Cura. Cura should be able to find the scripts from inside your plugin folder if you move your scripts folder to into a folder named resources, and add this to your plugin initialisation:

Resources.addSearchPath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources"))

This will add that resources folder to the paths Cura checks for script files.

5axes commented 3 years ago

Unfortunatly no it doesn't work. Your solution is correct but as the PostProcessingPlugin is launched before my custom plugin, even if the code is correct the scripts are not loaded byt the PostProcessingPlugin via the function : def loadScripts(self, path: str) -> None:

2021-01-18 14:36:53,431 - INFO - [MainThread] UM.Logger.info [122]: Loaded plugin PostProcessingPlugin ... 2021-01-18 14:36:54,382 - INFO - [MainThread] UM.Logger.info [122]: Loaded plugin SimpleShapes

fieldOfView commented 3 years ago

It doesn't work, but that is not because the PostProcessingPlugin loads before your plugin, but because the PostProcessingPlugin does not use the resource search paths correctly :-(

https://github.com/Ultimaker/Cura/blob/4.8/plugins/PostProcessingPlugin/PostProcessingPlugin.py#L145 Instead of using getStoragePath, it should be using getAllPathsForType. Oh well, it was worth the try.

nallath commented 3 years ago

Whoops, that's our bad :(

fieldOfView commented 3 years ago

It just might be my bad ;-)

https://github.com/nallath/PostProcessingPlugin/commit/12d4d177b624272a0083b0ecc17f737c3c19ca1d#diff-29915b71ed69033c978493b7def0019f64e3064ac80c4ab127d74ac5d3c3628bR159

fieldOfView commented 3 years ago

Here's a fix: https://github.com/Ultimaker/Cura/pull/9147

nallath commented 3 years ago

It just might be my bad ;-)

nallath/PostProcessingPlugin@12d4d17#diff-29915b71ed69033c978493b7def0019f64e3064ac80c4ab127d74ac5d3c3628bR159

Well, we were still paying you at that time, so it's our fault :P

fieldOfView commented 3 years ago

Nope, this was a year and 2 days after my last day on the team... But it was your fault for not spotting it in the review ofcourse. It is always your fault.

nallath commented 3 years ago

It is always your fault.

Damn right! :D

nallath commented 3 years ago

I just merged the PR.

5axes commented 3 years ago

Ok I have modified the source code V1.3.0. Don't need to use the Copy scripts function anymore. Have been removed from the menu thanks for your help @nallath and @fieldOfView