Jump to content

Cuq

Expert
  • Posts

    676
  • Joined

  • Last visited

  • Days Won

    18

Posts posted by Cuq

  1. Hello

     

    I'm certainly missing something but I d'ont know what ? I'm trying to use the same code to create a SnapShot .. I can get a file but the result is absolutly not correct. If Im using the plugin UPFWriter I got the result thumbnail.png  ( the first image) and my result is my_thumbnail.png  (the second image) ?

     

    Actual source code 

    # Copyright (c) 2020
    # The SimpleShapes plugin is released under the terms of the AGPLv3 or higher.
    
    from PyQt5.QtCore import QObject
    from PyQt5.QtCore import QBuffer
    
    from UM.Extension import Extension
    from cura.CuraApplication import CuraApplication
    from cura.Snapshot import Snapshot
    from cura.Utils.Threading import call_on_qt_thread
    
    from UM.Application import Application
    from UM.Logger import Logger
    from UM.Message import Message
    from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType
    
    from UM.i18n import i18nCatalog
    catalog = i18nCatalog("cura")
    
    class CreateSnapShot(Extension, QObject,):
        
        def __init__(self, parent = None) -> None:
            QObject.__init__(self, parent)
            Extension.__init__(self)
    
            # attention pas le même nom que le menu
            self.addMenuItem(catalog.i18nc("@item:inmenu", "Snap"), self.doExtendedCreateTrainingPics)
            
            self._snapshot = None
           
     
        def doExtendedCreateTrainingPics(self):
            self.doCreateTrainingdata(True)
    
        #def doExtendedWrite(self):
        #   self.write(stream)
        @call_on_qt_thread
        def doCreateTrainingdata(self, extended_mode):
            self._write()
            self._message = Message(catalog.i18nc("@info:status", "Creating .PNG pics"), title = catalog.i18nc("@title", "PNG Pics"))
            self._message.show()
            
            
        def _createSnapshot(self, *args):
            # must be called from the main thread because of OpenGL
            Logger.log("d", "Creating thumbnail image...")
            try:
                self._snapshot = Snapshot.snapshot(width = 300, height = 300)
            except Exception:
                Logger.logException("w", "Failed to create snapshot image")
                self._snapshot = None
                
        @call_on_qt_thread
        def _write(self):
    
            self._createSnapshot()
    
            #Store the thumbnail.
            if self._snapshot:
                
                thumbnail_image = self._snapshot
                thumbnail_image.save("C:/temp/thumbnail.png", "PNG")
                Logger.log("d", "Thumbnail creation")
                
            else:
                Logger.log("d", "Thumbnail not created, cannot save it")
                

     

    thumbnail.png

    my_thumbnail.png

  2. finally the right code 

            global_container_stack = CuraApplication.getInstance().getGlobalContainerStack()
            extruder = global_container_stack.extruderList[int(id_ex)]    
            # Define support_xy_distance
            extruder.setProperty("support_xy_distance", "value", self._UseOffset)

     

  3. Hello,

     

    I'm Still figting with Python , this time I'm looking for a solution to modify a parameter in a profil. The following Code doesn't return any error . But it doesn't change anything.

     

            id_ex=0
            global_container_stack = Application.getInstance().getGlobalContainerStack()
            extruder = global_container_stack.extruderList[int(id_ex)]    
    
            # Define support_xy_distance
            definition = extruder.getSettingDefinition("support_xy_distance")
            new_instance = SettingInstance(definition, extruder)
            new_instance.setProperty("value", self._UseOffset)

    Any Help would be welcome

  4. Hello,

     

    When Y use a Mesh as support , Cura Use the value set in the Profil as Support X/Y distance and not the value define for the element support.  Is there any solution to use the value set on the element ? and keep the global X/Y distance for the other support ?

    Support.JPG

  5. Ok

    I wasn't aware about, that.

    Thanks to your help the plugin is now "acceptable". So next step for me: find the solution to create a curapackage. Can you point me to a tuto or document which explain how to do that ?

     

    [Edit]  your solution in test https://community.ultimaker.com/topic/26046-writing-a-custom-cura-package/?do=findComment&comment=229467

     

    and https://github.com/Ultimaker/Cura/wiki/Creating-Packages

     

    But my goal at the end is not necessary to put it on market place. Is it possible just to get the curapackage via this solution ?

  6. Ok it's a little bit more clear now, I can define this windows ..  But I still have some problems to understand how the Binding mecanism works between the windows and the main code. Can you help me on this point ?

    valid.jpg

     

    I have now a control TextField and  I can fix the value with the code :

        def getDiam(self) -> float:
            """ return: Diam  in mm.
            """
            # get diameter_custom_support as cylinder value
            id_ex=0
            extrud = Application.getInstance().getGlobalContainerStack().extruderList
            DiamCylinder = extrud[id_ex].getProperty("diameter_custom_support", "value")
            
            return DiamCylinder

    but how to get back this value form the TextField ?

  7. 29 minutes ago, ahoeben said:

    Why would you want this to be a setting though? Couldn't it just be a numeric input field in the tool panel?

     

    That's exactly what I want , using a setting is not the right solution but as I don't know how to implement such type of numeric field in the tool panel it was for me a workaround.   In the different plugins there is no sample code to integrate this type of function.  I'm just a beginner in Python coding and this type of code is too hight level for me without an existing example.

  8. So my question is now where can I find a "basic sample code" or how to implement in this plugin a windows to define specific parameters to define the size of this cylinder ? Hereafter a sample view of the expected function to clarify my request.

    modif.JPG

  9. temporary solution : using the value of support_tower_diameter  (Support as Tower diameter) as Cylinder diameter:

            # get support_tower_diameter as cylinder value
            id_ex=0
            extrud = Application.getInstance().getGlobalContainerStack().extruderList
            DiamCylinder = extrud[id_ex].getProperty("support_tower_diameter", "value")

     

  10. Hello,

     

    I'm working on a plugin based on the CustomSupport plugin. But in this case I'm not creating a cube but a cylinder.  I haven't any problem to get the right length ( from the picked point to the base) but I wanted to define the radius as a parameter in order to be able to customize this value.  Is it possible to add a customized value ? or to get an existing value for this parameter Ie : support_conical_min_width ?

    CustomSupporCylinder.thumb.jpg.3455b705237de168be09304daa44d200.jpg

    Cylinder.zip

    • Like 1
  11. Bon c'est pas le sujet mais Support arborescent pour ce genre de pièce et de cas de figure, normalement c'est quand même le top . Et en plus c'est quand même là où Cura fait la différence avec d'autres Slicers

  12. Oui par contre un truc marrant .. en regardant mon image je viens de voir que Cura Indique premier layer = 425  alors que c'est bien le premier .. pour lui il a bien slicé 425 layer vide en partant du plateau sauf qu'il les a supprimés. Du coup c'est plutôt pas mal ca permet de voir si t'es raccord entre le Print de tes pièces précédentes et celles que tu vas relancer. C'est plutôt un bon point même si finalement ça serait mieux que Cura puisse nous permettre de slicer avec des hauteurs différentes en utilisant la fonction de modélisation des paramètres de chevauchement. 

    • Like 1
×
×
  • Create New...