Jump to content
Ultimaker Community of 3D Printing Experts
taconite

If statement in Postprocessing, Layer height

Recommended Posts

Good evening fellow 3D-printing enthusiasts,

 

I am new to this forum and have a problem - I couldn't find a topic with the search function. I have no idea if this is the correct forum for my inquiry - maybe a moderator could help me out.

I would like to add some code to the g-code with postprocessing. I would like to add different code dependent on the layer height like:

 

if(layer height==0.3)

{

// some g-code

}

elseif(layer height == 0.1)

{

// some other g-code

}

else

{

// default g-code

}

 

is this possible with the post-processing plug-in (I will use the search and replace function)?

what is the variable for the layer height? layer_height ... ?

 

I am using Cura 3.4

 

Thank you for your help

 

Best Regards

 

 

Share this post


Link to post
Share on other sites

Read about post processing plugins.  There are bout 6 of them that come with cura.  Look at the code in them.  They use python.  Python is a general purpose language so you can do anything in a post processing script that you can do in any language.

 

Maybe start by looking at the names of the scripts (go to extensions, post-processing, modify g-code, then click add-a-script.  Try to find the python files that go with those script names using grep.  They'll be in the same folder tree structure as cura.

Share this post


Link to post
Share on other sites

What do you mean by "variable"? A python variable? There is not global python variable for the layer height in Cura.

 

There is a setting called "layer_height". To get its value, you would call the method getPropertyValue on the "global stack".

 

global_stack = Application.getInstance().getGlobalContainerStack()
layer_height = global_stack.getProperty("layer_height", "value")

 

  • Like 1

Share this post


Link to post
Share on other sites
16 hours ago, ahoeben said:

What do you mean by "variable"? A python variable? There is not global python variable for the layer height in Cura.

 

There is a setting called "layer_height". To get its value, you would call the method getPropertyValue on the "global stack".

 


global_stack = Application.getInstance().getGlobalContainerStack()
layer_height = global_stack.getProperty("layer_height", "value")

 

 

 

Thanks, I could definitely use that at some point!

What would the spelling look like for "material_standby_temperature"?

Global_stack.getProperty (material_standby_temperature, value) returns only the default value of fdmprinter.def.json.

It would be best if extruders were also possible dependent!

Share this post


Link to post
Share on other sites
26 minutes ago, zerspaner_gerd said:

Global_stack.getProperty (material_standby_temperature, value) returns only the default value of fdmprinter.def.json.

 

That is because material_standby_temperature is set per extruder, so instead of the global stack you need to look at one of the extruder stacks.

 

For example, this gets the standby temperature set for the first extruder:

first_extruder_stack = ExtruderManager.getInstance().getActiveExtruderStacks()[0]
material_standby_temperature = first_extruder_stack.getProperty("material_standby_temperature", "value")

 

  • Like 1

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

×

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!