Generate wood patterns with temperature changes

by MoonCactus Feb 11, 2013
Download All Files

Please Login to Comment

The web application is giving me a file is too large for a relatively small file. Not sure what is up to be honest.

The server will not accept a really large file indeed, how big is yours? (I updated the server not long ago and may be Ireduced the allowed upload size -- but I see processed files as big as 10MB?)
You may have to reduce the uploaded file complexity in the first place, or to use the standalone python script on your own computer instead, which would have no limit.

Mostly depending on the layer size, the returned file may grow much larger. Technically, the script inserts a temperature change for each Z change in the input data. But when printing wood-laden filament, I recommend thick layers and large nozzles anyway, so if the file is "too" big you may increase the layer height a bit according t your nozzle.

The file that I tested out to see if I could get the application to work was only 4.8mb, then I tried a smaller file at 4.2mb and that one also errors out.

I just increased the allowed upload size to about 20MB and tested a 10MB file, seems OK on my side.
You may try it again now, thanks for the feedback :)

Thank you! That worked like a charm and was able to process all the files I needed. Really appreciate it

Thanks for letting me know :)

Can someone help me get started. I have no idea what I am doing here. The only python I know is a few commands for RPI. I am not sure where I have to put the file, or really how to use this. I have read through all the links associated with the script but do not understand any of it. Where and how do I start?

I was in the same place as you when I first tried this. Here is what I did.

  • Open the windows command prompt. If you search for cmd, it will pop up.
  • Drag the python file into the command prompt
  • Type -f and drag in the gcode file you want to modify
  • Type -i and enter the initial temp you want
  • -a maxtemp
  • -g grainsize you want. I used the default 3.0
  • Hit enter. The script will process. When finished, the command prompt will reset to the state it was in when you first started.
  • The original gcode you entered has now been modified.
  • Note; the commands should be entered as -i with a single space before the value you want to use.

Happy printing!

Thanks for helping @nd1985 :)
Actually -i is a shortcut for --min
It is the smallest temperature that the script is allowed to set, not really the "initial" temperature.
I updated the dc with your input!

Awesome! Just what I was looking for.. I will give that a try! Thanks!
One last question. Do you know how to Fix the grain style so it isn't random? I want to print 2 pieces the same..

@SquirrelEngineering you probably want to make use of the optional parameter named --random-seed <integer> (see new doc above).
E.g. add --random-seed 1 to each of your runs, and you should get the same pattern!

I am using the stand alone python script to print the secret butterfly box on a prusa mk3. I have been able to get it work on some of the smaller pieces. When I attempt to print the larger pieces of the box, I invariably get a pre-heat error and the print fails.

Any ideas why this might be the case?

The picture is of a stained front tile piece. I am very happy with the results. Just unsure why I can't get it to work with the larger pieces.
Thanks for any help.

You might also have a look at the produced g-code, and/or tweak a few values, add some delay before starting the print etc. I am curious to see what the issue might be if it cannot be fixed by maxUpward (and possibly maxDownward)

Some machines implement thermal runaway safeties that may be triggered when the temperature changes too fast.
E.g. they might consider the thermocouple/thermistor is broken and they stop the print to avoid risks of fire. This is a bit zealous if they do not consider the g-code commands in the first place, but that is another story. If this is the case you might want to use the first of the following parameters that were added specifically to stay within the range of acceptable changes. Sadly, it will reduce the chance to have very sharp transitions.

        graphStr += ", temperature increases capped at " + str(maxUpward)
        graphStr += ", temperature decreases capped at " + str(maxDownward)

BTW: pretty cool part of yours! It is one of the best prints I ever saw :)
What's the filament in the first place? Did you post-process it, as it looks like varnished?
...and would you mind if I add it to the pictures for this thing (with attribution as usual)?

A question:
what would the commands look like when I enter them in the prompt? I have been using -i (value), -a (value), etc.
I know very little about programming but your script has given me a chance to learn.

As to the part, it is tianse wood filament. I am using a combination of variable layer height in slic3r pe and your script to get the wood grain effect. I sanded the parts before staining. I applied 3 coats of stain waiting 24 hours and sanding in between. I wanted to make something that my Grandma would be proud to display haha. When people ask what you can make with a 3d printer, a lot of it is kitschy pop culture stuff. That is great, but I wanted to make something that could stand on it's own as an object.

I will post pics when all is said and done. You may use them for anything you like. I love the open nature of the community and want to contribute in anyway I can.

Thanks for any and all help!

I set -u and -d to 5 and still had print failures.

Here are all the parts I have been able to print successfully. The final coat of clear had just been applied when I took the photos.

I am really hoping I can figure out a way to get the larger pieces to print. I think the final piece will be quite nice.

Someone on the prusa forum mentioned adding the following gcode to avoid a false thermal runaway situation:

M109 S210 ; Set target temperature for nozzle and wait for nozzle to reach target

Is there anyway this could be added to the script?

I just added the -w special option to the source on on github!
You can now specify the g-code temperature command to use, like, e.g.:

python ../wood.py -w M109 --file mytest.gcode

Default is to use former asynchronous M104 that does not block/wait for the hot end temperature to setlle down (it gives much faster prints).

Just an update;

A member of the prusa forum posted a version of the script that may have fixed the issue. I will try it out tomorrow and let you know how it goes.

Comments deleted.

I believe this may need to be changed to a script for Cura 3.6. The file location is now under Ultimaker Cura 3.6>Plugins>PostProcessingScripts>Scripts. There is a "Change at Z" script, which is not a plugin as the info here seems to suggest (for an older version).

Actually, I would have had to "fix" the script with almost every new release of Cura... what a pity!
I have waited years for them to settle their own interface down once for all after they broke their initial support.
See right now again, "fixing" it for the official Cura 3.6 would not make it work with the soon-to-be-released Cura 4.0, damn.

Comments deleted.

Has anyone tried this with Cura 3.5.1? The plugin is not showing.

I'm getting underextrusion on top layers when using a .6mm nozzle. Do you have any experience with that, or know a fix?

S3D didn't pick it up at all, but Cura shows the extruder paths for the top and bottom being way too sparse. https://cdn.discordapp.com/attachments/320763547560706048/478783206687113226/unknown.png

I tried the website mode but the printing stays on only one temperature (1rst try on 209 °C, 2nd try on 240 °C). Please, any suggestion?

I'd really like to try it out, but the Cura-Plugin doesn't seem to work, like it's supposed to.

Looks fine in Cura, but when I actually start the print, the printer doesn't preheat at all and won't move the nozzle to the bed.
Just trying to print in midair with a nozzle that's nowhere as hot, as it should be.

Plugin: directly from github - 25.03.2018
Software: Cura 15.04.6
Printer: Ultimaker 2 - Tinkergnome Firmware (Marlin Fork)

Is there a way to make this work with Cura 3.1.0?

I guess MoonCactus killed the webpage supporting the script.

It got axed as a collateral damage when I eventually updated my main site a few days ago, but it is back now :)

Comments deleted.

IMHO you checked all the obvious possible cause. Black filament often have "special" thermodynamic properties, mostly due to the carbon particles that drive heat faster (they melt easier in the heating conduit, upwards -- some like CFPLA really need to be printed fast enough to avoid clogging the nozzle). Now, white should be white. If ever you get some darker bands into your prints, either you are carbonizing it (temp is waay too high!), or your nozzle is dirty and it drags former black filament remains into the print (more likely, but this cannot really last forever!). Try to lower your temperature as much as possible with your white filament?

Comments deleted.

Hi, i tried it with the Webapp. But i don´t get the rough surface like you in the pictures.
I only get a little bit darker filament.

My temperatures are between 200 and 228 °C

Some like it, some prefer a dense, "well printed" result ;)
Actually, if you use lower temperatures (as I did here IIRC), you will start to experience under-extrusions, which will leave gaps in the printed model. A large nozzle makes it also rougher.
All in all it boils down to a mix of the filament properties and the mechanical properties of your driver, but the main parameter is the temperature. Going low is less risky than going too high (carbonized material is no good in the nozzle).

Ah ok, i will experiment a little bit.

Hi. I have used to Cura 2.5 and unfontunatelly and even I putting de wood.py in plugin folder I can`t see it in my Cura. Did u already test it in Cura 2.5...tks in advanced...
BTW: Great job...

Hi there. I just updated the python script from github, the file included here was obsolete.
By the way, I use the older Cura 16.04, could you tell me if it works fine with 2.5 ? :)

It is broken, they changed how the plugins function. I can help rewrite it once I get some free time

Thanks for letting me know. Actually I no more feel very comfortable with Ultimaker business strategy (and internal echoes... http://www.tridimake.com/2017/03/ultimaker-patents-and-PR-bullshit.html). Anyhow, I just do not understand why they shot themselves in the foot by ditching/not supporting third party plugins the way they did before. It does not make sense :/

Iv been trying to get this working for the last couple hours on cura 2.5 using the latest file from github with no luck. It does not show up in the plugin list and I do not see any sort of check box for it anywhere in print settings. Looks super though so I might give the site version a try.

unfontunatelly the same problem. =/

Comments deleted.

I can't seem to get the .py file to work with Cura. But I did try the web based tool at https://www.tecrd.com/page/liens/stl_wood and I am impressed with the results.

I have fixed the issue. Cura ignored the file because of missing spaces in the leading comments of the file (!).
You can download it again from github and it should work fine in Cura (tested with 15.04.6 on linux).

I have noticed that the web version introduces weak layers where the print tends to break. Seems to happen when a dark hot layer goes down over a colder lighter layer. I played with the settings but the weak layers come back each time.

Both should give the same results, but I think it probably depends on the material you are printing with.
The only really safe way is to increase the minimum temperature, which is a problem if you want to have also very light bands (as it means barely melting the polymer of the filament... which results in under-extrusions, and possibly poorly merged layers).
Or just cheat: spray or paint a coating or lacquer to the part once it is printed, so it glues it altogether ;)

I tried the standalone version, but always get a syntax error (on windows and mac).

At windows I installed python 2.7. I opened cmd.exe and wrote:
"python wood.py -i 190 -a 230 -g 3.0 -f cube.gcode"
also tried "python wood.py -f cube.gcode"

This gives me:
File "", line1
invalid syntax.

The gcode file is in the same folder as wood.py.
I get the same error at windows and mac.

What am I doing wrong?

Should work from cmd.exe, but could this be the problem? http://stackoverflow.com/questions/13961140/syntax-error-when-using-command-line-in-python
Either run "python wood.py -f cube.gcode" from a generic shell console (e.g. Win32 on windows), or type only "wood.py -f cube.gcode" if you are already in the Python console? There are also additional suggestions regarding versions and environment variables for these OSes.

A couple of questions: I tried your script but a previous version, it works, almost, the only problem is that for some reason there was no way to pass teh max and min temperatures in a comand line. To solve that I just edited the code with that values.
I see that there is a new version of the script. The beaty is that beinga python script, it can be used in other slicers, like slic3r. In my case I use windows and a face teh same problem: windows doesnt allow you to use the same file in 2 different processes. In perl scripts I solve this useing "$^I = '.bak';" and a second file is generated by the script and problem solved, what would be the line to add in this python script to do that and where shuld be added?
Thanks ina dvance

Hi there. Ouch, that was more or less my first try on the language even though I am a seasoned programmer on others (and less proficient that you in perl, I did not know the trick -- but I have no such problems, being on linux for the last 15 years...).

I am not sure that I understand why it fails. I am skeptical that there is no way to read-then-write (not append!) a file from within the same python script, especially given that I originally based my script on another plugin from the (now underground!?!) regular Cura plugins. In any case, you may either try to:

  • add a "seek(0)" on the line that follows the "fout= open(filename, "w")" line (should have no impact as I write in "w" mode, not "a" or "a+" as figured on http://stackoverflow.com/questions/14271216/beginner-python-reading-and-writing-to-the-same-file). Please tell me if it fixes your problem, so I can include it in the script.
  • or "fout= open(filename+"_fix.gcode", "w")" for example, since it would change the filename to write to. This would break integration with Cura plugins and probably other slicers, as they expect the same gcode filename on output :/

BTW is the min/max stall an issue with the last script?

http://wiki.ultimaker.com/CuraPlugin:_Wood is not working anymore, the amas the rest of cura plugins, does anybody knows whre to get all those plugins for cura?

Nope, years ago they abandoned this wiki and switched to another one, scrapping the plugins in the same time. Then they kept on saying they will be available again one day since. Frankly, this is disappointing :/ You will have to find them via google, but I am not sure any place has them all!

So glad you posted this - very cool. Thanks!

Works amazingly well within Fedora 22 with FormF coconut filament ;).
Now a question : what's the diff between wood31 & wood32.py ?

hi there! Glad to know. Check the details:

wood31 Fixed obsolete syntax that made Python3 fail (thanks @Mysli)
wood32 is for Python3, should work also on Python2 but untested by me!

You may try the latest one by principle (wood32 then), else just use any that works without trouble for you they are doing basically the exact same job for two flavors of Python.

Comments deleted.

in the web application after uploading my gcode, nothing happens :/

hi...could someone please tell me how to install the plugin in cura? :?

sorry huge delay... I think it boils down to moving the file to a specific folder of Cura. Cura website does not seem to tell chich one (amazing!) but just look with your file manager for one which is already in your default package (e.g. TweakAtZ.py, or by directory name "plugins"), you will just have to copy/paste the file there and start cura again I think

Strange, the website doesn't generate proper g-code for my printer (Flashforge creator x pro) - getting all kinds of errors when I try to print

Did you get it working finally? I am left in the dark without more contextual information (eg. the errors in question!)... Did you check the comments below? It may be due to firmware protections or some other reasons, I cannot help much here.

Hello! Sadly no, I cannot get it working

I believe this is because my flashforge uses sailfish firmware. I believe I need to compile the gcode for a reprap style printer in slic3r first, then run through he website, and then use a GPX converter to convert the code to use with my sailfish firmware. The error messages pop up when I try to print and RepG checks the code for errors.

I tried to install Cura with the GPX converter to try using the cura plugin to add wood grain later, but I can't get THAT working either. It's to the point where I'm about to give up and simply inject the temp commands into the code by hand

May be you can send me a (short!) gcode file from your sailfish version and I will have a look at it. I suspect it is ot very hard to fix in the script! jeremie dot francois on gmail

Ah, huh X3G indeed (aka makerbot-only format)... I remember posting a link to someone here posting a solution (which, indeed, required conversion from/to X3G and regular gcode). It worked on a MK so I guess it should work on the Flashforge (a copycat, right?). Sorry, no support for "weird" gcode. Check my post here http://www.tridimake.com/2013/11/a-rant-open-or-closed-you-get-what-you.html

I have a Question in general about Laywood is it possible to print it with a 0.3mm Nozzle ?

I tried it for a very few parts. It worked for me but many people complains about jams with 0.4 mm already (I never experiences jams with mine though). So be prepared for some annoying cleanup. Also, it is not really worth in my opinion, because the filament really welds to itself smoothly (excellet properties that regular filament do not have), so a bigger nozzle is usually enough imo

Yea! Tanks a lot! I have already printed with it now but I used a 0.5mm Nozzle and it works just fine and the results are great!

Glad it worked fine :) This material is really outstanding for art and good-looking prints compared to regular plastics!

Just tried this script on my mac OS10.9. It ran and processed my gcode file but only Z10! the M104 commands were in the gcode but only up to Z10. help? its a Kisslicer gcode file.

If it stopped printing at some height, it could be the firmware protection that halts when it sees an increase of +10 degrees C (then use the proper argument).
Now as you say, if the M104 disappear after Z10 from the gcode I have no clue... may be hopping makes it fail (though it should handle it)! Could you upload the gcode file somehwere so I see better?

What I mean is the temperature changes that the script inserts into the gcode only appear up to Z10. after Z10 there are no more script created temperature changes. I can email you the gcode if you send me your email address if there is a private message ability on here. if not... let me know and maybe dropbox or something

Awfully sorry for the late reply (TV mailing is not great to say the least...).
This is very weird indeed. Yes, feel free to send me your file, using jeremie period francois on gmail, I would like to give it a try myself and know what may be going on! Cheers

MoonCactus, awesome idea :D But i cant get this straight... here you link to your site and your site links back here for the standalone python script :S
And the ones i found got me a syntax error in the "print usage" line.

So could you please simplify this in any way, it would be greatly appreciated :D

The http://wod3.pywod3.py is the latest one, and (probably) the same as my website. Cura holds the latest also as a convenient GUI plugin, My website limits the file size to something barely usable in fact.

Otherwise, in a console, the error message you get about the "usage" probably means that you forgot to specify the arguments or have a bad value. You need to run this script through python in a console... and give it at least one gcode file prefixed with "-f" or "--file".

For example here is how you may run it

python http://wood3.pywood3.py --file myobject.gcode

Check the printed indications when you run the script without any parameters for more options!

Hope it helps!

c:\>python http://wood3.pywood3.py --file lower.gcode

Gives me the following:
File "http://wood3.pywood3.py" line 39
print "usage:"
SyntaxError: invalid syntax

This was executed through cmd.exe windows 7 x64 with python 3.3.3 for windows 7 x64

I have never used python for anything before so im pretty lost here :( it such a shame as i have a lamp shade i have to print for my girlfriend :D

I can't see why it fails... There should be a "tab" caracter before the "print" (Python syntax), but they may get corrupted when you download the file: quite common since windows always thinks that it helps you while it screws the file!
I added "wood3_windows.zip" to make it safer (all as windows like it, and not a text file to be corrupted when downloaded. Tell me!

I just downloaded your zip file and extracted it so that the http://wood3_windows.pywood3_windows.py was in the exact same place and executed it in the exact same way as before and that still gives me the error :S
I checked the file and the tab character is there before the print syntax. i also checked for spaces and there dosent seem to be any...
I just cant see what i am doing wrong... what version of python are you running?

Oh damn you are 100% right. Python 2.X is fine with it but Python 3 complains about the syntax. This file was probably my first python work in 10 years, so I would not remember the syntax and did it with no care, this use of print is obsolete. Here it is fixed (removed the window specific version). Hope it will all be OK now and thanks for not letting it down :)

MoonCactus, You da' man :D
Actually just found out about this by searching google for a bit :) and was actually in the middle of editing the file for 3.x but i guess i wont have to now :D

Wrote another reply earlier, but apparently it didnt get posted :S
But i get this error when running the script on a file
Traceback (most recent call last):
File "http://wood31.pywood31.py", line 194, in <module>
if thisZ != None and maxZ < thisZ:
TypeError: unorderable types: Nonetype() < float()</module>

Looks like I am not proficient enough. Python3 changed a few things and I stumbled on all of them ;)
Uploaded http://Wood32.pyWood32.py and this time I tried it really (but not all the options, so there may be some residual issues in the corners)

That did it :D you're awesome dude :D

Well, that print went very bad :( my whole spool of the laywoo-d3 tangled up midprint and pretty much desintegrated all of it. it was a whole new spool, now i have like 10 meters left thats any good :(
Anyone know why the dont put it on a friggin spool :S

Huh. I once had some brittle laywoo. It was OK to re-heat it in a box to give it some elasticity back, else it just broke all the time in the hobbed bolt (better not pinch it too much). See e.g, http://www.tridimake.com/2012/10/wood-filament-becoming-brittle-after.htmlhttp://www.tridimake.com/2012/...

Very cool thing, but does anybody know how to use this with a makerbot? How can I edit the x3g file? Or an other way, how can I convert a gcode to x3g?
Thanks in advance!

Rather than attempt to modify the exported X3G file, export gcode from MakerWare instead. I can't be sure that this script will work correctly, but it's worth trying.
Once you have exported and modified the gcode, you can use MakerWare to "Print From File" on the gcode.

I do not know and I will even not try. Now my license allows anyone to adapt it to a format that was made to lock you on a much advertized closed-source printer... You'll get more detailed explanations on my blog, I hope you will understand: http://www.tridimake.com/2013/11/a-rant-open-or-closed-you-get-what-you.htmlhttp://www.tridimake.com/2013/...

Can't seem to get the online version to work. How do I incorporate this into Repetier-Host for Mac/Slic3r?

Hi sorry for the late answer. What kind of issue do you have?
Actually you don't have to "incorporate" the script anywhere, but only to run it on the "G-code" file that is produced by your slicers, and before it gets sent to the printer (ie. save the g-code, run the script on it, then load and print the modified g-code file).
Take car the first time in case something goes wrong.

Thanks for responding! I guess, because of my lack of familiarity with Python, I don't know how to "run the script" on my G-code file.

You may have a look at python howto. Eg. on windows, here is a good starting point: http://docs.python.org/2/faq/windowshttp://docs.python.org/2/faq/w...

It is really easy once you open a console (aka terminal), move to the right place and put the files in the proper place. On linux/mac I guess it is even much easier because most of the requirements are met by default:

If you put both the script and the gcode file at the same place, then move to this place in the terminal, just rune this:
python http://wood_standalone.pywood_standalone.py -f yourfile.gcode

And it should work. Then you can play with other options such as min/max temp. Just run again like this to get some information:
python http://wood_standalone.pywood_standalone.py

lol I'm copy/pasting: "Hm sure, but would you send some to me for this free advertising space? ;)"
I'd love to try it indeed, and I have another idea for this filament, but I have so much at home that I don't feel like buying more for now

Wow! Will try it myself and link to your post on website! Thanks a lot!

This is top - thank you. Currently printing an Owl in Laywood scaled to 70% of the original size. This is the second Laywood print I have done - for the first, I had to sit next to the printer for a couple of hours tweaking away at the hot end temperature so this standalone script has enabled me to let it get on with things.

Glad you like it. One thing that makes it better also is the kind of variations applied to the temperature (these are not pure random).
I also fixed something absent from Cura 12.10+: every temperature found in the file was overridden by the plugin, including the last one. So at the end of the print, the nozzle was left hot, which is bad.
This version tries to keep the last temperature (usually something like M104 S0 = cool down).

Make sure to take pictures and post. Any ideas what you'll be printing next?

Oops! Sorry for this, I fixed it on Tue Feb 12 08:35:53 UTC 2013
You can contact me at jeremie francois at gmail

It would be cool if you could have the script show the graph before editing, then if you like it have it edit the file, and if you don't then redo the temperature gradients until you do like it

Good idea. I implemented this in the last version. I also transposed the graph so it easily be viewed in a text editor: now, simply run again the script to update the file. The previous generated temperatures will be overridden, no need to start again with the original file, much easier to tweak then.

So if I don't like the wood temperature graph at the beginning of the gcode, I just run it again on the original gcode file I take it?

Now you just need to re-run the same command line (up arrow + enter in the console), the old temperatures will be discarded and a new plot is generated. Check it in a text editor, it's easier to view now :)

Printed out a Bear with the Wood Filament: http://www.thingiverse.com/thing:49494http://www.thingiverse.com/thi...
Didn't have the python script to run on the gcode before I printed it.

Brown Bear (Ursus arctos) by Makerbot Printed with Wood Filament
by Fused3D

Hm sure, but would you send some to me for this free advertising space? ;)

If you can get a skeinforge plugin made, or standalone plugin made to modify gcode for varying the colors of wood in a print I would happily send you a roll of it.

Yeah! Here you are: I've converted it to a real standalone Python script :)

Well if this turns out and runs on windows good i'll send you some.

Wow, awesome work man. Really, really awesome.

That was originally motivated by my laziness, as I quit did not want to insert M104 commands manually throughout an entire g-code file ;)
I'm glad you like it, but the material itself is the awesome stuff: except for chocolate or clay it is the first one that really looks and feel gorgeous and not like cheap plastic. Still a bit expensive and with its own set of "properties" but one major improvement imho.

SUch a cool idea!

What would it take to run it as a Skeinforge module rather than a Cura module? That way it would be usable by more people. :-)

Yes please, Skeinforge!!