Notifications
Clear all

[Closed] Get Cameras in an unloaded scene

Is there a way to get the names of all cameras in a max scene, which isn`t loaded, without unloading the currently open scene?

5 Replies

You can use “mergeMaxFile” with “#prompt” argument to filter/select/cancel what you want in the target max file :

mergeMAXFile @"D:\path	o\max\file.max" #prompt

Your current maxfile is still loaded, the target file (even big) loads fast to show objects within.

1 Reply
(@rayjo571)
Joined: 11 months ago

Posts: 0

This works well if the user wants to see the camera names, but i need to access the camera names with maxscript, so i can put them into an array and put the names into a listbox for example.

you have this :

getMAXFileObjectNames <max_filename_string> [quiet:<bool>]

It only returns an array of strings, so you can’t check if classof arr[i]==Camera
You can only check for a name convention.

A solution where i can check the class of the object would be better, but “getMaxFileObjectNames” seems to be the best way possible.
Thank you.

as a workaround:

(
   	
   	maxFile = @"D:\path	o\my\file.max"
   	arr = getMAXFileObjectNames maxFile quiet:true
   	cams = for str in arr where (matchpattern str pattern:"*cam*") collect str
   	
   	if cams.count != 0 then (
   		print cams
   		
   		mergeMaxFile maxFile cams #select quiet:true		-- do merge and select merged "*cam*" node name
   		if selection.count!=0 then (
   			wrong_objs = for c in selection where (superclassof c != camera)	-- array of non camera (if any)
   		)
   	)--end if	
   	
   )