• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Ruby access to styles.

Scheduled Pinned Locked Moved Developers' Forum
8 Posts 4 Posters 359 Views 4 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.
  • A Offline
    Al Hart
    last edited by 20 Feb 2011, 03:16

    Does anyone know if you can create styles in Ruby?

    In particular, I want to use ruby to add a background image to a model.

    Al

    @thomthom said:

    @al hart said:

    (And, of course, I am assuming I can place background image into the current style using ruby. Has anyone tried this already?)

    This is a good question... I'm not really sure how. I wanted to do something with watermarks via ruby a little bit ago - but I couldn't immediately figure out how. And I never got around to investigate further...

    Al Hart

    http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
    IRender nXt from Render Plus

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 20 Feb 2011, 13:05

      The API has no methods to 'create' a Style from scratch http://code.google.com/apis/sketchup/docs/ourdoc/styles.html BUT you can add a style from premade .style files [which could be shipped with your tool[s]], you can then set the desired Style current etc... You simply make your style and export it to a '.style' format within the SKP or directly using the StyleMaker tool...
      You could use a method similar to my SKM-tools to manipulate or create the contents of a new 'style' file 'on-the-fly' and 'add' it... however, there are xml files and a res folder of images, including any background etc. A .style file is only a .zip file with a different suffix... However it is a complex task to read /write the required parts for a .SKM and I think a .STYLE is even more complicated. Adding a premade one is MUCH easier πŸ˜’

      TIG

      1 Reply Last reply Reply Quote 0
      • A Offline
        Al Hart
        last edited by 20 Feb 2011, 14:31

        Thanks TIG.

        I think that is the hint I was looking for.

        I may be able to create a style with a background image, and then modify the background image and the .XML referring to it as a "ZIP" file and the reload the altered style..

        
        <n0;screenimages>
                    <n0;screenimage alphaScale="1" background="1" info_filename="C;\docs\blue sky sailboat.jpg" info_found="13" info_time="0" intensForAlpha="0" maintainAR="1" name="Watermark1" position="4" scale="0.3826606875934" stretched="1" tiled="0">
                      <n0;images>
        
        

        I don't see any way for to save the current style from ruby, (Perhaps someone has found a send_action code to do that, or it can be reversed engineered somehow.) So to create a ruby to alter the background of the current style, the user may have to save the style somewhere.

        But at least this gives me some hope.

        Al Hart

        http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
        IRender nXt from Render Plus

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 20 Feb 2011, 15:00

          There is no API way to save a loaded Style externally.
          I managed to make a new 'material.export_SKM(folder)' method that constructs the required SKM file from bits constructed from all of the material's properties/texture etc accessed through the API, BUT that is possible because you can at least access those with the API - you can't get a fraction of the info you need from a loaded Style through the API to try and make the parts to assemble into the required .style file πŸ˜’
          There are no send_actions that would help either... 😞

          TIG

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 21 Feb 2011, 04:58

            @al hart said:

            I don't see any way for to save the current style from ruby, (Perhaps someone has found a send_action code to do that, or it can be reversed engineered somehow.)

            Are you consinering a cross-platform plugin, or PC only ??

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • A Offline
              Al Hart
              last edited by 21 Feb 2011, 06:00

              @dan rathbun said:

              Are you considering a cross-platform plugin, or PC only ??

              PC only at first.

              We want to write a routine to take a 360 degree spherical panoramic HDRi image and convert to a background image to match the current SketchUp screen size and perspective camera view.

              We can just make the image available to the SketchUp user to place as a background image. However, if the user can give us the name of a saved style, we would like to update and reload the style automatically, so that when the view is changed it will just take one click (or perhaps an "observer") to update the background image.

              Al Hart

              http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
              IRender nXt from Render Plus

              1 Reply Last reply Reply Quote 0
              • D Offline
                Dan Rathbun
                last edited by 21 Feb 2011, 09:01

                @al hart said:

                We want to write a routine to take a 360 degree spherical panoramic HDRi image ...

                These HDRi images are spherical? or cylindrical?

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • T Offline
                  thomthom
                  last edited by 21 Feb 2011, 10:11

                  @dan rathbun said:

                  @al hart said:

                  We want to write a routine to take a 360 degree spherical panoramic HDRi image ...

                  These HDRi images are spherical? or cylindrical?

                  Environment maps can be in many shapes - even cubical. HDRI image aren't always environment images.

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

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

                  Advertisement