GetObject custom object

Hey I have a question regarding GetObject for Rhinocommons custom Objects.

I’m writing a plugin where I’m adding custom objects to the doc. I want the user to be able to run commands on those objects so I need to build a GetObject function.

My approach for my CustomCurveObject class is using getObject with geometryfilter set to curve extracting the guids of the selected objects and then iterating over the result of document.objects.GetObjectsByType comparing the guids.

This is inefficient and feels more like a hack then a true solution. Can I setup a custom geometryfilter to allow only certain types to be selected?

Also part of the reason for my approach is that I want to run class Methods of MyCustomCurveObject so the result of getObject needs to be of type MyCustomCurveObject.

Any hints on how to do this the right way would be greatly appreciated as my ‘solution’ can’t be the recommended way. Thanks in advance

You should be able to call SetCustomGeometryFilter on your GetObject class with a delegate that checks to see if the object is one of your custom objects. Something like

var go = new GetObject();
go.SetCustomGeometryFilter((obj,geom,ci)=>{return obj is MyCustomObject;});
1 Like

Wow thanks for the quick reply will try your recommendation immediately.

EDIT: Works like a charme thanks alot!