SketchUp / api-issue-tracker

Public issue tracker for the SketchUp and LayOut's APIs
https://developer.sketchup.com/
39 stars 10 forks source link

New Layer/Tag do not immediately follow set behavior when added via Ruby API #457

Open DanRathbun opened 4 years ago

DanRathbun commented 4 years ago

SketchUp Ruby API Issue

New Layer/Tag do not immediately follow set 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= method.

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 ...

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/

thomthom commented 4 years ago

So changing the layer's page_behaviour doesn't update the viewport (entity visibility) based on the current scene (page)?

DanRathbun commented 4 years ago

So changing the layer's page_behaviour doesn't update the viewport (entity visibility) based on the current scene (page)?

Please be careful in dialogue here. We are taking about the layer visibility property not direct object visibility which is a separate feature saved by scene pages.

The layer's visibility state (as shown in the Layer inspector) is not updated to reflect the change in behavior, ... so yes ANY entity or object using this layer is still visible.

AND ... I am assuming that none of the other scene pages have been updated as well, until a change of scene page is made (manually, in code or triggered using the "trick" I show above.)


I am wondering if explicitly setting ...

pages.selected_page.use_hidden_layers= true

... must be called before the change in behavior statement ?

TESTED. Result = no help. Same problem.

sketchupbot commented 4 years ago

SU-45930