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

    Ruby code to extract watermark

    Scheduled Pinned Locked Moved Developers' Forum
    15 Posts 6 Posters 2.6k 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.
    • thomthomT Offline
      thomthom
      last edited by

      There doesn't seem to be any get/set methods for watermarks... 😞

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

      1 Reply Last reply Reply Quote 0
      • A Offline
        Alienizer
        last edited by

        But there is a 'WatermarkManager', perhaps undocumented?

        I'm from Mars and moved to Earth to alienize you. Unfortunately, I became humanized.

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          @alienizer said:

          But there is a 'WatermarkManager', perhaps undocumented?

          Where have you found this?

          I don't find it anywhere in the Ruby API...

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

          1 Reply Last reply Reply Quote 0
          • A Offline
            Alienizer
            last edited by

            @thomthom said:

            Where have you found this?
            I don't find it anywhere in the Ruby API...

            In Sketchup.exe there is the word 'WatermarkManager' (no space) so it must mean something oter than plain English 'Watermark Manager'.

            I'm from Mars and moved to Earth to alienize you. Unfortunately, I became humanized.

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              There might very well be something like that in SketchUp - but not something that's exposed to the Ruby API. 😞 There are some bits and bobs missing.

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

              1 Reply Last reply Reply Quote 0
              • A Offline
                Alienizer
                last edited by

                @thomthom said:

                There might very well be something like that in SketchUp - but not something that's exposed to the Ruby API. 😞 There are some bits and bobs missing.

                Maybe it's just an undocumented api?

                I'm from Mars and moved to Earth to alienize you. Unfortunately, I became humanized.

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  It's not an API if it's not available. I can't find it even in the C++ SDK for reading and writing SketchUp files.

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

                  1 Reply Last reply Reply Quote 0
                  • TIGT Offline
                    TIG Moderator
                    last edited by

                    'WatermarkManager' appears in these filesCapture.PNG

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      Jim
                      last edited by

                      The only solution I see would be to scan the .skp for image header info.

                      See this post for example code.

                      Hi

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        tomasz
                        last edited by

                        @thomthom said:

                        There doesn't seem to be any get/set methods for watermarks... 😞

                        I was hoping I could find something here on the forum on how access watermarks (set at least).
                        I guess it can be done through C Extension... I appreciate a help from Google team.

                        Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by

                          @unknownuser said:

                          @thomthom said:

                          There doesn't seem to be any get/set methods for watermarks... 😞

                          I was hoping I could find something here on the forum on how access watermarks (set at least).
                          I guess it can be done through C Extension... I appreciate a help from Google team.

                          C Extensions can't do anything more than normal Ruby. It still needs to deal with the Ruby API.

                          The C++ SDK might, but that is for reading and writing .skp files - not dealing with the currently open model in SU.

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

                          1 Reply Last reply Reply Quote 0
                          • TIGT Offline
                            TIG Moderator
                            last edited by

                            In the same way that my SKMtools add some missing API functions to let you load a SKM file as a Material, save a Material as a SKM file, or extract SKM images/thumbnails etc, you COULD envisage a similar StyleTools set of additional methods. A '.style' file is only a zip-file with a different suffix - any watermarks are defined in the 'document.xml' under the 'screenimages' section as an individual 'screemimage' with its settings and the required image file is in the 'ref' folder. So if you just want to get a watermark image from a .style file it's straightforward - but getting any info from a loaded Style is fraught... Unfortunately, whilst the making/setting/adding .style parts seem quite possible, access to loaded Style info is very limited - to name and description ! 😕
                            You could envisage a tool that compiles the required parts of a 'zipped' style [images and xml files] into a new .style file that you then load into the SKP using standard API methods...
                            Here's an extract of some watermark xml

                            <span class="syntaxdefault"></span><span class="syntaxkeyword"><</span><span class="syntaxdefault">sty</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">item id</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"5001"</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault">      </span><span class="syntaxkeyword"><</span><span class="syntaxdefault">t</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">variant type</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"13"</span><span class="syntaxdefault"> xmlns</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">n0</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"http://sketchup.google.com/schemas/sketchup/1.0/wmlist"</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword"><</span><span class="syntaxdefault">n0</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">wmlist count</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"2"</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault">          </span><span class="syntaxkeyword"><</span><span class="syntaxdefault">n0</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">screenimages</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault">            </span><span class="syntaxkeyword"><</span><span class="syntaxdefault">n0</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">screenimage name</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"&amp;lt;MODEL SPACE&amp;gt;"</span><span class="syntaxkeyword">/><br /></span><span class="syntaxdefault">            </span><span class="syntaxkeyword"><</span><span class="syntaxdefault">n0</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">screenimage alphaScale</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"0.81"</span><span class="syntaxdefault"> background</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"0"</span><span class="syntaxdefault"> info_filename</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"C;\Aagard\Library\Components\AagardLogo.png"</span><span class="syntaxdefault"> info_found</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"1"</span><span class="syntaxdefault"> info_time</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"0"</span><span class="syntaxdefault"> intensForAlpha</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"0"</span><span class="syntaxdefault"> maintainAR</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"1"</span><span class="syntaxdefault"> name</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"AagardLogo"</span><span class="syntaxdefault"> position</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"2"</span><span class="syntaxdefault"> scale</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"0.12"</span><span class="syntaxdefault"> stretched</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"0"</span><span class="syntaxdefault"> tiled</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"0"</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault">              </span><span class="syntaxkeyword"><</span><span class="syntaxdefault">n0</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">images</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault">                </span><span class="syntaxkeyword"><</span><span class="syntaxdefault">n0</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">image id</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"1"</span><span class="syntaxdefault"> path</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"AagardLogo_1.png"</span><span class="syntaxkeyword">/><br /></span><span class="syntaxdefault">              </span><span class="syntaxkeyword"></</span><span class="syntaxdefault">n0</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">images</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault">            </span><span class="syntaxkeyword"></</span><span class="syntaxdefault">n0</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">screenimage</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault">          </span><span class="syntaxkeyword"></</span><span class="syntaxdefault">n0</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">screenimages</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword"></</span><span class="syntaxdefault">n0</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">wmlist</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault">      </span><span class="syntaxkeyword"></</span><span class="syntaxdefault">t</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">variant</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault">    </span><span class="syntaxkeyword"></</span><span class="syntaxdefault">sty</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">item</span><span class="syntaxkeyword">></span><span class="syntaxdefault"> </span>
                            

                            and the .style file's contents...Capture.PNGCapture1.PNG

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • T Offline
                              tomasz
                              last edited by

                              @thomthom said:

                              C Extensions can't do anything more than normal Ruby. It still needs to deal with the Ruby API.

                              I am aware of it. I thought one could access certain C methods within SU Dll's/internals to set a watermark.

                              Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

                              1 Reply Last reply Reply Quote 0
                              • A Offline
                                Anton_S
                                last edited by

                                You can actually display watermarks.

                                model = Sketchup.active_model opts = model.rendering_options opts['DisplayWatermarks'] = true/false

                                Yep, there is no function to get/set watermark image, though there is actually a way around it.

                                "Watermarks are part of a Style. You would have to have a preset Style with the watermark, and change the Style with the API." - quote by Dan.
                                Create a style or two, add watermarks to each, and set them via Ruby API:
                                styles = Sketchup.active_model.styles styles.selected_style = styles['Style Name'/style index#]

                                Reference: Watermark via Ruby API

                                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