Heapsize = 7.5*10^6 -- Set heapsize to 7.5 MB
obj_world_rotation ; thedummy ; theobj ; rot_ratio_abs
resetmaxfile
with undo off(
with redraw off(
fn fn_calc_rot_ratio x =(
		
		for obj in geometry do (
			if (matchpattern obj.name pattern:"_copy") do (
		resetxform obj ; maxOps.CollapseNodeTo obj 1 true --reset Xform + collapse stack
		rot_ratio = ( ((-1 * obj.min.x) + obj.max.x) / ((-1 * obj.min.z) + obj.max.z) ) / ( renderwidth / renderheight as float) - 1   --Calculate rotate ratio, lower value (ignore + or -) = closer to render aspect ratio
		rot_ratio_abs = abs rot_ratio
		)
			)
				)
				
fn calc_data a b =(
	in_file = "C:\\Users\\GOD\\Desktop\\P90 (single obj).max"
	out_dir = "C:\\Users\\GOD\\Desktop\\359 2\\"
	
	steps = (b-a) ; print(steps)

	steps = steps-1
	for i in 0 to steps do(
		resetmaxfile #noprompt
		loadmaxfile in_file quiet:true #noprompt
		
		for obj in geometry do (
			if (matchpattern obj.name pattern:"_copy") do(
				theobj = obj
				select obj
				) -- end if obj.name matchpattern pattern:"_copy" do(
			) -- end for obj in geometry do
		theobj.rotation = eulertoquat (eulerAngles 0 0 i) -- Set initial rotation obj (world coordinates)
		obj_world_rotation = $.rotation
		
		clearselection()
		thedummy = dummy isselected:on
		selectmore theobj	
		thedummy.rotation = obj_world_rotation
		Dummy_and_obj = selection as array
		
		out_name = out_dir + i as string + ".txt"
		out_file = createfile out_name -- Create external file
		close out_file -- Close external file
		for j in 0 to steps do(
			theobj.parent = thedummy -- link dummy/obj
			thedummy.transform = (rotateYmatrix 1 ) * thedummy.transform -- Rotate dummy/obj local Y-axis
			theobj.parent = undefined -- unlink dummy/obj
			--calc rot ratio
			fn_calc_rot_ratio 1
			--open ext. file
			fs = openFile out_name mode:"a"
			--format [angle rot_ratio_abs \n] to external file
			format "% % \n" j rot_ratio_abs to:fs --Format precalculated value of rotation ratio to exteral file (without newline)
			close fs -- Close external file			
			
			) -- end for j in 0 to (steps-1) do(

			delete thedummy -- delete dummy obj
			
		) -- end for i in 0 to (steps-1) do(
	) -- end fn calc_data a b =(
				
-- Call main function (structure: calc_data --> fn_calc_rot_ratio)
calc_data 0 110
				
			) --end with redraw off
		) --end with undo off	