ScriptSpot

Forum topic · General Scripting

Extracting Camera Information

By tobyritchie · 2010-04-06

Description

Hi Guys,

I'm looking for some help to find / develop a script that will export camera data from 3D Studio Max into an excel file. It would need to export the co-ordinates of the camera (x+530000m and y+180000m), Z would be unchanged. It would also need the roll, FOV and co-ordinates of the cameras target (x+530000m, y+180000m, z unchanged).

In one project I might have 20+ cameras which would be in separate files, I could merge these into a single file and then run this script to extract the camera information in one go. This data would then be formatted into a table for inclusion in our verified view documentation.

Is there a good way of doing this??

Many thanks.

Toby

Comments (1)

Anubis · 2010-04-08

Hi Toby,
If the csv files are the same as those that send me, I think I can help. The first line into the file was camera position data, and the second was it target position. Well, to merge this data, move a copy of all your *.csv files to "c:\temp" folder and try my snippet code. It will read all of them, correct X and Y, format new data to "c:\temp\cams_coords.csv". I hope this is what you ask for ;)

files = getFiles "c:\\temp\\*.csv"
outFile = createFile "c:\\temp\\cams_coords.csv"
for f in files do (
	rf = openFile f mode:"r+"
	s1 = readLine rf ; s1 = filterString s1 ","
	s2 = readLine rf ; s2 = filterString s2 ","
	s1[2] = formattedPrint (s1[2] as float + 530000) format:"0.20g"
	s2[2] = formattedPrint (s2[2] as float + 530000) format:"0.20g"
	s1[3] = formattedPrint (s1[3] as float + 180000) format:"0.20g"
	s2[3] = formattedPrint (s2[3] as float + 180000) format:"0.20g"
	format "%,%,%,%\n" s1[1] s1[2] s1[3] s1[4] to:outFile
	format "%,%,%,%\n" s2[1] s2[2] s2[3] s2[4] to:outFile
	close rf
)
close outFile