Jump to content
Daniel26

Plugins HowTo

Recommended Posts

Posted · Plugins HowTo

Hello,

 

is there anywhere a HowTo for writing plugins?

Which classes can be used etc. pp.

 

Regards

 

Daniel

 

Share this post


Link to post
Share on other sites
Posted (edited) · Plugins HowTo

Hmmm,

 

I try to reengineer a plugin and looking for a funktion which I can't find neither in uranium nor somwhere else in Cura:

Application.getInstance().getMainWindow().screenshotImages()

 

Can anybody help me to find it? Or the replacement in newer versions of Cura?

 

Regards

 

Edited by Daniel26

Share this post


Link to post
Share on other sites
Posted (edited) · Plugins HowTo

Ok, Nice.

What is this plugin doing?

But isn't there anywhere a howto?

When is a plugin called?

I wan't to include a preview of the model with specific g-codes to the G-Code-File.

 

Edited by Daniel26

Share this post


Link to post
Share on other sites
Posted · Plugins HowTo

That is what this plugin does. Use file -> export and select UFP as the output format. Inspect the saved file as if it were a zip file.

Share this post


Link to post
Share on other sites
Posted · Plugins HowTo

Hmm, no. It seems not to be the same. The UFP creates a bundle. I wan't the code in the gcode-file.

Butr I think it will bring me a step further.

Thanks.

 

But when will a plugin be executed? Everytime I slice a file? Or can I configure when a plugin will be executed?

Share this post


Link to post
Share on other sites
Posted (edited) · Plugins HowTo

The UFPWriter plugin is an OutputDevice plugin. Those are documented in an example here:

https://github.com/Ultimaker/UraniumExampleOutputDevicePlugin

 

Sorry, the UFPWriter is a MeshWriter plugin. There is no example plugin for that. But the UFPWriter plugin itself is fairly simple, code-wise. A MeshWriter plugin has a "write" method that you override. This method is called when you save a file in the format the MeshWriter plugin is configured for. Other types of plugins have other ways they are called. What sort of plugin you want to write really depends on what you want it to do.

 

The simplest type of plugin to start with is an Extension plugin: https://github.com/Ultimaker/UraniumExampleExtensionPlugin

Edited by ahoeben

Share this post


Link to post
Share on other sites
Posted · Plugins HowTo

I wan't  to execute the plugin everytime a gcode file is being created.

Best would be a point in the settings to activate it.

What are the qml files for?

 

I'm not totally nw to python, I'm also writing apps with pyQT in business. But I don't have any clue how to write a plugin for cura.

 

Share this post


Link to post
Share on other sites
Posted · Plugins HowTo

QML files describe the UI. They are pretty integral parts of creating UIs with Qt and conversely pyqt.

 

You could act every time a gcode file is written, sent to the printer via USB or the network like this:

class SomePlugin(Extension):
    def __init__(self):
        super().__init__()

        application = CuraApplication.getInstance()
        application.getOutputDeviceManager().writeStarted.connect(self._onWriteGcode)

    def _onWriteGcode(self, output_device):
        # do things
        pass

Alternatively, you could listen to the state of the backend:

class SomePlugin(Extension):
    def __init__(self):
        super().__init__()

        application = CuraApplication.getInstance()
        application.getBackend().backendStateChange.connect(self._onBackendStateChange)

    def _onBackendStateChange(self, state):
        if state == BackendState.Done:
            # do things
            pass

 

Share this post


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

×
×
  • Create New...

Important Information

Welcome to the Ultimaker Community of 3D printing experts. Visit the following links to read more about our Terms of Use or our Privacy Policy. Thank you!