Hi.
My current challenge is to select all texts from a rhino document, and then append each text to new lists, but by color. A short example: I have 10 text objects, 3 are red, 3 are green and 4 are blue. I need to select all objects, and 3 lists are to be made: 1 list containing the red text objects, 1 list containing the green objects and the last one containing the blue objects.
for i in objs:
if rs.IsText(i):
l1 = rs.ObjectsByColor(color1)
rs.DeleteObjects(l1)
l2 = rs.ObjectsByColor(color2)
rs.DeleteObjects(l2)
With these lines of code, the script deletes all my objects that have those colors, even though I never selected them.
Any help is appreciated.
Thanks, T.
Hi,
Here is a python script which gives you an example to extract all colors affected to your texts objects, then to create lists of text objects of the same color. It may help you. Select Text By Color.7z (24.0 KB)
What do you need to do with these lists ? You talk about select them, then in your code you delete them … Can you give us an example of the user actions you imagine ?
In this code you ask user to pick multiple objects in the model. Then for each of these objects, if it’s a text object, rhino delete all objects of the same color in the model, not only text objects. You should probably put a rs.isText(l1) filter after rs.ObjectsByColor(color1)
You should try something like this :
for i in objs:
if rs.IsText(i):
l1 = rs.ObjectsByColor(color1) #rs.DeleteObjects(l1)
for j in l1:
if rs.IsText(j):
rs.DeleteObjects(j)
But I don’t get what you want to do with rs.deleteObjets. I thought you wanted to select objects ?