LODDING
This script let's you hide/show lod levels quickly and easily. You have 4 lod levels to use, simply select the object(s) you want on a specific level and hit the "+" next to the LOD level. "-" will remove it from that level. You can then use the show/hide buttons for those objects. Hint: Objects can be on more than one lod level.
macroScript LodDisplay category:"Fast Utils"
(
rollout renameObjs_rollout "LODS" width:344 height:240
(
button btnShow0 "Show" pos:[48,66] width:107 height:34
button btnHide0 "Hide" pos:[160,66] width:104 height:32
label lbl4 "LOD 0" pos:[8,80] width:32 height:16
button btnAdd0 "+" pos:[272,66] width:32 height:32
button btnRemove0 "-" pos:[304,66] width:32 height:32
button btnShow1 "Show" pos:[48,104] width:107 height:34
button btnHide1 "Hide" pos:[160,104] width:104 height:32
label lbl7 "LOD 1" pos:[8,118] width:32 height:16
button btnAdd1 "+" pos:[272,104] width:32 height:32
button btnRemove1 "-" pos:[304,104] width:32 height:32
button btnShow2 "Show" pos:[48,144] width:107 height:34
button btnHide2 "Hide" pos:[160,144] width:104 height:32
label lbl8 "LOD 2" pos:[8,158] width:32 height:16
button btnAdd2 "+" pos:[272,144] width:32 height:32
button btnRemove2 "-" pos:[304,144] width:32 height:32
button btnShow3 "Show" pos:[48,184] width:107 height:34
button btnHide3 "Hide" pos:[160,184] width:104 height:32
label lbl9 "LOD 3" pos:[8,198] width:32 height:16
button btnAdd3 "+" pos:[272,184] width:32 height:32
button btnRemove3 "-" pos:[304,184] width:32 height:32
fn ShowChildren parent levelText =
(
for obj in parent do
(
test = getUserPropBuffer obj
if matchpattern test pattern:levelText then
unhide obj
)
for children in parent.children do
(
ShowChildren children levelText
)
)
fn HideChildren parent levelText =
(
for obj in parent do
(
test = getUserPropBuffer obj
if matchpattern test pattern:levelText then
hide obj
)
for children in parent.children do
(
HideChildren children levelText
)
)
on btnShow0 pressed do
(
for obj in rootscene.world.children do
(
ShowChildren obj "*lod=0*"
)
)
on btnHide0 pressed do
(
for obj in rootscene.world.children do
(
HideChildren obj "*lod=0*"
)
)
on btnAdd0 pressed do
(
for loop = 1 to selection.Count do
(
test = getUserPropBuffer selection[loop]
if not(matchpattern test pattern:"*lod=0*") then
(
test = test + "lod=0\r\n"
setUserPropBuffer selection[loop] test
)
)
)
on btnRemove0 pressed do
(
for loop = 1 to selection.Count do
(
buff = (getUserPropBuffer selection[loop]) as stringStream
newb = stringStream ""
while not eof buff do
(
str = readLine buff
if str != "" and not matchpattern str pattern:"*lod=0*" do format "%\r\n" str to:newb
)
setUserPropBuffer selection[loop] (replace_LF_with_CRLF (newb as string))
)
)
on btnShow1 pressed do
(
for obj in rootscene.world.children do
(
ShowChildren obj "*lod=1*"
)
)
on btnHide1 pressed do
(
for obj in rootscene.world.children do
(
HideChildren obj "*lod=1*"
)
)
on btnAdd1 pressed do
(
for loop = 1 to selection.Count do
(
test = getUserPropBuffer selection[loop]
if not(matchpattern test pattern:"*lod=1*") then
(
test = test + "lod=1\r\n"
setUserPropBuffer selection[loop] test
)
)
)
on btnRemove1 pressed do
(
for loop = 1 to selection.Count do
(
buff = (getUserPropBuffer selection[loop]) as stringStream
newb = stringStream ""
while not eof buff do
(
str = readLine buff
if str != "" and not matchpattern str pattern:"*lod=1*" do format "%\r\n" str to:newb
)
setUserPropBuffer selection[loop] (replace_LF_with_CRLF (newb as string))
)
)
on btnShow2 pressed do
(
for obj in rootscene.world.children do
(
ShowChildren obj "*lod=2*"
)
)
on btnHide2 pressed do
(
for obj in rootscene.world.children do
(
HideChildren obj "*lod=2*"
)
)
on btnAdd2 pressed do
(
for loop = 1 to selection.Count do
(
test = getUserPropBuffer selection[loop]
if not(matchpattern test pattern:"*lod=2*") then
(
test = test + "lod=2\r\n"
setUserPropBuffer selection[loop] test
)
)
)
on btnRemove2 pressed do
(
for loop = 1 to selection.Count do
(
buff = (getUserPropBuffer selection[loop]) as stringStream
newb = stringStream ""
while not eof buff do
(
str = readLine buff
if str != "" and not matchpattern str pattern:"*lod=2*" do format "%\r\n" str to:newb
)
setUserPropBuffer selection[loop] (replace_LF_with_CRLF (newb as string))
)
)
on btnShow3 pressed do
(
for obj in rootscene.world.children do
(
ShowChildren obj "*lod=3*"
)
)
on btnHide3 pressed do
(
for obj in rootscene.world.children do
(
HideChildren obj "*lod=3*"
)
)
on btnAdd3 pressed do
(
for loop = 1 to selection.Count do
(
test = getUserPropBuffer selection[loop]
if not(matchpattern test pattern:"*lod=3*") then
(
test = test + "lod=3\r\n"
setUserPropBuffer selection[loop] test
)
)
)
on btnRemove3 pressed do
(
for loop = 1 to selection.Count do
(
buff = (getUserPropBuffer selection[loop]) as stringStream
newb = stringStream ""
while not eof buff do
(
str = readLine buff
if str != "" and not matchpattern str pattern:"*lod=3*" do format "%\r\n" str to:newb
)
setUserPropBuffer selection[loop] (replace_LF_with_CRLF (newb as string))
)
)
)
createDialog renameObjs_rollout
)
How it works: It simply adds a property "lod" to the objects properties.