/*********** SAMPLE SCENE **********/
delete objects
gc()
with redraw on
(
t0 = for k=0 to 8 collect
(
t = teapot name:(uniquename #red_teapot_) radius:19 pos:[4,0,0] rotation:(eulerangles 0 0 (k*40)) wirecolor:red
)
gr0 = group t0 name:#red_group
move gr0 [-50,0,0]
t1 = for k=0 to 9 collect
(
t = teapot name:(uniquename #green_teapot_) radius:15 pos:[10,0,0] rotation:(eulerangles 0 0 (k*36)) wirecolor:green
)
gr1 = group t1 name:#green_group
move gr1 [50,0,0]
t2 = for k=0 to 8 collect
(
t = teapot name:(uniquename #orange_teapot_) radius:20 pos:[-6,0,0] rotation:(eulerangles 0 0 (k*40)) wirecolor:orange
)
gr2 = group t2 name:#orange_group
move gr2 [0,50,0]
t3 = for k=0 to 9 collect
(
t = teapot name:(uniquename #blue_teapot_) radius:13 pos:[-16,0,0] rotation:(eulerangles 0 0 (k*36)) wirecolor:blue
)
gr3 = group t3 name:#blue_group
move gr3 [0,-50,0]
)
/*********************** METHODS **********************/
fn collectGroupHeads =
(
for obj in objects where isGroupHead obj collect obj
)
fn collectHeadGroup head = if isGroupHead head do
(
join #() head
)
fn exportSetup =
(
file = objExp.getIniName()
if doesFileExist file then
(
setINISetting file #Material #UseMaterial "1"
setINISetting file #Geometry #ObjScale "1.000"
true
)
else false
)
fn exportHeadGroup head dir: = if isGroupHead head do
(
if dir == unsupplied do dir = getdir #temp
makeDir dir all:on -- just in case the path doesn't exist
cursel = selection as array
nodes = collectHeadGroup head
select nodes
filename = pathConfig.appendPath dir (head.name + ".OBJ")
res = exportFile filename #noPrompt selectedOnly:on using:ObjExp
if cursel.count == 0 then clearselection() else select cursel
if res do filename
)
fn exportHeadGroups dir: setup:on =
(
if dir == unsupplied do dir = getSavePath()
if dir != undefined do
(
heads = collectGroupHeads()
exported = #()
if heads.count > 0 do with redraw off, undo off
(
if setup do exportSetup()
exported = for head in heads collect
(
expfile = exportHeadGroup head dir:dir
if expfile != undefined then #(head, expfile) else dontcollect
)
)
exported
)
)
/************ RUN BELOW TO DO THE EXPORT ****************
res = exportHeadGroups()
********************************************************/
feel free to ask questions if you encounter a problem or want more details...