SketchUcation Premium Membership

 

 

Ruby code to extract watermark

Ruby code to extract watermark

Postby Alienizer » Fri Jun 03, 2011 2:19 am

Does anyone know how how to get the watermark image in the ruby console? The API shows how to get the active_style and such, but no reference to the watermark!

Thanks for any advice you can provide.
I'm from Mars and moved to Earth to alienize you. Unfortunately, I became humanized.
Alienizer
 
Posts: 120
Joined: Thu Mar 26, 2009 9:02 pm
Name: Alan

Re: Ruby code to extract watermark

Postby thomthom » Fri Jun 03, 2011 7:20 am

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
User avatar
thomthom
Global Moderator
 
Posts: 17545
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: Ruby code to extract watermark

Postby Alienizer » Fri Jun 03, 2011 3:57 pm

But there is a 'WatermarkManager', perhaps undocumented?
I'm from Mars and moved to Earth to alienize you. Unfortunately, I became humanized.
Alienizer
 
Posts: 120
Joined: Thu Mar 26, 2009 9:02 pm
Name: Alan

Re: Ruby code to extract watermark

Postby thomthom » Fri Jun 03, 2011 3:58 pm

Alienizer wrote: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
User avatar
thomthom
Global Moderator
 
Posts: 17545
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: Ruby code to extract watermark

Postby Alienizer » Fri Jun 03, 2011 4:57 pm

thomthom wrote: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.
Alienizer
 
Posts: 120
Joined: Thu Mar 26, 2009 9:02 pm
Name: Alan

Re: Ruby code to extract watermark

Postby thomthom » Sat Jun 04, 2011 1:07 am

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
User avatar
thomthom
Global Moderator
 
Posts: 17545
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: Ruby code to extract watermark

Postby Alienizer » Sat Jun 04, 2011 5:19 am

thomthom wrote: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.
Alienizer
 
Posts: 120
Joined: Thu Mar 26, 2009 9:02 pm
Name: Alan

Re: Ruby code to extract watermark

Postby thomthom » Sat Jun 04, 2011 10:50 am

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
User avatar
thomthom
Global Moderator
 
Posts: 17545
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: Ruby code to extract watermark

Postby TIG » Sat Jun 04, 2011 1:14 pm

'WatermarkManager' appears in these files
Capture.PNG
Please, register (free) to access all the attachments on the forums.
TIG
User avatar
TIG
Global Moderator
 
Posts: 13903
Joined: Mon Nov 12, 2007 7:24 pm
Location: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: Ruby code to extract watermark

Postby Jim » Sat Jun 04, 2011 2:05 pm

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

See this post for example code.
Jim
Global Moderator
 
Posts: 4126
Joined: Mon Nov 12, 2007 10:13 pm
Location: NEOH
Name: Jim
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: other
Level of SketchUp: Intermediate

Re: Ruby code to extract watermark

Postby tomasz » Fri Sep 16, 2011 10:21 am

thomthom wrote: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.
tomasz
SU2TH & SU2KT Developer
 
Posts: 768
Joined: Fri Nov 16, 2007 8:46 pm
Location: Poland
Name: Tomasz
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: Ruby code to extract watermark

Postby thomthom » Fri Sep 16, 2011 10:29 am

Tomasz wrote:
thomthom wrote: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
User avatar
thomthom
Global Moderator
 
Posts: 17545
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: Ruby code to extract watermark

Postby TIG » Fri Sep 16, 2011 10:56 am

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
Code: Select all
<sty:item id="5001">
      <t:variant type="13" xmlns:n0="http://sketchup.google.com/schemas/sketchup/1.0/wmlist">
        <n0:wmlist count="2">
          <n0:screenimages>
            <n0:screenimage name="&amp;lt;MODEL SPACE&amp;gt;"/>
            <n0:screenimage alphaScale="0.81" background="0" info_filename="C:\Aagard\Library\Components\AagardLogo.png" info_found="1" info_time="0" intensForAlpha="0" maintainAR="1" name="AagardLogo" position="2" scale="0.12" stretched="0" tiled="0">
              <n0:images>
                <n0:image id="1" path="AagardLogo_1.png"/>
              </n0:images>
            </n0:screenimage>
          </n0:screenimages>
        </n0:wmlist>
      </t:variant>
    </sty:item> 
and the .style file's contents...
Capture.PNG
Capture1.PNG
Please, register (free) to access all the attachments on the forums.
TIG
User avatar
TIG
Global Moderator
 
Posts: 13903
Joined: Mon Nov 12, 2007 7:24 pm
Location: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: Ruby code to extract watermark

Postby tomasz » Mon Sep 19, 2011 12:56 pm

thomthom wrote: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.
tomasz
SU2TH & SU2KT Developer
 
Posts: 768
Joined: Fri Nov 16, 2007 8:46 pm
Location: Poland
Name: Tomasz
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: Ruby code to extract watermark

Postby Anton_S » Wed May 30, 2012 1:30 am

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
Anton_S
 
Posts: 205
Joined: Tue Nov 23, 2010 9:15 pm
Location: Salem Oregon US
Name: AntonSynytsia
Operating system: Windows
SketchUp version: 8
License type: Free
SketchUp use: hobby
Level of SketchUp: Intermediate

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago

Are you a Premium Member? Get your freebies here. Are you not a Premium Member yet? Upgrade your account to grab these freebies instantly.

Ad Machine
Robot
 
Posts: 2012



 

Return to Developers' Forum

Who is online

Users browsing this forum: francescole and 7 guests