Jump to content
Ultimaker Community of 3D Printing Experts
pm_dude

New Plugin - Swap At Height

Recommended Posts

Hello,

I'm working on a small plugin in Cura to swap gcode at a given height. The goal is to make it possible to merge gcodes with different settings like different infill.

So far I find the layer at z replace the content from that point and until the end or the given z. Recalculate layer count and layer indices, add G0 movements to travel to layer start point, recalculate E.

I haven't tried to print yet. The preview in Cura is working but the layer view doesnt display new layers (if other gcode as different layer height) and the print time is not updated.

Is there anything I'm missing? This is my first time playing with gcodes and plugins...

swap at height

 

EDIT:

Available on Youmagine

https://www.youmagine.com/designs/swap-at-z

 

Share this post


Link to post
Share on other sites

The tricky part is the E values. Nice work.

As far as I can tell, the layer view takes the outer shell directly from the slicer, but then the second pass (inner shell, infill, brim, support, etc) comes from the gcode after your plugin. This means it can show the wrong shell but the correct infill. To truly visualize the gcode it's best to "clear platform" and then "load model file" and load the gcode result.

 

Share this post


Link to post
Share on other sites

Inner shell is good. It display the good one.

The display isn't good if you change geometry between the gcodes. When the swapped section is in focus on the layer view it does display the good one but not when out of focus.

Loading the gcode on a clear platform give weird results. Thanks for the tip. It will help me figure it out.

Are you sure the feature you refer to in PU is not different settings per object?

 

Share this post


Link to post
Share on other sites

I found some issues with loading a gcode file on a clear platform more than once. This was performed with a regular gcode (it did not include swapped content)

- load gcode, display is correct

- switch to normal view

- switch back to layer view

- clear platform

- load gcode. The second gcode doesnt display the same content.

* If you dont switch to normal view the second gcode is correct.

** output log display an error about a division by zero. Could be related (or not).

 


Traceback (most recent call last):
File "Cura\gui\sceneView.py", line 553, in _onRunEngine
self._engine.runEngine(self._scene)
File "Cura\util\sliceEngine.py", line 295, in runEngine
for k, v in self._engineSettings(extruderCount).iteritems():
File "Cura\util\sliceEngine.py", line 498, in _engineSettings
settings['fanFullOnLayerNr'] = (fanFullHeight - settings['initialLayerThickness'] - 1) / settings['layerThickness'] + 1
ZeroDivisionError: integer division or modulo by zero

Also when loading a gcode the layers are placed properly but the camera height is still dependent on layer height setting. It doesnt follow the Z value of the displayed layer.

 

Share this post


Link to post
Share on other sites

 

Swapping is advancing nicely.

- Swap start and end are working properly.

- Material usage is updated but doesn't show in Cura.

- I dont know how to recalculate the time (other plugins dont seems to do it)

- Works for different layer heights

layer thickness

 

- Seems to works with all settings so far (speed, shell, infill, ...).

swap settings

 

- Stacking multiple swap plugins works to. You could transition you infill settings from 10% to 20% to 30%.

 

*I have not tested any other gcode flavor or dual material. I have not tested every single settings.

 

Test print

IMG 20140909 234452

 

You can test it yourself here (download SwapAtZ.py)

https://github.com/pmsimard/Cura/tree/SteamEngine/plugins

 

Share this post


Link to post
Share on other sites

I think Daid would normally fix this but I think he is working on PU instead. I'm pretty sure PU will let you switch by height as well as by object.

 

Yeah these are pretty minor and I prefer investing Daid's time on PU too :D. Hopefully PU will do. If not it will eventually

 

Share this post


Link to post
Share on other sites

-Go on GitHub (link above)

-Right click on SwapAtZ.py and select save link as ...

-Save the .py file in your currently installed Cura (..\Cura_14.07\plugins\) folder.

-Start Cura

-Plugin should show up.

-Make sure to check the layer view.

Be warned that this is still a very early version.

 

Share this post


Link to post
Share on other sites

@pm_dude: Hope you don't mind me making suggestions for improvements. On the Dutch forum section there is interest to use this plugin to change layer height mid print. I foresee some problems when at the switch height both or one gcode files doesn't have a layer at that height. Like printing a 0.3mm layer only 0.1mm above the previous layer resulting in over extrusion. So I want to try to build in some warning when there is a mismatch of layer height. when switching.

 

Share this post


Link to post
Share on other sites

Yes there is a risk for that and for the opposite case too. I dont mind suggestions :).

There are needs for improvements such as:

- Using the travel speed instead of the print speed when moving toward the end point of the previous layer.

- Currently it travel but dont trigger retraction.

- Layer gap/compression could be added too. (your point)

- I have not tested with the "Z hop when retracting" option

- I still dont support dual extrusion or non UltiGCode flavor.

- Calculating proper time estimate.

- Need support for print one at the time mode.

 

Share this post


Link to post
Share on other sites

@gr5 Do you think I can simply multiply the E value to compensate a potential over extrusion?

If the next layer is planned for a thickness of 0.3mm but there is space for 0.2mm I could scale E by 2/3 and reduce the extrusion. Could that also cause spacing between the lines?

 

Share this post


Link to post
Share on other sites
@gr5 Do you think I can simply multiply the E value to compensate a potential over extrusion?

 

Yes. But it's complicated by the fact that E values are sums/totals for "the entire print so far".

I was wondering how you handle switching to the other print with different E starting value. Do you adjust all the new values? Or do you use the G92 command (reset position)?

For example lets say you cut off the first print at E1000 (1000 cubic mm of filament used so far) and the layer to start next happens to start at E2000. You can either do a G92 E2000 to reset the position or you can subtract 1000 from all the future E values.

Now with your multiplier - lets call it 1.5. If the next line goes to E2001 you don't want to multiply by 1.5 to get E3001.5 - you want to go to E2001.5

So you are multiplying the deltas by your multiplier. Not the absolute values.

Alternatively you can multiply all the new E values by the multiplier but do a G92 3000 just before this.

Too many choices!

 

Share this post


Link to post
Share on other sites

I calculate the delta between the last E value and the E value of the other gcode and update all the E values that will be inserted. It should be easy to do it also with multiplying the delta of E and offsetting everything afterward.

what is G92 code? I really need to read more about the codes. I think the Marlin github has a list of the implemented codes.

 

Share this post


Link to post
Share on other sites

Hello,

I submitter a new version on git:

https://github.com/pmsimard/Cura/blob/SteamEngine/plugins/swapAtZ.py

Update on the previous list:

- Using the travel speed instead of the print speed when moving toward the end point of the previous layer. No G0 travel needed.

- Currently it travel but dont trigger retraction.

- Layer gap/compression could be added too. (your point)

- I have not tested with the "Z hop when retracting" option

- I still dont support dual extrusion or non UltiGCode flavor.

- Calculating proper time estimate.

- Need support for print one at the time mode.

 

Additionally:

- I rewrote most of it to make it simpler to read and to support more features.

- More log but in output.txt

- Adding ;SwapAtZ in resulting gcode to easily locate the swap

 

Thanks Dirkels for testing and your inputs :)

 

Share this post


Link to post
Share on other sites

I have updated the SwapAtZ plugin in github. It now include some changes provided by Dirkels and better support layer height differences.

If you test with a different gcode flavor please let me know if you find anything suspicious.

Always check the result by loading the saved gcode in Cura.

 

Share this post


Link to post
Share on other sites

the delta of E and offsetting everything afterward.

 

You should stick with G92. The problem is Marlin runs on a wimpy computer that can't handle E values larger than a few thousand so every 9999 (not sure the exact roll over number) or so Marlin resets E back to zero (and adds a G92). If you modify the remaining E values with an offset you will be requesting negative E values.

So you either need to detect G92 values that already exist in the code and modify your offsets when found. Or you should do your own G92 value when swapping.

 

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

  • Our picks

    • How to 3D print with reinforced engineering materials
      Ultimaker is hosting a webinar where we explain how you can achieve and maintain a high print success rate using these new reinforced engineering materials. Learn from Ultimaker's Product Manager of Materials and top chemical engineer Bart van As how you can take your 3D printing to that next level.
      • 2 replies
    • "Back To The Future" using Generative Design & Investment Casting
      Designing for light-weight parts is becoming more important, and I’m a firm believer in the need to produce lighter weight, less over-engineered parts for the future. This is for sustainability reasons because we need to be using less raw materials and, in things like transportation, it impacts the energy usage of the product during it’s service life.
        • Like
      • 12 replies
×

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!