it depends exactly how you're working your script, but heres a few tips to help you.
if you have an arbitrary selection, then:
string $shapes[] = ls ("-type", "mesh", (listRelatives ("-c", (ls ("-sl")))));
if you have an array full of objects, and you want to filter out only mesh nodes, use this:
string $array[] = { "someObject", "anotherObject" };
string $onlyShapes[] = ls -type mesh $array
;
those two examples should help you out, but if they don't work for exactly what you're doing, just ask for more detail. 
cheers,