Welcome! Log In Create A New Profile

Advanced

Auto Orienting STLs

Posted by nicholas.seward 
Auto Orienting STLs
October 21, 2013 01:41PM
From time to time I have had to go through and transform a bunch of STLs so they are oriented in a print friendly way. This weekend I finally hobbled together a script that can batch process a bunch of files for me. It is by no means perfect but it serves me well.

[github.com]

How it works:
It sums the (xy area)(z distance) for all triangles that are angled down too much. (This is the volume of the support structure needed) I also keep track of the area of the base. I try to minimize the first quantity while maximizing the base area. It only looks at the 6 easy orientation. It also isn't smart enough to identify that something is a bridge and shouldn't be added to the support structure volume. It is also not smart enough to decrease the calculated support volume if it could terminate on a plastic surface instead of the bed.

I post this because hopefully someone else can use it and I wanted to start a conversion. Is there already a better tool out there? If not what would you like in the perfect tool?

My future plans include:
*bridge detection
*max print volume containment
*find the convex hull and find the best triangle from that to sit on the print bed
*calculate the real support volume as mentioned above

Those are way out plans.

BTW, I have been trying to do a lot of direct manipulation of SLTs to get me ready for writing a nonplanar slicer for 4+DOF robots. Sextupteron, Six Arm Simpson, and my "secret" project Tilt-n-Twirl.

Edited 1 time(s). Last edit at 10/21/2013 02:05PM by nicholas.seward.
Re: Auto Orienting STLs
October 21, 2013 02:15PM
thanks for doing this, as far as I know their is no auto orientation software, but I may be wrong.

Edit, getting this error message, am I doing something stupid?, Hmmmm tilt&twirl.

Processing: prism.stl
Traceback (most recent call last):
File "orient.py", line 209, in
s=solid(sname)
File "orient.py", line 71, in __init__
data=struct.unpack("ffffffffffffH",f.read(50))
struct.error: unpack requires a string argument of length 50

Edited 2 time(s). Last edit at 10/21/2013 02:40PM by johnrpm.


Random Precision
Re: Auto Orienting STLs
October 21, 2013 03:36PM
@johnrpm: You are probably okay. Can you tell me what version of python you are running? OS?
Re: Auto Orienting STLs
October 21, 2013 03:46PM
python 2.7.3 on linuxlite, an ubuntu derivative.

Edit, perhaps I am missing a python module ??.

Hmmmm Tilt-n-Twirl.

Edited 1 time(s). Last edit at 10/21/2013 04:52PM by johnrpm.


Random Precision
Re: Auto Orienting STLs
October 21, 2013 05:16PM
@johnrpm: I changed "ffffffffffffH" to "12f1H". I have no idea if that will work. (I mean it works for me.) I have a few other things I can try if that doesn't work. I am using the same version of Python as you. Let me know either way.

I will give you a hint Tilt-n-Twirl will both tilt and twirl. :-) 4DOF. (All the additional degree of freedom bots will probably have to wait as I finish Simpson and Wally. I also have a 1 arm SCARA plan that probably should be developed first.)

Edited 1 time(s). Last edit at 10/21/2013 05:18PM by nicholas.seward.
Re: Auto Orienting STLs
October 21, 2013 05:30PM
Sorry still getting the same error, (edited it in geany) am I missing a module ?.

Processing: prism.stl
Traceback (most recent call last):
File "orient.py", line 209, in
s=solid(sname)
File "orient.py", line 71, in __init__
data=struct.unpack("12f1H",f.read(50))
struct.error: unpack requires a string argument of length 50

P.S no rush if you are busy.

Edited 1 time(s). Last edit at 10/21/2013 05:31PM by johnrpm.


Random Precision
Re: Auto Orienting STLs
October 21, 2013 07:08PM
@johnrpm: I just pushed another version. It might fix the problem but will at least get me some more debug data.

Also, can you verify that prism.stl is 484 bytes. I am thinking that we might be getting an unintentional switching of newline character styles which shouldn't happen for a binary file.

Edited 1 time(s). Last edit at 10/22/2013 10:50AM by nicholas.seward.
Re: Auto Orienting STLs
October 22, 2013 01:21PM
I feel a right burk, the stl files are all about 27k, right clicked them and selected save as, so tried a different
stl file and it worked, both orient.py and reorient.py, so it was my fault, although I can not see how else to
download them.

So sorry to waste your time

Edit, it seems that it works with ascii but not binary files, unless its me again.

Edited 1 time(s). Last edit at 10/22/2013 01:39PM by johnrpm.


Random Precision
Re: Auto Orienting STLs
October 22, 2013 02:56PM
@johnrpm: No worries. I am just glad it works!

I just pushed some additional changes that I had to do to get it to work on a friends OSX machine.

BTW, this could be paired with kliment's simarrange to make build plates from randomly oriented parts.
Re: Auto Orienting STLs
October 23, 2013 09:46PM
Hi

Good to see your program here and will try later.

And I see there is a python program below for tweaking a gcode from STL model.

Please give credit to tedbeer from KISSclier forum also.smiling smiley

gcode tweak

Edited 1 time(s). Last edit at 10/23/2013 09:47PM by gayven.
Sorry, only registered users may post in this forum.

Click here to login