Insert image as Picture Frame error


#1

I have used these scripts in the past. I am now getting an error with System.Drawing, possibly.

Code:

import rhinoscriptsyntax as rs
import System.Drawing as SD

filter = "PNG (*.png)|*.png|JPG (*.jpg)|*.jpg|TIF (*.tif)|*.tif|BMP (*.bmp)|*.bmp|All (*.*)|*.*||"

filename = rs.OpenFileName("Select image file", filter)

img = SD.Bitmap(filename)

# scripted rhino command pictureframe with width and height as calculated above
script = '_-PictureFrame "{0}" 0,0,0  {1},0,0'.format(filename, img.Width)
rs.Command(script)

img.Dispose()

obj = rs.GetObject("Select object")
if obj:
    index = rs.ObjectMaterialIndex(obj)
    if index>-1:
        rs.MaterialTransparency( index, 0.60 )

obj = rs.GetObject("Select object to orient")
if obj:
    reference = rs.GetPoints(message1="First reference point", message2="Second reference point")
    if reference>0:
        target = rs.GetPoints(message1="First target point", message2="Second target point")
        if target>0:
            rs.OrientObject( obj, reference, target, flags=2 )

I am running on OSX Rhino.

Thanks, Randy


#2

Has this worked before on MacRhino? I was under the impression (correct me if I’m wrong) that anything that uses System.Drawing.GDIPlus is Windows-only code…

–Mitch


#3

Hi Mitch, it has worked before, though it has been a while. What I remember id it brings them in scale 100% and bottom left of image was @ 0. I then would use the orient command.

I cannot tell how long ago, but I have used that script successfully. The date on that script is July 2012.

Randy