Converting obj files to sketchup
in
Integration and Hardware
•
1 year ago
I've been working with Google sketchup to create triangulated 3D models that I wanted to render in Processing. I thought I would share a short list of c shell commands I wrote to do the conversion automatically. The following list of commands take an obj file (input.obj) and covert it to a list of processing vertices (output.txt). I've only tested this with OBJ files exported from sketchup (select the "all faces triangulated" and "swap YZ" options for exporting).
I'm not sure how this code will render, but there should only be three lines, two beginning with an awk command and the third an rm command.
Someday I will learn a real scripting language.
- awk '/v /' input.obj | awk '{print "vertex (",$2,",",$3,",",$4,");"}' > temp1.txt
awk '/f /' input.obj | tr '/' ' ' | awk '{print $2,"\n",$5,"\n",$8}' | awk '/[0-9]/ {print "sed -n ",$1," p temp1.txt"}' | sed "s/n /n '/" | sed "s/ p/'p/" | sh > output.txt
rm temp1.txt
I'm not sure how this code will render, but there should only be three lines, two beginning with an awk command and the third an rm command.
Someday I will learn a real scripting language.