there are ways to ‘crop’ the image on a mac, but why do you only want part of a webdialog window?
the easiest is to do this first
orig_size = ( 200,400 ) # orig_size is whatever you started with
webdialog.set_size( 100, 100)
webdialog.write_image( filenam ) # filenam should already be a string
webdialog.set_size( orig_size )
[@tt I knew it was somewhere… this link][1]
it’s the docs that are wrong, you need more args…
I would express them as dlg.write_image(filepath , quality, left_margin, new_width, top_margin, new_height)
I have a working script that demonstrates cropping dlg1 image to make dlg2 with cropped.
[1]: How to Use Graphing Gem in SketchUp Plugin • sketchUcation • 1
The problem goes beyond just the docs (which are indeed wrong). The API does not behave sensibly when you pass the wrong number of arguments. In Denis’ example, per John’s reference the interpretation of the arguments should be
Since Ruby does not raise a wrong number of arguments exception, I must assume that the API treats the arguments as optional. But what sort of strange defaulting logic transmutes (0,100)->(100, missing) to full screen?
This is another case where the API should have returned a usable error or raised an exception and did not.
Right - that jogs my memory. I see in the source that quality should be there. I’m going to bump this issue to have the docs updated.
But you shuffled the remaining of the arguments. it’s top_left_x, top_left_y, bottom_right_x, bottom_right_y.
Correct.
This is the type of method where we should have been accepting an option hash instead. As the quality argument doesn’t always apply, and certainly not as a requirement if you want to crop part of the image.
cheers @tt_su.
I had seen that, and your comment above re: my order being wrong, but for my mind, if I think more like css dlg.write_image(filepath , quality, left, top, left + width, top + height) it actually works…
edited when i realised i was still cocking it up…
john
Sketchup lets you pass in 3, 4 or 5 arguments but ignores them.
On a pc you can pass in 4 different file formats along with the file name
bmp jpg png tif
quality works with jpg only and is a number between 0.0 and 100.0
0.0 is maximum compression and 100.0 is no compression