# Layer/Tag LAYER\_HIDDEN\_BY\_DEFAULT not working

**URL:** <https://forums.sketchup.com/t/layer-tag-layer-hidden-by-default-not-working/121203>\
**Category:** Ruby API\
**Tags:** hidden, layers\
**Created:** [April 7, 2020, 1:26pm UTC](https://forums.sketchup.com/t/layer-tag-layer-hidden-by-default-not-working/121203 "2020-04-07T13:26:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PhilippR](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@PhilippR](https://forums.sketchup.com/u/PhilippR)\
**Post date:** [April 7, 2020, 1:26pm UTC](https://forums.sketchup.com/t/layer-tag-layer-hidden-by-default-not-working/121203/1 "2020-04-07T13:26:09Z")

</div>

Hi  
In my SketchUp extension I create a layer/tag which should be hidden or set to invisible by default. This has and still works in earlier SketchUp versions (for example in SketchUp 2017), but not in SketchUp 2020.  
In SketchUp 2020 the layer/tag is set to visible after the extension created it.

Example code:  
`box_layer.page_behavior=(LAYER_HIDDEN_BY_DEFAULT | LAYER_IS_HIDDEN_ON_NEW_PAGES)`

I looked in the API doc; there are no changes on this.

Is this a bug?

Greets Philipp

---

<div class="post-metadata">

**Author:** ![eneroth3](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/eneroth3/32/1222_2.png) [@eneroth3](https://forums.sketchup.com/u/eneroth3)\
**Post date:** [April 7, 2020, 1:29pm UTC](https://forums.sketchup.com/t/layer-tag-layer-hidden-by-default-not-working/121203/2 "2020-04-07T13:29:08Z")

</div>

Sounds like a bug to me.

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [April 7, 2020, 11:07pm UTC](https://forums.sketchup.com/t/layer-tag-layer-hidden-by-default-not-working/121203/3 "2020-04-07T23:07:20Z")

</div>

> [@PhilippR](#):
>
> In my SketchUp extension I create a layer/tag which should be hidden or set to invisible by default.  
> …  
> In SketchUp 2020 the layer/tag is set to visible after the extension created it.

Yes I see this also. **But** it just a momentary glitch.

If you **manually** switch scenes and back again you’ll see the correct settings are applied across the scene page collection.

Testing shows that using code to set the selected page **to itself** triggers a scene view refresh as if the model was switched to another scene and then back again. This is fortuitous as the user will not see and ugly scene change. Ex …

```ruby
pages = Sketchup.active_model.pages
pages.selected_page= pages.selected_page

```

I know it’s not intuitive (from the docs) but it works.

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [April 7, 2020, 11:22pm UTC](https://forums.sketchup.com/t/layer-tag-layer-hidden-by-default-not-working/121203/4 "2020-04-07T23:22:27Z")

</div>

And I logged an issue for this …

> <https://github.com/SketchUp/api-issue-tracker/issues/457>
>
> \### SketchUp Ruby API Issue
> 
> \#### \*\*New Layer/Tag do not immediately follow se…t behavior when added via Ruby API\*\*.
> 
> Reported bug in: 20.0.363, also in 18.0.16975
> 
> Reportedly works as expected in SU2017, \*\*but testing shows\*\* the bug is also present in version 17.2.2555 and 16.1.1449.
> 
> Creating a new layer/tag and setting it's scene page behavior does not immediately get applied by \[\`Sketchup::Layer#page\_behavior=\`\](https://ruby.sketchup.com/Sketchup/Layer.html#page\_behavior=-instance\_method) method.
> 
> \`\`\`ruby
> layer = Sketchup.active\_model.layers.add("Test")
> layer.page\_behavior=(LAYER\_HIDDEN\_BY\_DEFAULT | LAYER\_IS\_HIDDEN\_ON\_NEW\_PAGES)
> \`\`\`
> Either a manual change of scene page and back again is required to have the layer be correctly applied across the scene pages collection, ... or a undocumented Ruby "trick" that causes SketchUp to refresh the scene layer/tag behaviors by setting the selected page to itself ...
> 
> \`\`\`ruby
> pages = Sketchup.active\_model.pages
> pages.selected\_page= pages.selected\_page
> \`\`\`
> 
> \_REF Forum topic:\_ 
> https://forums.sketchup.com/t/layer-tag-layer-hidden-by-default-not-working/121203/

* * *

> [@PhilippR](#):
>
> This has and still works in earlier SketchUp versions (for example in SketchUp 2017), but not in SketchUp 2020.

Note that I tested (on Windows platform) and this bug is present in …

- 20.0.363
- 18.0.16975
- 17.2.2555
- 16.1.1449

… so it is an **old** bug.
