• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

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.
  • F Offline
    fredo6
    last edited by 2 May 2015, 15:24

    I am a little bit lost with this, at least on 2 points

    1. What is the model.styles.active_style?
      Is it a way to save the current style information to replay it later?
      What is the difference with styles.selected_style?
      For sure, if the following statement create an immediate bug plat. Don't know if this is a bug or a misunderstanding of the difference
    
    style_active = styles.active_style
    styles.selected_style = style.active
    
    
    1. The model or page rendering options des not include ALL information on styles.

    At least I found that is a scene is formatted with the style "Brush Stroke Wide", the model.rendering_options or page.rendering_options does not contain all information necessary to replay the same rendering as the style from the Ruby API.

    The API documentation is very elusive, in general, and in particular on styles and rendering options.

    Thanks for your thoughts

    Fredo

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 2 May 2015, 16:38

      @fredo6 said:

      For sure, if the following statement create an immediate bug plat. Don't know if this is a bug or a misunderstanding of the difference

      
      > style_active = styles.active_style
      > styles.selected_style = style.active
      > 
      

      Anything causing a crash is to be considered a bug.

      For the record, the complete snippet to reproduce the crash with all variables defined and without typo is:

      
      styles = Sketchup.active_model.styles
      style_active = styles.active_style
      styles.selected_style = style_active
      
      

      Fredo, I'll look at this on Monday. I was just skimming the forum right now.

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • F Offline
        fredo6
        last edited by 2 May 2015, 16:55

        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 2 May 2015, 17:13

          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 2 May 2015, 17:59

            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 2 May 2015, 18:58

              @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
              • F Offline
                fredo6
                last edited by 2 May 2015, 19:32

                @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 3 May 2015, 23:44

                  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 4 May 2015, 02:40

                    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 8 May 2015, 12:40

                      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
                      • F Offline
                        fredo6
                        last edited by 10 May 2015, 11:18

                        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 19 May 2015, 09:29

                          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