# \_SelSameName?

**URL:** <https://discourse.mcneel.com/t/selsamename/182868>\
**Category:** Rhino\
**Tags:** windows\
**Created:** [May 27, 2024, 4:10pm UTC](https://discourse.mcneel.com/t/selsamename/182868 "2024-05-27T16:10:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Toni\_Osterlund](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/toni_osterlund/32/762021_2.png) [@Toni\_Osterlund](https://discourse.mcneel.com/u/Toni_Osterlund)\
**Post date:** [May 27, 2024, 4:10pm UTC](https://discourse.mcneel.com/t/selsamename/182868/1 "2024-05-27T16:10:36Z")

</div>

Would there, could there be a macro for selecting objects with the same name?  
Currently `-Selname Select` does not work with preselection

---

<div class="post-metadata">

**Author:** ![pascal](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/pascal/32/479395_2.png) [@pascal](https://discourse.mcneel.com/u/pascal)\
**Post date:** [May 27, 2024, 4:35pm UTC](https://discourse.mcneel.com/t/selsamename/182868/2 "2024-05-27T16:35:58Z")

</div>

Hi Toni - - scriptable -SelName Select Enter with pre-selection should work - as it does with

`-SelLayer Pick Enter`

, but does not. Not to mention the option name should match. Thanks for pointing this out, I’ll see if we can get it fixed.

-Pascal

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [May 27, 2024, 5:17pm UTC](https://discourse.mcneel.com/t/selsamename/182868/4 "2024-05-27T17:17:40Z")

</div>

Hi @Toni_Osterlund,

Here is a Python script that _may_ help.

[SelSameName.py](https://discourse.mcneel.com/uploads/short-url/9HGAbe1kDluDjKWO62rxpvR5U4U.py) (592 Bytes)

– Dale

---

<div class="post-metadata">

**Author:** ![Toni\_Osterlund](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/toni_osterlund/32/762021_2.png) [@Toni\_Osterlund](https://discourse.mcneel.com/u/Toni_Osterlund)\
**Post date:** [May 27, 2024, 6:16pm UTC](https://discourse.mcneel.com/t/selsamename/182868/5 "2024-05-27T18:16:07Z")

</div>

Thanks @pascal @dale  
So python it is.

I re-wrote Dale’s idea to a button.  
Seems to work. Good for now.

```auto
_NoEcho _-RunPythonScript (
#! python 2
import scriptcontext as sc
import rhinoscriptsyntax as rs

def SelSameName(objs):
    rs.EnableRedraw(False)
    names = []
    for obj in objs:
        name = rs.ObjectName(obj)
        if name != None:
            names.append(name)
	if len(names) > 0:
		for rh_obj in sc.doc.Objects:
			for name in names:
				if rs.ObjectName(rh_obj) == name:
					rs.SelectObjects(rh_obj)

    rs.EnableRedraw(True)

selection = rs.SelectedObjects()
if len(selection) == 0:
    selection = rs.GetObjects("Pick objects",0,False,True,True)
    if not selection: Exit
    
SelSameName(selection)
)

```
