bugs in custom script.

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

...

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)

barigazy

roosterMAP's picture

dude, thank you so much! very

dude, thank you so much! very helpful!

barigazy's picture

*.ms

Or *.ms version

AttachmentSize
modify_stack_jumper.ms 1.84 KB

barigazy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.