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):
        super().__init__()
        self._application = Application.getInstance()
        self._i18n_catalog = None
        self._application.getOutputDeviceManager().writeStarted.connect(self._filterGcode)

    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")
            return

        # 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??

TestPlugin.zip

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:

    [general]
    version = 5
    name = Idebroken 25_staiger
    id = Idebroken 25_staiger
    
    [metadata]
    setting_version = 20
    type = machine
    group_id = 8df622d3-210a-459d-a213-265b216eeef4
    
    [containers]
    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

      • 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
        • 26 replies
      • S-Line Firmware 8.3.0 was released Nov. 20th on the "Latest" firmware branch.
        (Sorry, was out of office when this released)

        This update is for...
        All UltiMaker S series  
        New features
         
        Temperature status. During print preparation, the temperatures of the print cores and build plate will be shown on the display. This gives a better indication of the progress and remaining wait time. Save log files in paused state. It is now possible to save the printer's log files to USB if the currently active print job is paused. Previously, the Dump logs to USB option was only enabled if the printer was in idle state. Confirm print removal via Digital Factory. If the printer is connected to the Digital Factory, it is now possible to confirm the removal of a previous print job via the Digital Factory interface. This is useful in situations where the build plate is clear, but the operator forgot to select Confirm removal on the printer’s display. Visit this page for more information about this feature.
          • Like
        • 0 replies
    ×
    ×
    • Create New...