macroScript previewSelectedCameras 
category:"!animation tools"
toolTip:"Preview for SelectedCameras" 
icon:#("VCRControls",21)
(
--naming convention: camera_name = (### ,-=. ### ###), example "01 = 100 - 300"
-- create array of cameras
--
	global hid=#()
	global width
	global height
	global view = getviewsize()
	hid[1]=hideByCategory.Geometry
	hid[2]=hideByCategory.Shapes
	hid[3]=hideByCategory.Lights
	hid[4]=hideByCategory.Cameras
	hid[5]=hideByCategory.Helpers
	hid[6]=hideByCategory.bones
	ar=animationrange
	global a
	q= cameras as array
	for i = 1 to (q.count) do
	(
		if q[i] != undefined then
		(
			if ((findstring q[i].name "Target") != undefined) then (deleteItem q i)
		)
	)

	Rollout SelectCameras "Auto preview"
	(
		group "Resolution:"
		(
		button Three "320x240" across:2 width:60
		button Four "400x300" width:60
		button Six "640x480" across:2 width:60
		button Thousand "1024x768" width:60
		spinner Widthres "Width" range:[0,4000,0]
		spinner Heightres "Height" range:[0,4000,0]
		checkbox scr "FromViewport" align:#right checked:true
		)
		on Widthres entered do
		(
		width=Widthres.value
		)
		
		on Widthres entered do
		(
		height=Heightres.value
		)
		
		on Three pressed do
		(
			Widthres.value=320
			width=320
			Heightres.value=240
			height=240
		)
		
		on Four pressed do
		(
			Widthres.value=400
			width=400
			Heightres.value=300
			height=300
		)
		
		on Six pressed do
		(
			Widthres.value=640
			width=640
			Heightres.value=480
			height=480
		)
		
		on Thousand pressed do
		(
			Widthres.value=1024
			width=1024
			Heightres.value=768
			height=768
		)
		
		multilistbox objectToSelect "Cameras:" items:(for o in q collect o.name) selection:0
		button buttonok "Ok" width:80
		progressbar progress color:blue
		on buttonok pressed do
		(
			hideByCategory.all()
			hideByCategory.geometry = false
			global a=(objectToSelect.selection as array)
			num = a.count
			if scr.state == true then 
			(
				width=view[1]
				height=view[2]
				print height
			)
			else
			if scr.state == false then 
			(
				if (Widthres.value !=0) then 
				(
					if (Heightres.value !=0)  then
					(
					width=Widthres.value
					height=Heightres.value
					print height
					)
				)
				else
				(
				width=view[1]
				height=view[2]
				)
			)
			
--make preview
			for i =1 to (a.count) do
			(
				
				
				s=(filterString q[a[i]].name "= , . -")
				if (s.count>1) then
				(
					h1=s[s.count]
					h2=s[s.count-1]
					viewport.setCamera (q[a[i]])
					preview_name = (getDir #preview)+"/" + (q[a[i]].name as string) + ".avi"
					view_size = getViewSize()
					wbmp=width
					hbmp=height
					anim_bmp = bitmap wbmp hbmp filename:preview_name
					animationRange = interval (h1 as integer) (h2 as integer)
					for t = animationrange.start to animationrange.end do
					(
					progress.value = 100.*(t-animationrange.start)/(animationrange.end - animationrange.start)
					escapeEnable = true
					
					sliderTime = t
					dib = gw.getViewportDib()
					copy dib anim_bmp
					save anim_bmp
					)
					
					progress.value = 0
					close anim_bmp
					gc()
				)
			)
			progress.value = 0
			animationRange = ar
			hideByCategory.Geometry=hid[1]
			hideByCategory.Shapes=hid[2]
			hideByCategory.Lights=hid[3]
			hideByCategory.Cameras=hid[4]
			hideByCategory.Helpers=hid[5]
			hideByCategory.bones=hid[6]
			destroyDialog SelectCameras
		)
	)
	CreateDialog SelectCameras 200 350 400 300
	SelectCameras.objectToSelect.items
	--
)
