Count objects


#1

I was searching for it but cant find it. Need script like poly count but object count that will count all nurbses and/or polygons in my scene. It must be easy but I am :banghead: in scripting. Thx a lot


#2

Hi Falco,

this should do the trick… :slight_smile:

[size=2]

proc countObjects()
{
	 int $nurbsObj = size(`ls -type "nurbsSurface"`);
	 int $polyObj = size(`ls -type "mesh"`);
	 print("there is "+$nurbsObj+" Nurbs Objects and "+$polyObj+" poly Objects in the scene... 
");
}
countObjects;

regards

Alex
[/size]


#3

thxxxxxx you are god :)))))))))))))


#4

Hi Falco,

thanx… :slight_smile:

btw. here is a little script more… e.g. if you want to find out what type a selected object is…

e.g. if you select a camera, locator, poly, nurbs etc. objects, you get a “transform” as type… this little script will also tell you what kind of object it is… :slight_smile:


proc printObjAndType()
{
	 //the selected items/objects
	 string $daObj[]=`ls -sl`;
	 //run this for every selected object...
	 for( $obj in $daObj)
	 {
		 //what is the object type...
		 string $daType = `objectType $obj`;
		 if($daType == "transform")
		 {
				//get the shape
				string $shape[] = `listRelatives -s $obj`;
				//find out what type the shape is to find out what the object is...
				string $objSubType = `objectType $shape[0]`;
				$daType+= " and is a "+$objSubType+"";
		 }
		 //print out the current object and it's type...
		 print("the Object "+$obj+" is of the type "+$daType+"
");
	 }
}
printObjAndType;

regards

Alex


#5

nice ty :slight_smile:


#6

I have problems with the second one. Some string error. But never mind. I have another question. Could you add an instances counter also for that first script? Ty

Falco


#7

Hi Falco,

oki doki… :slight_smile:

i have modified the code for the second one… now it should work… if it doesn’t just let me know… :slight_smile:

regarding the instances I will see if I can implement it a bit later today… :slight_smile:

regards

Alex


#8

Hi Falco,

here is an updated version, which also counts the instanced objects… if they are of the type either poly or nurbs… :slight_smile:


proc countObjects()
{
	 string $daObjs[] = `ls -dag -ap`;
	 string $pObj[]= `ls -typ "mesh" $daObjs`;
	 string $nObj[]= `ls -typ "nurbsSurface" $daObjs`;
	 int $polyObj = size($pObj);
	 int $nurbsObj = size($nObj);
	 print("there is "+$nurbsObj+" Nurbs Objects and "+$polyObj+" poly Objects in the scene... 
");
}
countObjects;

regards

Alex


#9

incredible :slight_smile: Thx a lot. Well it says I have 11k objects in scene :eek:

Falco


#10

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.