ScriptSpot

Forum topic · General Scripting

bugs in custom script.

By roosterMAP · 2013-10-16

Description

wrote a handy little script that helps me navigate through my stack upon execution. It checks to see where I am in the stack and moved to the lower modifier. When it reaches the root, it goes back the the top of the stack. The main problem is that when it reaches the bottom of the stack (and the bottom of the stack is an editable poly), it cannot seem to go back to the top. Also, when I have instances of an object and I run the script on one of them, it selected the next modifier on the other object. Here is the source code of the script. Plz help:

(
	try
	(
		i = modPanel.getModifierIndex $ (modPanel.getCurrentObject()) --if cannot initialize, then root is reached
			print i
	)
	catch 
	(
		--reached root
		i = 999
		print i
	)
	if(i<$.modifiers.count) then
	(
		--next
		i=i+1
		modPanel.setCurrentObject $.modifiers[i]
	)
	else if(i==999) then
	(
		--back to top
		i = 1
		modPanel.setCurrentObject $.modifiers[i]
	)
	else
	(
		modPanel.setCurrentObject $.baseObject
	)
)
Comments (3)

barigazy · 2013-10-16

Here is your tool

try(destroyDialog ::msRoll)catch()
rollout msRoll ":)"
(
fn setMody obj mode: =
(
if getCommandPanelTaskMode() != #modify do setCommandPanelTaskMode #modify
if (cnt = obj.modifiers.count) == 0 then modPanel.setCurrentObject obj.baseobject else
(
case mode of
(
#top: modPanel.setCurrentObject obj.modifiers[1]
#up:
(
if isKindOf (mody = modPanel.getCurrentObject()) Modifier then
(
if (idx = modPanel.getModifierIndex obj mody) == 1 then modPanel.setCurrentObject obj.baseobject
else modPanel.setCurrentObject obj.modifiers[idx-1]
)
else modPanel.setCurrentObject obj.modifiers[cnt]
)
#down:
(
if isKindOf (mody = modPanel.getCurrentObject()) Modifier then
(
if (idx = modPanel.getModifierIndex obj mody) == cnt then modPanel.setCurrentObject obj.baseobject
else modPanel.setCurrentObject obj.modifiers[idx+1]
)
else modPanel.setCurrentObject obj.modifiers[1]
)
#bottom: modPanel.setCurrentObject obj.baseobject

)
)
)

button btn_top "Top" width:50 pos:[5,5]
button btn_up "Up" width:50 pos:[5,25]
button btn_down "Down" width:50 pos:[5,45]
button btn_bottom "Bottom" width:50 pos:[5,65]

on btn_top pressed do (if selection.count == 1 do setMody selection[1] mode:#top)
on btn_up pressed do (if selection.count == 1 do setMody selection[1] mode:#up)
on btn_down pressed do (if selection.count == 1 do setMody selection[1] mode:#down)
on btn_bottom pressed do (if selection.count == 1 do setMody selection[1] mode:#bottom)

)
createDialog msRoll 60 90 10 110 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

*.ms

barigazy · 2013-10-16

Or *.ms version

Attachments

roosterMAP · 2013-10-17

dude, thank you so much! very helpful!