Hiding definition in Components window

I seem to remember reading about a DC attribute that we can attach to a Component Definition to hide it in the Components window. But after an extensive search both here and on Google, I can’t find anything.

Did I dream it? Maybe I’m just mixing things up with the definition.hidden?

1 Like

Yea, there is something that was added for Dynamic Components:

  // A Dynamic component can set a _hideinbrowser attribute == true
  // to keep a definition fron showing in the Component Browser.
```ruby
definition.set_attribute('dynamic_attributes', '_hideinbrowser', true)

(Note that this is something of an internal implementation detail. But it sounds reasonable to me if the API had an official method to do this.)

On that topic I just realized we have internal? and hidden? for definitions. And it wasn’t clear to me what they meant.


hidden?

The hidden method is used to determine if this component definition should be hidden on the component browser.

The source code comment says:

  // A component is "hidden" if all of its instances are within
  // other external component definitions.  Conversely a component
  // is "visible" if it has no instances, or has any instances
  // within the model or within any internal component definitions.
  // Note that we use "GetHidden" to differentiate this from the
  // method on CDrawingElement.

This method checks if the definition has zero instances and that all its instances are within another definition. It also checks if the definition is “internal”.


internal?

The internal? method is used to determine if the component definition is internal to the Component Browser

The source code returns true if the “loaded from path” is empty.

3 Likes

Thanks thomthom, that’s it!

I did know about .hidden? and .internal? but that was not what I was looking for.

Can you add this as issue(s) to add to the docstrings of those API method, please.

Also think the indenting went haywire above, a bit confused about what statements go with what.
Horizontal lines might help.