NorthAngle overwritten in page.shadow_info?

When creating a new page, it seems to save the model.shadow_info[“NorthAngle”] in the page.shadow_info[“NorthAngle”], as expected. However, when I click on the scene in SketchUp, the NorthAngle for the page get’s overwritten with whatever the current NorthAngle is for the model.

Ruby to reproduce (from a new model):

> m=Sketchup.active_model
#<Sketchup::Model:0x00007f96cddd6ab0>
> m.shadow_info["NorthAngle"]
0.0
> m.shadow_info["NorthAngle"] = 90
90
> m.pages.add("pg1")
#<Sketchup::Page:0x00007f96cddd4be8>
> m.pages.each{|pg| puts pg.shadow_info["NorthAngle"] }
90.00000000000003
> m.shadow_info["NorthAngle"] = 180
180
> m.pages.add("pg2")
#<Sketchup::Page:0x00007f96cddcedb0>
> m.pages.each{|pg| puts pg.shadow_info["NorthAngle"] }
90.00000000000003
180.00000000000006
# This looks correct, but when I click on pg1, I get..
> m.pages.each{|pg| puts pg.shadow_info["NorthAngle"] }
180.0000000000001
180.00000000000006
#Click back on pg2 and no change
> m.pages.each{|pg| puts pg.shadow_info["NorthAngle"] }
180.0000000000001
180.00000000000006

From here I can change m.shadow_info[“NorthAngle”] to something else like 270, and click on both scenes and then the above line will show 270 for each scene I’ve clicked on.

I’ve seen this in SU going back to 2016, so it’s not new behavior. Is this by design for the NorthAngle? For what it’s worth, it doesn’t seem to matter if the Solar North extension is installed or not.

This came up trying to create Elevation scenes and I was using the NorthAngle to get perfect shadows coming down to the bottom-right from any direction, but it looks like that NorthAngle wasn’t getting saved in the scene after changing scenes. Naturally, I would have Elevations from different directions and want different NorthAngles for each scene since these aren’t ‘real’ shadows, just there for aesthetics.

Is there another setting that has to be enabled for this property to be saved/honored on a per-page basis?

1 Like

I think I remember this also. Basically the ShadowInfo hash is a model level options object. The model does not have a ShadowInfos collection of multiple ShadowInfo hash objects that can be assigned variously to different scenes (like Styles can.) [EDIT: Perhaps not true as noted below.]

(Idea of using a FrameChangeObserver, ... probably does not apply here.) ...

So your plugin will may have to save the NorthAngle to an attribute dictionary, and use a FrameChangeObserver to detect a transiston to each scene and then set the NorthAngle according to your saved attributes. [EDIT: But maybe not.]

I don’t think so, other than the scene pages update method.

EDIT: Hold on a minute … The API docs seem to indicate that each scene page object can save it’s own ShadowInfo hash object (as you’ve used in your code example reading the NorthAngle.)

However you do not appear to be changing the scene page object’s ShadowInfo hash, instead you are changing the model’s ShadowInfo hash each time. AND … you are not calling page.update after making changes.

Scenes do not save north angles (and if they do it’s a leftover from an earlier behavior and isn’t actually used). This could be useful for e.g. interior views of spaces with windows facing north, but still would just be a workaround. What we really need is a way to set the sun direction to any arbitrary value, without affecting the model geo location (and more clarity in how these things are intended to function).

Hi Dan, thanks for the quick response!

This behavior of the NorthAngle seems specific to that property. If I repeat the process with another shadow_info key like ‘Light’, it works as expected:

> m=Sketchup.active_model
#<Sketchup::Model:0x00007f8a56397b68>
> m.shadow_info["Light"]
80
> m.shadow_info["Light"] = 75
75
> m.pages.add("pg1")
#<Sketchup::Page:0x00007f8a56d1d6d8>
> m.shadow_info["Light"] = 65
65
> m.pages.add("pg2")
#<Sketchup::Page:0x00007f8a56d1cfd0>
> m.pages.each {|pg| puts pg.shadow_info["Light"]}
75
65
#This is as expected, and when I click on pg1, I get:
> m.pages.each {|pg| puts pg.shadow_info["Light"]}
75
65
# Changing back to pg2 also keeps the same values.
> m.pages.each {|pg| puts pg.shadow_info["Light"]}
75
65

Generally, we only have to call page.update if we change the model-level information and want the new/current model data to be saved into the page. When the page is created via pages.add, the current state of the model, camera, shadow_info, etc is captured into the page. As shown it captures the NorthAngle too, but when clicking on the page, the model value overwrites the page value just for NorthAngle, otherwise the per-page values are kept.

Yes, I can use the FrameChangeObserver and that should work for changing scenes in SU, but when they’re viewed in LO, the observer won’t run and the views in LO will have the wrong shadows.

Hi eneroth3,

Got it. So this behavior is ‘by design’, and the NorthAngle is really a model-level property, not a per-shadow_info (and by extension a per-page) property.

Scenes will save North Angle if transitions are turned off.
north

1 Like

@DaveR the savior!

Yep that seems to be it! When the transitions are disabled, it doesn’t overwrite the per-scene NorthAngle. I confirmed with my original test with scene transitions disabled and the NorthAngle is saved/honored.

Thanks!

Edit: As a bonus, I can control this on a per-scene basis by setting the page.transition_time = 0, even better!

2 Likes

Yup. When you think of it it makes sense. The model position on earth is static (well, you could be modeling a boat or other mobile object I guess, but that’s not how SketchUp sees it).

Maybe it used to be per scene before the Google days. Having this property in the ShadowInfo object suggests that.

This sounds like a bug to me. I wouldn’t build a workflow around it.

Someone else just reported an funny issue that happens only when scene transitions is on. But I can’t find it.