PDA

View Full Version : Count objects


Falco
08-10-2004, 03:20 PM
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

strarup
08-10-2004, 04:26 PM
Hi Falco,

this should do the trick... :)

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... \n");
}
countObjects;

regards

Alex

Falco
08-10-2004, 07:02 PM
thxxxxxx you are god :)))))))))))))

strarup
08-10-2004, 08:48 PM
Hi Falco,

thanx... :)

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... :)


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+"\n");
}
}
printObjAndType;

regards

Alex

Falco
08-10-2004, 09:58 PM
nice ty :)

Falco
08-11-2004, 08:07 AM
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

strarup
08-11-2004, 08:18 AM
Hi Falco,


oki doki... :)

i have modified the code for the second one... now it should work... if it doesn't just let me know... :)

regarding the instances I will see if I can implement it a bit later today... :)

regards

Alex

strarup
08-11-2004, 10:22 AM
Hi Falco,

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


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... \n");
}
countObjects;

regards

Alex

Falco
08-11-2004, 02:44 PM
incredible :) Thx a lot. Well it says I have 11k objects in scene :eek:

Falco

CGTalk Moderation
01-18-2006, 10:00 PM
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.