Loading

Generate wood patterns with temperature changes

by MoonCactus, published

Generate wood patterns with temperature changes by MoonCactus Feb 11, 2013

Description

Script to generate texture via temperature gradients to get horizontal stripes that "look like wood".

**Update**: this script is also available as a simpler webservice here: tecrd.com/page/liens/stl_wood&lang=fr (it will refuse and fail too big input files though as long as I have to pay for my CPU, sorry).

The owl is Cushwa's popular design at thingiverse.com/thing:18218

It was printed here with LAYWOO-D3 wood filament thingiverse.com/thing:30552
It works also somehow with some other filament (just tweak the temperature), with a less drastic effect.

This is a piece of source code of mine, originally made for Skeinforge within Cura 12.08, now part of the official releases, and is now also an independent standalone Python script.

Recent Comments

view all
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
Glad it worked fine :) This material is really outstanding for art and good-looking prints compared to regular plastics!
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!

Liked By

view all

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag. Print Thing Tag

Instructions

This is the code of my post here: betterprinter.blogspot.fr/2012/10/shades-of-brown-with-wood-filament-via.html


Last updates:
Fri Jan 10 14:32:52 CET 2014
wood31 Fixed obsolete syntax that made Python3 fail (thanks @Mysli)
wood32 is for Python3, should work also on Python2 but untested by me!
Thu Jan 9 23:10:51 CET 2014
Added some more options, and a Windows-friendly zipped version with windows line ends and zipped so that it does not get corrupted when downloaded or opened (this OS sucks so much that you have to pay for it, and you get a notepad as useful as an ashtray on a motorbike, so ridiculous!)

Sun Jul 7 21:43:12 UTC 2013
- web service hosted on tecrd.com/page/liens/stl_wood&lang=fr
Tue Feb 12 08:35:53 UTC 2013
- more readable ASCII art plot
- can be re-run on itself, it will no more duplicate the commands and graph
- fixed a bug in the numeric arguments (thanks to Fused3D)


This script was an official plugin in Cura (version 12.11+). Check it here: wiki.ultimaker.com/CuraPlugin:_Wood Thanks to Daid for porting my old Skeinforge/Cura version to the new and much cleaner plugin system. The tgz archive could be useful only to Skeinforge users or old-timers of Cura. Better ignore it ;)

After multiple requests and at last, I finally converted it to a standalone Python script that no more needs Cura nor Skeinforge. I documented the process here by the way: betterprinter.blogspot.fr/2013/02/how-tun-run-python-cura-plugin-without.html

You'll need Python on your computer. Then run the wood_standalone.py script as follows:

python wood_standalone.py --min minTemp --max maxTemp --grain grainSize --file gcodeFile

or in brief mode:

python wood_standalone.py -i minTemp -a maxTemp -g grainSize -f gcodeFile

This will "patch" your gcode file in place (it will be modified), so keep a backup if you need one.
- minTemp is the minimum temperature to use (the code ensures that it is reached)
- maxTemp is the maximum temperature to use (the code ensures that it is reached)
- grainSize lets you tweak the "average thickness" of the layers
The gcodeFile is the only compulsory parameter.

Initial temperature settings will be overridden by the varying pattern that is generated by this script (a variant of recursive Perlin noise). You can run it multiple times to test different values and generated temperature curve until you like it.

Default values are minTemp=190, maxTemp=240 and grainSize=3. Higher themperature give darker bands (due to the wood being burnt). Do not let the wood stay too long in your nozzle else you will most probably clog it with carbon!

Finally, to run it on windows you may want to check the FAQ here: docs.python.org/2/faq/windows.html
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
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 wod3.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 wood3.py --file myobject.gcode

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

Hope it helps!
c:>python wood3.py --file lower.gcode

Gives me the following:
File "http://wood3.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 wood3_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
Mysli - in reply to Mysli
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.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 Wood32.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
Mysli - in reply to Mysli
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, tridimake.com/2012/10/wood-filament-becoming-brittle-after.html
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: tridimake.com/2013/11/a-rant-open-or-closed-you-get-what-you.html
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: docs.python.org/2/faq/windows

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 wood_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 wood_standalone.py
This would also look nice with sandstone filament!
https://igo3d.com/pla-abs-filament/special-filaments/laybrick-filament.html
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: thingiverse.com/thing:49494
Didn't have the python script to run on the gcode before I printed it.
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!!
Top