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

    Need some help with write_image

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 350 Views 3 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.
    • jeff hammondJ Offline
      jeff hammond
      last edited by

      hey guys

      i'm trying to do a 2D export via ruby.. i've looked at this:

      https://developers.google.com/sketchup/docs/ourdoc/view#write_image

      so far, i've tried this:

      view = model.active_view status = view.write_image "test.png" keys = { :filename => "~/desktop/write_image.png", :width => 640, :height => 480, :antialias => false, :compression => 0.9, :transparent => true } model = Sketchup.active_model view = model.active_view view.write_image keys

      …and it returns 'false'..

      not sure what i need to change in order to get the image to write..
      any assistance will be greatly appreciated
      thanks

      dotdotdot

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

        Try
        model = Sketchup.active_model view = model.active_view keys = { :filename => "~/desktop/write_image.png", :width => 640, :height => 480, :antialias => false, :compression => 0.9, :transparent => true } view.write_image(keys)
        Jumbled code from the API - typically confusing 😒
        If it fails then try giving the FULL path for the filename [without the '~']...
        I'm not sure how a MAC deals with 'relative' / 'user' paths...
        On a PC ENV['USERPROFILE'] gives the user's path; onto which you can append 'Desktop'...
        The MAC will have something similar...

        TIG

        1 Reply Last reply Reply Quote 0
        • jeff hammondJ Offline
          jeff hammond
          last edited by

          ok.. that worked.. i tried a few variations on the path and finally got:

          /Users/jeff/Desktop/write_image.png

          to work..

          (whereas Macintosh HD/Users/jeff/Desktop/write_image.png ,which is the full path, fails ?? )

          i know with applescript, i can use the tilde in there as a relative path to the user.. i'll just poke around some more and see what i come up with for relative paths in ruby on mac..

          thanks a bunch!

          dotdotdot

          1 Reply Last reply Reply Quote 0
          • jeff hammondJ Offline
            jeff hammond
            last edited by

            oh.. btw.

            what i'd really like to do, in this particular scenario, is to write the image to my clipboard instead of creating a file somewhere ..
            so, if anyone know of a way to do that, please tell..
            thanks

            dotdotdot

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

              I would know how to do it for Windows, using the Win32API - but I don't know what you can use on OSX. 😞

              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

                @unknownuser said:

                oh.. btw.

                what i'd really like to do, in this particular scenario, is to write the image to my clipboard instead of creating a file somewhere ..
                so, if anyone know of a way to do that, please tell..
                thanks
                I think you'll need to at least make a temporary file and use some as/terminal/shell stuff ...
                osascript -e "tell app \"Finder\" to set the clipboard to (POSIX file \"~Documents/mytemp.png\")"
                😕 perhaps

                TIG

                1 Reply Last reply Reply Quote 0
                • jeff hammondJ Offline
                  jeff hammond
                  last edited by

                  @tig said:

                  I think you'll need to at least make a temporary file and use some as/terminal/shell stuff ...
                  osascript -e "tell app \"Finder\" to set the clipboard to (POSIX file \"~Documents/mytemp.png\")"
                  😕 perhaps

                  i think something like that could work.. i found a way to do it with straight applescript (still using a temp file location) which eliminates using Finder..

                  set the clipboard to (read ("path/to/the/image.png") as «class PNGf»)

                  dotdotdot

                  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