Hiding/Showing items from ObjectTable

Hi there,

a quick question that might acutally be easy to solve…

I want to hide certain objects in a Rhinofile.
The frist time I do that, it works perfectly fine by using
Rhino.RhinoDoc.ActiveDoc.Objects.Hide(obj.Id, true)

If then I want to show them again and hide other objects it simply does not work, everything that got hidden stays hidden.

What am I missing?


HI @tobias.stoltmann,
What code are you using to show objects? Is it Rhino.RhinoDoc.ActiveDoc.Objects.Show(obj.Id,true)?

@Darryl_Menezes, yes.

Could you post the full code?

@Darryl_Menezes of course.

var objects = Rhino.RhinoDoc.ActiveDoc.Objects

//targets will be a list that contains the Ids that I want to display...
foreach (var obj in objects)
    if (this.targets.Contains(obj.Id.ToString()))
        Rhino.RhinoDoc.ActiveDoc.Objects.Show(obj.Id, true);
        Rhino.RhinoDoc.ActiveDoc.Objects.Hide(obj.Id, true);

When you iterate through Rhino.RhinoDoc.ActiveDoc.Objects, I believe you only get the objects whose “IsNormal” property is true, or they are not Document Controlled.

Instead of using foreach loop on “objects”, you could do it on your targets. If your “targets” is a list of string,

foreach(string strId in targets)
    Guid objectID = Guid.Parse(strId);
    Rhino.RhinoDoc.ActiveDoc.Objects.Show(objectID, true);
1 Like

@Darryl_Menezes, I see.
But what if I want to show all the objects that have been hidden before?
Or what would I do with all the items that should now be hidden?

You could maintain seperate lists in your plugin, like list of objects you want to hide, list of objects you hid using your plugin. This is in case you only want to show the hidden objects that were hidden by your plugin, and not by anything else.

If you want to show every hidden object in your document, you could do something like this,

var hiddenObjects = doc.Objects.GetObjectList(new ObjectEnumeratorSettings() { HiddenObjects = true }).ToList();

foreach (var obj in hiddenObjects)
    doc.Objects.Show(obj.Id, true);
1 Like

so this means if I want to get Ids out of let’s say a list of blocks, I would first get the Ids out of ObjectTable.GetObjectList and chose InstanceObject there.

Then I’d check all the items in doc.Objects.GetObjectList(new ObjectEnumeratorSettings() for visible and invisible objects.

And then I’d apply the loop on the list of Ids?

I will check and let you know :slight_smile:

Thats one way to do it, yes

Working perfectly fine, @Darryl_Menezes.
Thanks a lot!