Notifications
Clear all

[Closed] need help on a simple script, about timeline

Hello guys,
I need help on a simple max script which allow me to jumping from range of times in a click.
I am working on lots of game cycles in single string, so cycle A could be frame 10-46, cycle B frame 50-98,… etc. and it is really annoying to keep that data in a text file and type it in the time configuration every time when you wanna see your animation.
It would be really cool if I can have a pop up window like the attached file… all I need to do is type in the start/end frame. and click on the botton to jump from cycle to cycle.

basicly I don’t have much MAXscript bakground… so any in put would help !
or soeone can write it for me as an exercise, that would be really awesome too haha

cheers

4 Replies
macroScript FrameRangeMan category:"Bobo_s Tools"
(
	global FrameRanges_Rollout 
	try(destroyDialog FrameRanges_Rollout)catch()
	local theIniFile = getDir #plugcfg + "/FrameRangesMan.ini"
	local theRangesArray = #()

	rollout FrameRanges_Rollout "Frame Ranges Manager"
	(
		dropdownlist ddl_Ranges items:#()
		edittext txt_newName text:"Range"
    	spinner spn_fromFrame "Start:" range:[-100000,100000,animationrange.start] type:#integer fieldwidth:50 across:2
		spinner spn_toFrame "End:" range:[-100000,100000,animationrange.end] type:#integer fieldwidth:50
		button btn_createRange "Add New Range" across:2 width:95 align:#left
		button btn_updateRange "Update Range" width:95 align:#right
		button btn_getFromScene "Get Scene Range" across:2 width:95 align:#left
		checkbutton chk_setSceneRange ">Set Scene Range" width:95 align:#right
		
		on btn_getFromScene pressed do
		(
			spn_fromFrame.value = animationrange.start
			spn_toFrame.value = animationrange.end
		)
		
		on spn_fromFrame changed val do
    		if chk_setSceneRange.checked do animationrange = interval val animationrange.end
		on spn_toFrame changed val do
    		if chk_setSceneRange.checked do animationrange = interval animationrange.start val 
		
		
		fn getRangesFromFile =
		(
			numRanges = execute (getIniSetting theIniFile "Ranges" "Count")
			if numRanges == OK then numRanges = 0
			theRanges = #()
			theRangesArray = #()
			for i = 1 to numRanges do
			(
    			startFrame = execute (getIniSetting theIniFile ("Range_"+i as string) "Start")
				if startFrame == OK then startFrame = 0
    			endFrame = execute (getIniSetting theIniFile ("Range_"+i as string) "End")
				if endFrame == OK then endFrame = 100
    			RangeName = getIniSetting theIniFile ("Range_"+i as string) "Name"
				if RangeName == "" then RangeName = "No Name"
    			append theRangesArray #(RangeName, startFrame, endFrame)
    			append theRanges (RangeName+": ["+startFrame as string + " - " + endFrame as string + "]")
			)
			ddl_Ranges.items = theRanges
			txt_newName.text = "Range " + (theRanges.count+1) as string
		)
		on FrameRanges_Rollout open do
		(
			getRangesFromFile()
			ddl_Ranges.selection = ddl_Ranges.items.count
		)
		
		on ddl_Ranges selected itm do
		(
			animationRange = interval theRangesArray[itm][2] theRangesArray[itm][3]
			spn_fromFrame.value = theRangesArray[itm][2]
			spn_toFrame.value = theRangesArray[itm][3]
		)
		
		on FrameRanges_Rollout moved pos do
			setIniSetting theIniFile "Dialog" "Position" (pos as string)
			
		on btn_createRange pressed do
		(
			if txt_newName.text != "" do
			(
    			numRanges = execute (getIniSetting theIniFile "Ranges" "Count")
				if numRanges == OK then numRanges = 0
				numRanges += 1
    			setIniSetting theIniFile "Ranges" "Count" (numRanges as string)
    			setIniSetting theIniFile ("Range_"+numRanges  as string) "Start" (spn_fromFrame.value as string)
    			setIniSetting theIniFile ("Range_"+numRanges  as string) "End" (spn_toFrame.value as string)
	    		setIniSetting theIniFile ("Range_"+numRanges  as string) "Name" txt_newName.text
				getRangesFromFile()
				ddl_Ranges.selection = ddl_Ranges.items.count
			)
		)
		
		on btn_updateRange pressed do
		(
			if ddl_Ranges.selection > 0 then
			(
    			setIniSetting theIniFile ("Range_"+ddl_Ranges.selection as string) "Start" (spn_fromFrame.value as string)
    			setIniSetting theIniFile ("Range_"+ddl_Ranges.selection as string) "End" (spn_toFrame.value as string)
				getRangesFromFile()
			)
		)
	
	)--end rollout
	thePos = execute (getIniSetting theIniFile "Dialog" "Position")
	if thePos == OK do thePos = [100,100]

	createDialog FrameRanges_Rollout 220 130 thePos.x thePos.y
)--end macro	

Short list of features:
*All ranges are shown in a dropdown list and saved to an INI file in your \Plugcfg directory
*To create a range, set the start and end time and the name in the UI and press Add New Range
*To update an existing range, select it from the list, change the values in the UI and press Update Range button
*To select a range, simply pick from the dropdown list
*To get the current scene time into the spinners in the UI, press the Get Scene Range button. (you can use Ctrl+Alt+Left/Middle/Right mouse button to manually set a range in Max, then hit the Get Scene Range button and then Add New Range to add it to the list.
*Check the >Set Scene Range checkbutton to directly manipulate the scene range. When checked, changing the Start and End frame values will directly affect the scene range.
*The Name field will always show “Range X” where X is the number of ranges + 1. You can type in any name you want. Note that you cannot currently rename ranges after the fact (but you can edit the INI file by hand)
*The last position of the UI will be saved and restored in the INI.

What is not there:
*You cannot delete ranges
*You cannot rename ranges
*You cannot save to alternative INI files (but that would be easy to add)

this is just perfect ! thanks a lots

Hi,

If you need some more advanced features, get the render pass manager plugin

http://www.rpmanager.com/

It totally rocks and once you go RPM you can’t go back, it should be an integrated part of max imho. What it dose is store passes for you, so you can have a cycle range a camera rendersettings and everything in at pass and just use it in the same fashion as bobos script…

Anyhoo, just a plug… and an idea…

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

LOL!

Comparing my short script to PRM is like comparing the Pong game to Doom 3
Grant spent years polishing PRM (and our LnR dept. cannot live without it), while the above code was written in 20 minutes before dinner…

Anyone who needs ANY form of render passes management better go and check out PRmanager!