Jump to content

How to correctly get the `line_width` value in custom plugin?

Go to solution Solved by Cuq,

Recommended Posts

Posted (edited) · How to correctly get the `line_width` value in custom plugin?

I am trying to use the value of `line_width` in my custom post-processor script, however, the value always returns 0.4, even if I change it to something else in the GUI.

I even tried a clean install with only one printer with everything set to something else than 0.4, however, I still get this value when querying line_width.


I use the following code (also attached as plugin):

from collections import OrderedDict

from UM.Extension import Extension
from UM.Application import Application
from UM.Settings.SettingDefinition import SettingDefinition
from UM.Settings.InstanceContainer import InstanceContainer
from UM.Settings.DefinitionContainer import DefinitionContainer
from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.Logger import Logger

class TestPlugin(Extension):
    def log(self, level, message):
        Logger.log(level, f"TEST: {message}")

    def __init__(self):
        self._application = Application.getInstance()
        self._i18n_catalog = None

    def _filterGcode(self, output_device):
        scene = self._application.getController().getScene()

        self.log('d', "trying the global container")
        global_container_stack = self._application.getGlobalContainerStack()
        if not global_container_stack:
            self.log('d', "no global container stack found")

        # get setting from Cura
        layer_height = global_container_stack.getProperty("layer_height", "value")
        self.log('d', f"Layer height: {layer_height}")


I suspect that I somehow the line_width in the global container stack has other values as well, however, I have very little idea of how the container structure is build up. Should I be using a different container? What am I doing wrong? And if somebody could explain to me, what is even a container??


Edited by andries_coastruction
  • Link to post
    Share on other sites

    Posted · How to correctly get the `line_width` value in custom plugin?

    Also when I try to query the machine name of my Custom FFF printer, i returns `Unknown`, even though it clearly has a name:


            machine_name = global_container_stack.getProperty("machine_name", "value")
            self.log('d', f"machine_name: {machine_name}")

    prints:  `machine_name: Unknown.`


    with the machine config looking like this:

    version = 5
    name = Idebroken 25_staiger
    id = Idebroken 25_staiger
    setting_version = 20
    type = machine
    group_id = 8df622d3-210a-459d-a213-265b216eeef4
    0 = Idebroken 25_staiger_user
    1 = custom_waterprofile_t2.5_#2
    2 = empty_intent
    3 = empty_quality
    4 = empty_material
    5 = empty_variant
    6 = Idebroken 25_staiger_settings
    7 = custom


  • Link to post
    Share on other sites

    • 2 weeks later...
    Posted · How to correctly get the `line_width` value in custom plugin?

    Line_Width is not a Global parameter but it is linked with the Extruder Container.  ( Each Extruder can have a different line Width )


    extrud = Application.getInstance().getGlobalContainerStack().extruderList
    GetVal = extrud[id_ex].getProperty(key, "value")


    Where id_ex is the number of the extruder if you have just one extruder id_ex = 0

  • Link to post
    Share on other sites

    Posted · How to correctly get the `line_width` value in custom plugin?

    Your Welcome , And If you want to have more information / Plugin example you can have a look to the Profil Analyse plugin  https://marketplace.ultimaker.com/app/cura/plugins/5axes/ProfilAnalyser


    And I'm Agree with you there is a huge gaps in knowledge and on documentation for Plugin creation.  

  • Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Our picks

      • Introducing the UltiMaker Factor 4
        We are happy to announce the next evolution in the UltiMaker 3D printer lineup: the UltiMaker Factor 4 industrial-grade 3D printer, designed to take manufacturing to new levels of efficiency and reliability. Factor 4 is an end-to-end 3D printing solution for light industrial applications
          • Thanks
          • Like
        • 3 replies
      • UltiMaker Cura 5.7 stable released
        Cura 5.7 is here and it brings a handy new workflow improvement when using Thingiverse and Cura together, as well as additional capabilities for Method series printers, and a powerful way of sharing print settings using new printer-agnostic project files! Read on to find out about all of these improvements and more. 
          • Like
        • 27 replies
    • Create New...