I am trying to read multiple image files using python script and then draw them and bake them into rhino.
I want to bake them on a grid using the image width and height values.
I manage to read the files using “System” module but how do I go on from there?
import System
bmp =
w =
h =
for i in path:
bmp.append(System.Drawing.Bitmap.FromFile(i))
bitmap = System.Drawing.Bitmap.FromFile(i)
w.append(bitmap.Width)
h.append(bitmap.Height)
Thanks for your reply… it is not quit what I was looking for.
I have found something though if anyone will need it in the future.
It bakes the pictures as surfaces (picture frame) by a given width and gap:
import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
import System
def DoSomething():
# define the file formats allowed to pick in the import dialog
nfilters = "JPEG - JFIF Compliant (*.jpg, *.jpeg, *.jpe)|*.jpg|"
nfilters += "Portable Newtork Graphics (*.png)|*.png|"
nfilters += "Windows Bitmap (*.bmp)|*.bmp|"
nfilters += "Tagged Image File Format (*.tif, *.tiff)|*.tif|"
nfilters += "All Files (*.*)|*.*||"
# ask for image files, show import dialog
pictures = rs.OpenFileNames("Import Pictureframes", nfilters)
#if not pictures: return
# setup width of image and gap size between them
width = 20
gap = 15
# process the image files
for i, pic in enumerate(pictures):
# print the pictue file name
print "Number:", i, " File:", pic
# define the 2 points to pick for placement
x1 = (i%10)*(width+gap)
x2 = x1+width
y1 = (i//10)*(2*width + gap)
y2 = y1
pt1 = Rhino.Geometry.Point3d(x1, y1, 0)
pt2 = Rhino.Geometry.Point3d(x2, y2, 0)
# put the path in quotes to prevent problems with spaces in it
path = chr(34) + pic + chr(34)
# create a command string
cmd = "_-Pictureframe " + path + " " + str(pt1) + " " + str(pt2) + " _EnterEnd"
# run the command
rs.Command(cmd, True)