Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add Spoolman Compatability #4771

Draft
wants to merge 81 commits into
base: main
Choose a base branch
from

Conversation

Ocraftyone
Copy link
Contributor

@Ocraftyone Ocraftyone commented Mar 29, 2024

Add Spoolman support to OrcaSlicer!

Spoolman is a self-hosted database of your spools of filament and how much has been used. This update now allows OrcaSlicer to directly access your Spoolman database to create and update filament profiles. One central database of all of your spool settings means less time inputting filament parameters.

Currently, this implementation is designed to only work with Klipper printers that have moonraker also set up with Spoolman. A macro can then be called at the beginning of each spool's custom gcode to load the spool via moonraker. Moonraker will then track how much filament was used and report that back to Spoolman.

Demo:
spoolman demo

Filament config values that are set

Spoolman Specific:

  • spoolman_spool_id
  • spoolman_remaining_weight
  • spoolman_used_weight
  • spoolman_remaining_length
  • spoolman_used_length
  • spoolman_archived

Filament Options:

  • filament_type
  • filament_vendor
  • filament_cost
  • filament_density
  • filament_diameter
  • nozzle_temperature_initial_layer (set by adding 5 degrees to normal temp)
  • nozzle_temperature
  • hot_plate_temp_initial_layer (set by adding 5 degrees to normal temp)
  • hot_plate_temp
  • default_filament_colour

Other ideas to expand functionality:

  • Check if spool has enough material to finish print upon slicing
  • Add option to "consume" filament upon upload
  • Store the entire filament configuration in Spoolman (via the Spoolman API's "extras" section)

Possible Changes:
Statistics are currently a config value that is updated upon request, but I am considering making it so they are just pulled when you select a Spoolman spool This has been implemented.

Moonraker Docs on how to setup Spoolman integration: https://moonraker.readthedocs.io/en/latest/configuration/#spoolman
Spoolman Project: https://github.com/Donkie/Spoolman

fixes #2955

-Spoolman utility class that fetches the spools, creates filament presets, and updates filament presets
-Add config entries for all needed values
make the config argument const. Allows more flexibility when calling it and in its current implementation, non-const access is not needed.
add force and detach options to create function

move call to get_filament_id past failure checks in the create function. It takes a few seconds to run and it is better to not run it if you don't have to

create get_name_from_spool function
Wouldn't load the filament if the "inherits" preset is not a base preset. The check is now done and it gets the base preset's parent if it needs to.
Added dialog itself

Added as it an item on the PlaterPresetCombobox

New extra renderer that renders a color in a dataview cell
# Conflicts:
#	src/libslic3r/Preset.cpp
#	src/slic3r/CMakeLists.txt
Merge in previous commit had a conflict that caused compile error.

Refactor code from merge to make it more readable

Add Refresh statement in the update to fix weird artifacting after selecting certain host types
Add Spoolman::is_server_valid()

Check validity of server in SpoolmanImportDialog and in Tab when clicking the update buttons

Hide the update buttons if Spoolman ID is 0

Check results from spool update when updating spools
@Ocraftyone
Copy link
Contributor Author

Ocraftyone commented Mar 29, 2024

@Noisyfox I did a refactor of a few lines of PhysicalPrinterDialog in 4ec7c12 that makes it a bit more readable with my changes. I don't believe I broke any of the functionality of your SimplyPrint integration, but if you could take a look at it and confirm, it would be much appreciated.

Also minor fix regarding hiding scrollbars
@YanceyA
Copy link

YanceyA commented Mar 29, 2024

This is great! Big kudos for the work.

@Zimbo111
Copy link

If Spoolman could be integrated like this, it would be great. Many thanks for the work . I hope it will be implemented

@CooperGerman
Copy link

can't wait to see this integrated =)

@Ocraftyone
Copy link
Contributor Author

I was taking a bit of a break from this to work on the CMake system overhaul PR. Moving back to this to hopefully get it finished up 😊

…poolman-support

# Conflicts:
#	src/libslic3r/Preset.cpp
@besser
Copy link

besser commented Apr 20, 2024

@Ocraftyone this integration you did was awesome!!!
Can't wait to see this integrated too :)

@Jesibu
Copy link

Jesibu commented May 12, 2024

Can't wait to see this released :)

@StuSerious
Copy link

Spoolman is now able to pull from a global database of filaments, materials and manufacturers (see https://github.com/Donkie/SpoolmanDB), should you be interested in implementing it as a feature (say to search for your new spool directly in the slicer) I'd be willing to help test/develop!

-check if the base_preset is valid. If it isn't, the current edited preset is used

-if there is an existing preset, check if it is a system preset. If it is, do not allow overwriting

-update the generation of the preset name to include the printer name

-only check for presets with the same spool ID within the list of compatible filament presets. users should be allowed to have different presets with the spool ID for different printers

-check if the materials are the same between the spool and base_preset

-when setting the "inherits" config value, get the first preset that is a system preset or base user preset in the inheritance hierarchy

-add translation to messages

-update get_preset_name() to prevent extra spaces
-general cleanup

-remove the check to see if the spool's preset name is the same as the current preset's name. this is handled in the Spoolman create function

-update how the error message is generated

-properly handle wide unicode chars in the preset names

-check for errors when retrying spools

-add translation to messages
@SamueldaCostaAraujoNunes

This feels so right! What an amazing job, I hope to see it on OrcaSlicer soon!

This allows these options to be saved across printer presets.

This commit removes the options from PhysicalPrinterDialog.cpp and does not include a way to set the values in the program. This will be implemented in a future commit.
…options

Adds fake options that save to the app config. These options are available regardless of what host type is selected
…eset_from_spool

When starting with an empty spoolman instance or after clearing the spoolman instance, spools should be pulled from the server the next time you try to do a spoolman action. This would not happen when calling Spoolman::update_filament_preset_from_spool because it was directly accessing the vector of spools rather than accessing them through the helper function
@Ocraftyone
Copy link
Contributor Author

Ocraftyone commented Feb 5, 2025

Hello all!
Thank you again for all your patience. I believe this is now ready for testing! There are still incomplete feature, such as creating a dedicated Spoolman management dialog, but the functionality is implemented. Please let me know any issues or areas you feel may need improvement.

Features since my last update:

  • Spoolman settings are stored in the app config, so the server is shared across printer profiles
  • Add filament consumption via the slicer

Features TODO:

Here is a link to the latest build: https://github.com/SoftFever/OrcaSlicer/actions/runs/13477830428?pr=4771

Happy testing and thank you again!

Edit 2/6: Update link to go directly to download
Edit 2/22: Update to new build link

@ducati1198
Copy link

Wow great work thanks you very much can’t wait to try this

@PaulMellor
Copy link

Looking forward to this as was able to import profiles, but really want that one central place for all my filaments, and them work together with HappyHare. Happy to be a tester and provide some feedback When you are ready for third party testing.

@AlexTheGreat1971
Copy link

Thank a lot. Great work, finally!
0d09b683-c7cf-41d1-bb86-faf1b9bfad96

  1. For sake of maintaining the overall design style, I would change the color of the buttons to greenish.
  2. When importing a filament from Spoonman DB into an existing filament in Orca, I would like not to duplicate it, but to fill in the Spoolman tab of this filament.

@CooperGerman
Copy link

Hi, thx for the great work, i was eager to try this one out for a while =)

So i ran the latest Appimage and noticed the following little issue:

  • Firstly i had to set my spoolman url to spoolman-serv because http://spoolman-serv would freeze OrcaSlicer, and spoolman-serv:7912 would get me an error telling me that the spoolman-server cannot be found eventhough my port is the default 7912 one. (My guess would be that this might be linux related ?)

FYI : Happy Hare is currently betatesting a mainsail/fluidd integration of a MMU control and monitoring widget that looks like this :
image

I would image one could retrieve the spools "assigned" to a printer using the exposed information from HappyHare to automatically set the spools in Orca for a printer (in a similar fashion than Bambu/AMS).

Concerning the philosophy behind the usage I'm actually wondering how my use case fits in. I'm currently on a Orca, klipper, HappyHare and Spoolman ecosystem, and for now the automapping feature from HappyHare allows me to automatically select the right filament(s) at a print start based on the name (in my case). For this to work i do need to have the spoolman db containing exact name matches of my filaments that I have on the OrcaSlicer side.
This leads me to think about the current implementation. Your version is based around assigning an Orca Filament a spoolid, and thus is limited to the specified spoolid i would guess ? Could it be possible to assign the filament id rather that the spoolid in order for Happy Hare to automap according to it ? This would also enable the reuse of the gcode, enable the "endless spool" feature from Happy Hare and could be "easier" to use for people with many instances of the same filament.

I'm open to discuss this (on discord for example if need be) and test more of your features as they arrive, keep on the good work !

@Ken6432
Copy link

Ken6432 commented Feb 19, 2025

This looks great! Thanks for doing this. I have one question. Previously, on the filament dialog's Advanced tab, I had to add the command "SET_ACTIVE_SPOOL ID=xx" in the start G-Code and "CLEAR_ACTIVE_SPOOL" in the end G-Code. When using this integration and having the spool number set on the Spoolman tab, are these commands still needed? Or, does the integration automatically add the g-code? If it is not automatically added, what is the suggested approach? -- Thanks!

@CooperGerman
Copy link

This looks great! Thanks for doing this. I have one question. Previously, on the filament dialogue's Advanced tab, I had to add the command "SET_ACTIVE_SPOOL ID=xx" in the start G-Code and "CLEAR_ACTIVE_SPOOL" in the end G-Code. When using this integration and having the spool number set on the Spoolman tab, are these commands still needed? Or, does the integration automatically add the g-code? If it is not automatically added, what is the suggested approach? -- Thanks!

For now it appears like this in the gcode's metadata :
image(In my case 2 spools used no 85 and 76)

It will also prompt you something like this to allow you "pre-consume" the estimated amount in the spoolman db when starrting the print (or exporting gcode) from Orca.
image

You can also use the set value inside your custom start end gcode (for instance in the filament start end gcodes)
image

This could be be useful if you want to implement the spool changing logic yourself via macros or something else. Concerning moonraker plugins or even Happy Hare, chances are that they will (in the future) preprocess the gcode file's metadata to discover the spoolIDs (or filament IDs) in order to automap and use their own automated spool switching logic.

@SoftFever SoftFever added the Community testers wanted Looking for community testers and feedback label Feb 22, 2025
@Ocraftyone
Copy link
Contributor Author

@AlexTheGreat1971

  1. For sake of maintaining the overall design style, I would change the color of the buttons to greenish.

I had noticed this too while developing. I intentionally left it alone since there were other buttons that also had this issue. I figured that this could be resolved in a different PR that standardizes the buttons.

  1. When importing a filament from Spoonman DB into an existing filament in Orca, I would like not to duplicate it, but to fill in the Spoolman tab of this filament.

If you have an existing profile that you want to specify the spool ID for, you would just update the spool ID. If you then want to set the filament settings from Spoolman into the filament profile, you can press "Update Filament".

@CooperGerman
I believe your issues come down to me not validating input correctly. The hard crash was because I was not expecting any other colons in the string, which the "http://" prefix has. This led to no regex match and a crash while trying to get the data from the failed match. The issue with "spoolman-serv" is due to me only expecting alpha-numeric values, not '-', so it was passing "serv:7912", which was invalid. "spoolman-serv" worked because without a colon in the string, the separation of : doesn't happen. This should be solved in the latest commit.

@Ken6432

I had to add the command "SET_ACTIVE_SPOOL ID=xx" in the start G-Code and "CLEAR_ACTIVE_SPOOL" in the end G-Code. When using this integration and having the spool number set on the Spoolman tab, are these commands still needed?

This is something I will add as an option to the Spoolman config dialog

As for Happy Hare: with the amount of people who are interested, I will be at the very least be including some basic compatibility features. I am not at all familiar with MMUs (I don't personally own one), so I will be relying on the community for testing and suggestions. I have read the basic documentation provided by @igiannakas (Thank you BTW) and basic implementation seems easy enough with the ability to expand later to a dedicated MMU dialog.

Continuing with Happy Hare
@CooperGerman

This leads me to think about the current implementation. Your version is based around assigning an Orca Filament a spoolid, and thus is limited to the specified spoolid i would guess ? Could it be possible to assign the filament id rather that the spoolid in order for Happy Hare to automap according to it ? This would also enable the reuse of the gcode, enable the "endless spool" feature from Happy Hare and could be "easier" to use for people with many instances of the same filament.

I have been using the spool id rather than filament ID because that is what is needed to 'use' the specified filament. I guess in theory as long as there is only 1 spool per filament, it could work, but adding any more spools would get hairy. I figured it would be easy enough to change the spool ID to a new one when it ran out. The filament ID is still available behind the scenes, so it would be possible to add that data somewhere in the gcode for Happy Hare to read. The only current caveat to that solution is that Orca would have to connect to spoolman before the filament ID would become available. The only thing I store locally in the config is the spool_id. If you, @igiannakas, or anyone else would like to discuss it more, you can absolutely reach out on discord. There is currently a spoolman discussion open under orca-dev-forum on the OrcaSlicer server, or we can open a different Happy Hare specific one.

@Kareem1211
Copy link

I'm very excited to try this great feature, how can I test it?

@Ocraftyone
Copy link
Contributor Author

I'm very excited to try this great feature, how can I test it?

#4771 (comment)

I will update this comment with a link to the latest files. Just click the link and get the correct file for your OS.

@AlexTheGreat1971
Copy link

AlexTheGreat1971 commented Feb 23, 2025

I would like to be able to synchronize Orca with Spoolman server across all Orca's filaments and use synchronization data even if there is no connection with the server. Now, when changing the filament and trying to slice, you constantly get a warning from Orca that there is not enough filament and you have to go into the properties of the filament and update its data from Spoolman server.

@cdedwards
Copy link

This will be great when it's working as expected along with Happy-Hare and Mainsail integration. I do have a problem though with the spoolman filament dialog. There is no way to increase the size of the window that's created by Orca to display Spoolman filament. leaving me with a very thin window with some scroll bars along side and bottom.

image

@Ocraftyone
Copy link
Contributor Author

This will be great when it's working as expected along with Happy-Hare and Mainsail integration. I do have a problem though with the spoolman filament dialog. There is no way to increase the size of the window that's created by Orca to display Spoolman filament. leaving me with a very thin window with some scroll bars along side and bottom.

image

I have noticed this while testing in WSL. I was hoping it was just some weirdness surrounding how WSL renders apps, but apparently not. I'll add this to my list of stuff to dig into 😄

@Ocraftyone
Copy link
Contributor Author

I would like to be able to synchronize Orca with Spoolman server across all filaments in Orca and use synchronization data even if there is no connection with the server. Now, when changing the filament and trying to slice, you constantly get a warning from Orca that there is not enough filament and you have to go into the properties of the filament and update its data from Spoolman server.

I am not entirely sure what you are asking for, but I think you are asking to have the filament consumption details persist between instances of Orca.

If the spoolman server is unreachable/not available, you should not get any notifications unless you are attempting to open the import dialog. This may break apart if you start with access to the spoolman server, then it becomes unavailable, but at that point you would already have the spool data cached in the orca instance and should only get an error if you are trying to import a spool or consume a spool. I have no intention of caching the data beyond the life of an instance of OrcaSlicer because I believe that negates the point. I think no data is better than stale data.

If that is not what you were asking or you still have questions, please let me know 😄

@Zimbo111
Copy link

Is there already a way to select the filaments inserted in spoolman directly in orca?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community testers wanted Looking for community testers and feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spoolman intergration - Request Filaments IDs