Willmac16 / OctoPrint-TranslateModel

An OctoPrint plugin to move models around without re-slicing
https://plugins.octoprint.org/plugins/translatemodel/
GNU Affero General Public License v3.0
7 stars 1 forks source link

Need similar plugin, can you maybe help? #14

Open evilC opened 1 year ago

evilC commented 1 year ago

Hi, apologies if this is a little cheeky, but I need a similar kind of plugin and I wondered if you could give me some direction or maybe even help (I am a coder, but I have never done an Octoprint plugin before).
I have an IDEX printer and want a plugin that will change all instances of E0 to E1 - such that, if I have a GCode file which is sliced for Extruder 1, instead have it print using Extruder 2 (Because the filament I want is already loaded into extruder 2).
Your plugin already does a lot more complex stuff - I just need to work out what bits I need to change to make it a unique plugin, and where my entry point is. I guess essentially what you are doing is registering some hook - you get passed each line of Gcode and do some string manipulation, then write it out.
If you could give me a leg up, I would really appreciate it.

Willmac16 commented 1 year ago

Hi @evilC, I'm happy to help!

Depending on what exactly you want, I would actually recommend you look at a different plugin of mine, because this one is a bit funky. I made this plugin to explore accelerating the file preprocessing by using C++ instead of native python.

If you want this to process all files uploaded then you can do this with a preprocessor hook "octoprint.filemanager.preprocessor": __plugin_implementation__.createFilePreProcessor,, which should point to a class that extends octoprint.filemanager.util.LineProcessorStream and importantly implements a process_line function. The actual function can probably be a single line of regex.

Otherwise, if you want similar UI functionality to how this plugin works (buttons in the file manager that launch a popup, then processing), I would suggest you clone/fork my repo and just tweak what you need to make it yours (rename things, change icons, rework the UI to have a swap from and swap to extruder setting, and rewrite the body of the TranslateWorker class to do your file translation).

And make sure to checkout the plugin tutorial

Whatever you choose, if you share your repo with me, I'd be happy to take a look and give you advice as you go.