ObjectTable Filter objects by more than one UserString at a time

Hello All,

It would be nice to have a function with the flexibility of the ObjectTable.FindByUserString Method (with the ObjectEnumeratorSettings) that would allow the user to give two or more pairs of UserStrings to the filter.

Would it be at all possible to include this as a feature request?

Thnak you!

1 Like

What would that add over doing this in a for loop?

Hi @Gijs,

It would prevent a lot of Marshalling between safe and unsafe code. If I do the loop in C#, then the unsafe underlying method will be called for every item.

See, for example, the code below, which is the RhinoCommon implementation. All filtering is done through the UnsafeNativeMethods.CRhinoDoc_LookupObjectsByUserText call.

        public RhinoObject[] FindByUserString(string key, string value, bool caseSensitive, bool searchGeometry, bool searchAttributes, ObjectEnumeratorSettings filter)
        {
            InternalRhinoObjectArray internalRhinoObjectArray = new InternalRhinoObjectArray();
            IntPtr pObjectArray = internalRhinoObjectArray.NonConstPointer();
            IntPtr iterator = new ObjectIterator(m_doc, filter).NonConstPointer();
            UnsafeNativeMethods.CRhinoDoc_LookupObjectsByUserText(key, value, caseSensitive, searchGeometry, searchAttributes, iterator, pObjectArray);
            RhinoObject[] result = internalRhinoObjectArray.ToArray();
            internalRhinoObjectArray.Dispose();
            return result;
        }

But if I do a loop, I’ll have to call every time the GetUserString, which I suppose marshals all communication to the unsafe side.

What do you think?

I’m afraid that’s beyond my programming knowledge, maybe @dale can help you out.

Hi @scudelari,

I’ve logged your wish:

https://mcneel.myjetbrains.com/youtrack/issue/RH-71823

– Dale

1 Like

@dale You are the best, thank you!