Need some help with write_image
-
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 -
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 thefilename[without the '~']...
I'm not sure how a MAC deals with 'relative' / 'user' paths...
On a PCENV['USERPROFILE']gives the user's path; onto which you can append 'Desktop'...
The MAC will have something similar... -
ok.. that worked.. i tried a few variations on the path and finally got:
/Users/jeff/Desktop/write_image.pngto 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!
-
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 would know how to do it for Windows, using the Win32API - but I don't know what you can use on OSX.

-
@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 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\")"
perhapsi 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»)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement