Results 1 to 2 of 2

Thread: How can I get an array of all scene items

  1. #1

    How can I get an array of all scene items

    I have only seen get Selected objects.
    Is there a way to get All objects in the scene (independent of their genus) so I can cycle through them.

    Thanks,

    Chris

  2. #2
    Newbie Member Tom Speed's Avatar
    Join Date
    Feb 2003
    Location
    Liverpool, England
    Posts
    86
    Here ya go, this will gather just the names & IDs of all Objects, Bones, Lights, Cameras.

    As you'll see the process for each item type is the same, except that as far as I know, Bones can only be accessed through the Mesh they belong to, as they can't exist by themselves.

    If you're testing this on a large scene with LOTS of items in it, you might want to rem out the info() calls :)

    Code:
    @version 2.6
    @warnings
    @script generic
    @name ListAllItems
    
    generic
    {
    	// Objects ..
    	objOA=Mesh();	// Object Agent for first Mesh in scene
    	while(objOA)	// If there's a Mesh ..
    	{
    		ObjNameList += objOA.name;	// Get its name
    		ObjIDList += objOA.id;		// Get its id
    
    		// Bones can't exist by themselves, so you access them via their Parent Mesh.
    		// So after getting the Mesh info, check if it has any Bones e.t.c before
    		// moving to the next Mesh
    		boneOA=objOA.bone(); // First Bone of this Mesh..
    		while(boneOA)
    		{
    			BoneNameList += boneOA.name;
    			BoneIDList += boneOA.id;
    			boneOA=boneOA.next();		// Next bone
    		}
    		objOA=objOA.next();	// Next Object
    	}
    	
    	// Lights ..
    	lightOA=Light();
    	while(lightOA)
    	{
    		LightNameList += lightOA.name;
    		LightIDList += lightOA.id;
    		lightOA=lightOA.next();
    	}
    	
    	// Cameras ..
    	cameraOA=Camera();
    	while(cameraOA)
    	{
    		CameraNameList += cameraOA.name;
    		CameraIDList += cameraOA.id;
    		cameraOA=cameraOA.next();
    	}
    	
    	// ACTION! (sorry, couldn't resist! :)
    	info(ObjNameList);
    	info(BoneNameList);	
    	info(LightNameList);	
    	info(CameraNameList);
    }
    Cya!
    Tom
    Last edited by Tom Speed; 08-06-2003 at 07:39 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •