Grasshopper Rhino Query Model Objects - Invalid problem

I noticed that if a file contains unnamed objects, my regex patterns fail all the time.

Not sure but I think if a non existent name would be instead, would that help maybe?

Hi Martin,

I’m not sure I am understanding you, so if my take on it is too simplistic I apologise.

If you mean by failing you are not getting objects with no name returned, then you regex is doing what it should. If you want the no name objects then you have to define them as an alternative match. In the following example I have three objects, one named Frank, one named Sam and the third nameless. My first regex looks for names beginning with F and just returns Frank. My second regex looks for names beginning with F or with an empty name and returns my nameless object as well.

If I’ve failed to grasp the gist of your problem, please expand your explanation and I’ll take another look.


You should investigate the error messages given by the components.

1. Solution exception:Object reference not set to an instance of an object.

When you investigate with Model Object connecting its N output to Null Item you should check X and D, they give better info than N (feels like a bug to me that N gives twice false).

Since Name for Model Object is a null reference any attempt to filter on regex fails, if you hover over one of the outputs you’ll see that it equates to x.Name.RegEx("\d"). Since Name is null the call .RegEx("\d") fails as it would be x.null.RegEx("\d").

You should filter first for this and either replace all null references with empty string, or just filter out these objects to begin with. Seeing as you’re doing that with Replace Nulls I think there’s a bug there.

edit: workaround, use Pick'n'Choose with X output from Null Item to switch between the names and the -- input.

Thanks Nathan and @jeremy5

I looked at my example file posted above again and I’m uploading a slightly changed version.

Please note how the Query Model Objects component with the Regex pattern attached doesn’t update the geometry correctly, when the previous state had one of the name inputs empty. Maybe @kike needs to look at this? (31.9 KB)

1 Like


In the light of day, I see that I was indeed too simplistic in my reading of your issue…

I think that a crucial factor here is the distinction between “Name is null” and “Name is blank”. Null means the name is indeterminate, not blank. The only thing that should match a null is an IsNull function or method.

The question is then whether it is more appropriate for an object with no name to return a null or a zero length string when asked for a Name. My preference, as someone who has spent a lot of their working life doing data migrations, would be the latter - I don’t see any benefit in returning a null.


1 Like

Thanks Jeremy.

I think the Bake Content component just doesn’t bake / update the content when one of the name inputs is empty or null.

Match Text Regex goes red if one of the Name outputs Model Object component is null.

Python also outputs null when there is no object name but the Match Text Regex works without error.

My main goal was to filter objects with a name using just the Query Model Objects component.

Value cannot be null.

Regex, Contains, Starts With and Ends With filter all fail when an object has no name.

Can this be fixed please?

Below is a new file since it doesn’t seem to have anything to do with Regex: (22.7 KB)

It is a bug and it’s fixed on next BETA.

As @jeremy5 says already baked objects with no name should be treated as if they have an empty name.
Null signals an object with an indeterminate name, which happens here but is different.
Once is baked becomes determinate as empty.

1 Like

Thanks @kike