Find by name

Newbie here.

I have given names to grouped objects. Now I need to find an object by its name. I expect Rhino to zoom into it and select it. Is this possible?

I see the FindText command but if I enter a name in there, it cannot find anything. Am I maybe using it wrong?

image

Any help appreciated!

Hi @davosian,

Try using the SelName command.

– Dale

Hi @dale,

SelName is certainly helpful, thank you! However, when this list gets longer and I am looking for a substring, I was hoping that a find method could help out as well. Since I am using a naming convention, I might want to select all objects that contain a *TA* or a W7*. Does this make sense?

Dennis

Btw, I found some coding snippet that does what I am looking for, however I do not know whether I can use this as a simple script within Rhino (e.g. the Python version):

Here is a relatively simple script that may help -

It puts up a stringbox on the screen where you can type the search term. It allows for * as wildcards at the start, end or both start and end of the search string (not in the middle though). It will select all objects that have object names corresponding to the criteria. If no wildcard is used, the object name and the entire search string must match exactly. It is not case-sensitive (but can be made so). It will report the number of objects selected and also if any matching objects are locked, hidden or are on locked or off layers.

More sophisticated searches could be made with regular expressions, but perhaps this may be enough for you…

SearchSelectObjName.py (2.6 KB)

2 Likes

Exactly what I was looking for, thanks @Helvetosaur! I am using RunPythonScript to trigger the find dialog.

Here are some instructions for making this work from a toolbar button or alias…

https://wiki.mcneel.com/developer/macroscriptsetup

I learned about aliases and tried to run the script as an alias but for some reason I do not get the popup this way. Here is what I did:

On my Mac, I copied the script inside the library folder: /Users/dstaiger/Library/Application Support/McNeel/Rhinoceros/Scripts/SearchSelectObjName.py and restarted Rhino. Then I created an alias “FindByName” and set it to ! _-RunPythonScript SearchSelectObjName.py.

When I now use Cmd-K to run the alias, nothing happens other than a message displaying at the bottom in the status bar: Python Script <SearchSelectObjName.

I also tried variants without a .py ending and with/without “”, but still no luck.

What am I missing?

These are the instructions I followed: https://discourse.mcneel.com/t/running-python-scripts-from-aliases-or-toolbar-buttons/47290

This is what I have configured after copying the script there:

I am not getting the popup to enter my search query if I do it this way. Is it maybe not interactive anymore?

That all seems like it should work… my Mac is unfortunately too old to run V7, but I can see if it will run in V6. Wait, what does Cmd+K do? Does the script run if you type out the full alias name?

OK, I can’t get it to work from an alias here on my Mac either - it works with RunPythonScript and browse to file on the desktop… @pascal can you test why?

As far as I can see right now, this is completely broken in V7. Still poking.

-Pascal

Cmd-K opens the command prompt:

OK, I can’t get it to work from an alias here on my Mac either - it works with RunPythonScript and browse to file on the desktop

This is exactly the behavior I am seeing.

V6 too, as far as I can tell.

Yep, I found that as well. Bugging people as we speak…
RH-62230 RunPythonScript - macros fail

-Pascal

Hi,

There is a 6.0 or 7.0 in the path corresponding to the version of Rhino you’re running.
Ex: Library/Application Support/McNeel/Rhinoceros/6.0/scripts

You can confirm with a script:

import sys
for p in sys.path:
    print p

Ah, so that means simply that the script is in the wrong folder… Hang on, going to check that now (for 6.0 at least).

OK, I can confirm that it’s working - thanks Alain! I will update the Wiki page and the Discourse topic (if I can) with this info…

Edit: Wiki page updated.

@wim - the Discourse post on this page - which people seem to find as per above - has information that needs to be updated. As the first post is two years old, I can no longer edit it, and putting new info with corrections at the bottom of a long thread will not be found easily… Any way to be able to edit that first post with the new info?

Using the correct folder path for the script is working fine. In my case for Rhino 7, it is /Users/myusername/Library/Application Support/McNeel/Rhinoceros/7.0/scripts.

Thanks to all for your great support!

Thanks, Mitch!

I’ve copied your text from the wiki page and used that to edit your post.
Let me know if I messed it up!
-wim

1 Like

:+1:t2::+1:t2:

1 Like