sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Questions on Styles and Rendering options

    Scheduled Pinned Locked Moved Developers' Forum
    12 Posts 6 Posters 741 Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • fredo6F Offline
      fredo6
      last edited by

      thomthom,

      Thanks for raising the point within Trimble.

      But do you know what is the difference between active_style and selected_style?

      Fredo

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        I have played around with styles, rendering options and shadow option in a couple of plugins

        but I could never work that one out...

        styles = Sketchup.active_model.styles
        
        p styles.selected_style == styles.active_style # => false
        
        p styles.selected_style.name == styles.active_style.name  # => true
        

        and

        
        p [styles.selected_style, styles.active_style]
        # => [#<Sketchup;;Style;0x007ff13ba9a590>, #<Sketchup;;Style;0x007ff13975fb20>]
        
        p [styles.selected_style.name, styles.active_style.name]
        # => ["[Default Style]", "[Default Style]"]
        

        I'll see if I can find my revert style code...

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 Reply Last reply Reply Quote 0
        • D Offline
          driven
          last edited by

          finally found the bit I was after...
          I grab the active style and collect the missing values...

                  styles = Sketchup.active_model.styles
                  @count = styles.count
                  sty = styles.active_style
                  @revert = 0
                  @i = 0
                  styles.map{|s| @i = @i+1
                                 @revert =  @i-1 if s.name == sty.name
                            }
          
                  # collect items not covered by Style options...
                  sun4 = Sketchup.active_model.shadow_info["UseSunForAllShading"]
                  shad = Sketchup.active_model.shadow_info["DisplayShadows"]
                  dark = Sketchup.active_model.shadow_info["Dark"]
                  light = Sketchup.active_model.shadow_info["Light"]
                  faces = Sketchup.active_model.shadow_info["DisplayOnGroundPlane"]
                  ground = Sketchup.active_model.shadow_info["DisplayOnAllFaces"]
          

          then at the end of my async loop that changes styles and makes an image I use

                          styles.selected_style = styles[@revert]
                          Sketchup.active_model.shadow_info["UseSunForAllShading"] = sun4
                          Sketchup.active_model.shadow_info["DisplayShadows"] = shad
                          Sketchup.active_model.shadow_info["Dark"] = dark
                          Sketchup.active_model.shadow_info["Light"] = light
                          Sketchup.active_model.shadow_info["DisplayOnGroundPlane"] = ground
                          Sketchup.active_model.shadow_info["DisplayOnAllFaces"] = faces
          

          to put it back as it was...

          learn from the mistakes of others, you may not live long enough to make them all yourself...

          1 Reply Last reply Reply Quote 0
          • D Offline
            driven
            last edited by

            @dan
            what's not working?

             model = Sketchup.active_model
             pages = model.pages
             page = pages[0]
             rendering_settings = page.rendering_options.to_a
            

            returns the full enchilada...
            and shadow info appears to work on page as well...

             shadow_settings = page.shadow_info.to_a
            

            can you post a failing snippet I can test on my mac?

            john

            learn from the mistakes of others, you may not live long enough to make them all yourself...

            1 Reply Last reply Reply Quote 0
            • fredo6F Offline
              fredo6
              last edited by

              @driven
              Thanks for your samples. It would seem that the Active Style is a structure to hold the current options set interactively (and normally in rendering_options and Shadow_info), whereas the Selected Style only corresponds to styles stored in the model and coming from files. But as the API to styles is very poor, there is little chance that anything useful can be done.

              @Dan
              Page.rendering_options seems to work OK in SU15, even if it does not map all the parameters of styles.

              Fredo

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                I am going from memory. This was several versions back, may have been while Google still owned SketchUp.

                What I was trying to do was SET rendering options/styles that were unique to each page.

                I was told (if I remember correctly) is that since Styles were invented, you have to use style files.

                I responded that (generalizing) this was cumbersome if I only wished to change a few options on each page.

                @fredo6 said:

                page.rendering_options seems to work OK in SU15...

                It did for me, also in that older version. But setting things (different than the model settings,) and having them remembered seems to be the issue.

                Notice how in the Scene Manager, there is no checkbox for "rendering options"

                Setting the page.use_rendering_options=true has no effect.


                For the shadow_info, there an additional flag that must be set true, to make the changes remembered.
                page.use_shadow_info= true page.update

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  I asked someone on the SketchUp development team last year (I think, could have been before,) about the page.rendering_options not working.

                  They said it was replaced with styles when styles were invented. And that the API docs were erroneous with respect to setting rendering options on pages. (It should say that they do not work when attempting to make settings on pages.)

                  To which I responded that made no sense, as nothing much of the Style class had been exposed. Why would take away API functionality? And the response was something vague, about future plans that never happened.

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • tt_suT Offline
                    tt_su
                    last edited by

                    Sorry Fredo for the late reply. I just looked up the source for this. Though it looks like you deduced this yourself, here's confirming it:

                    selected_style refer to the style selected in the Style browser. However, the user might have modified that style after selecting it. So it's properties doesn't reflect what's being used in the viewport.

                    active_style refer to the "working" style.

                    The API interface is a reflection off the underlying system. But it's certainly awkward. Better documentation and examples are needed. And I guess there is a need for some new API methods.

                    1 Reply Last reply Reply Quote 0
                    • fredo6F Offline
                      fredo6
                      last edited by

                      thomthom,

                      thsanks very much.

                      So active_style is finally not useful, as we cannot do anything with it.

                      Fredio

                      1 Reply Last reply Reply Quote 0
                      • CadFatherC Offline
                        CadFather
                        last edited by

                        api definitely needs some development here, you cannot even do a style.erase command. (just purge)

                        i looked inside a *.style file (aka zip), hoping to find some hints. some obscure numbers which surely must be pointing to the settings like face colours etc, but too cryptic.

                        not to mention watermarks.

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement