PDA

View Full Version : MEL: Query if object type exists then delete it


bentllama
10-17-2002, 10:56 PM
MEL: Query if object type exists then delete it...

Does anyone have an example of this? I am batching a series of files and want to delete all polygonal data within the files during the batch.

-wT-
10-17-2002, 11:23 PM
string $whatsSelected = `select -all`;
string $whatToDelete = `filterExpand -sm 12 -fp $whatsSelected`;
delete $whatToDelete;

Dunno if that even works, but it's a start :)

Edit: Oh and that -sm 12 means it's looking for "Polygon", so I'm not sure if that suits your needs, look at the MEL command reference for "filterExpand", there's all the codes for each type of objects.

bentllama
10-18-2002, 12:07 AM
thanks.

You pointed me in the right direction...

woot!

bentllama
10-18-2002, 12:22 AM
Originally posted by -wT-
string $whatsSelected = `select -all`;
string $whatToDelete = `filterExpand -sm 12 -fp $whatsSelected`;
delete $whatToDelete;

// Error: line 2: Error while parsing arguments. //

bentllama
10-18-2002, 04:43 PM
*bump*

-wT-
10-19-2002, 03:46 PM
Oh damn, I forgot to add a few things to that, so the right code would be this:


select -all;
string $whatsSelected[] = `ls -sl -fl`;
string $whatToDelete[] = `filterExpand -sm 12 $whatsSelected`;
delete $whatToDelete;
select -cl;


Shouldn't try to write any code without testing it first ;)
Just tried this "version", with a nurbs sphere and polygon cube in the scene, and the cube got deleted after running this... have fun :thumbsup:

bentllama
10-19-2002, 06:40 PM
Works like a dream. Thanks!:applause: :applause: :applause:

CGTalk Moderation
01-13-2006, 06: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.