How to assign a color to the imported stl model randomly ?

When I import a 3D model into Slicer,

it will be assigned yellow by default.

When I import many models, all the models are yellow and need to be manually adjusted to different colors one by one.

Is there a way to make the color of each model random?

Can you tell a bit more about your use case?

Do your really want random or you want to assign standard colors? We have color tables for anatomical structures, wouldn’t want to use these more meaningful colors instead?

How do you end up with many STL files? What do they contain? What do you want to do with them after loading?

As this picture shows,

this is composed of many models,

I downloaded from other websites,

but I need to import these models into Slicer for adjustment,

so I need to assign different colors to distinguish

In addition, when I use the Creat Model module to create different models,colors are yellow by default. In order to distinguish different models, I need to manually assign colors.I think this is unreasonable.

Randomly assigning a color would be easy but would result in non-deterministic result of data loading. The colors that you choose for models are not just deterministic but also meaningful (e.g., red is arterial tree, blue is venous; other colors are chosen to have good contrast when overlaid the basic colors).

When you specify what a model node represents (by double-clicking on the colored rectangle) then a meaningful color is assigned to it automatically. You can specify your own list of terms if the standard terms do not contain everything that you need. You can also write a short script that assigns standard terms (and therefore colors) to nodes based on their names.

Maybe a subject hierarchy context menu action could be added that would assign random colors (or somewhat random colors, for example it could assign similar colors to nodes in the same branch). You should be able to implement such features in Python quite easily and could be added to Sandbox extension and if it turns out to be useful to many people then it may be even added to Slicer core.