PDA

View Full Version : How to select all objects of a class in your model


Brenton King
08-22-2007, 08:12 PM
If you need to select all of your processors or network nodes or conveyors or any other class of objects in your model you can paste the following code into your script window. All you will need to change is the name of the class that is in quotes. (examples: Processor, Conveyor) This code is great because you can name your objects whatever you want but they won't hide from this code.



forobjecttreeunder(model())
{
if(comparetext("NetworkNode", getname(first(classes(a)))))
{
switch_selected(a, 1);
}
else
{
switch_selected(a, 0);
}
}

Tom David
08-23-2007, 12:26 AM
And if you like to do anything with the selected objects you could do something with the following code:


// FOR ALL SELECTED (RED) OBJECTS IN MODEL
forobjecttreeunder(model())
{
//IF OBJECT IS SELECTED AND IF IT IS AN OBJECT
if(and(switch_selected(a,-1),eq(4,getdatatype(a))))
{
//SHOW A SCREEN MESSAGE WITH THE NAME
msg(getname(a),getname(a));
}
}


My code is boring, because it only shows the names of the objects, but you can do exciting things if you like ;).

Have fun with it.
tom the (A)tom

shivrash
04-03-2008, 03:23 PM
If you need to select all of your processors or network nodes or conveyors or any other class of objects in your model you can paste the following code into your script window. All you will need to change is the name of the class that is in quotes. (examples: Processor, Conveyor) This code is great because you can name your objects whatever you want but they won't hide from this code.



forobjecttreeunder(model())
{
if(comparetext("NetworkNode", getname(first(classes(a)))))
{
switch_selected(a, 1);
}
else
{
switch_selected(a, 0);
}
}


Hey thanx 4 da code...

But where do i paste it? In my model, I have got 27 processor and 30 queues whose properties I would like to change in one step..Does pasting this code select all 27 proc. and 30queues ? If yes, then where shall i paste this code?

Tom David
04-03-2008, 11:25 PM
You can use the Script window to do the job.
You can find it under /View/Script Window in the menu.
Or use the Speedbutton Script between Persp and Control.

Good success.

P.S.: There is also a user command in the download section under Custom User Commands "select group" which you might find useful.
And there is a thread under Gripes and Goodies "about "no select" and "show parameter window from side bar"" which I guess is also interesting for you. See my post "Manipulate selected (red) objects ".