#!BPY """ Name: 'Import Reference Images 1.2' Blender: 244 Group: 'Image' Tooltip: 'Import a folder of Reference Images as Planes' """ __author__ = ["blackcougar"] __url__ = ("http://www.joshuascotton.com") __version__ = "1.2" __bpydoc__ = """\ Import Reference Images """ # ***** BEGIN GPL LICENSE BLOCK ***** # # Script copyright (C) Joshua Scotton 2007 # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # ***** END GPL LICENCE BLOCK ***** # -------------------------------------------------------------------------- ###### # V1.0 # # * imports any pictures with the extension .jpg # * resizes planes to 2 blender units per 1000 pixels # # V1.1 # # * implements changes proposed by migius on blenderartists to work on windows xp # * can choose any extension # * can choose the scale # # V1.2 # # * cosmetic changes # ###### import Blender, os from Blender import * current_path = Blender.sys.dirname(Blender.Get('filename')) path = Draw.PupStrInput("Path:", current_path, 100) exten = Draw.PupStrInput("Extension:", ".jpg", 100) scale = Draw.PupIntInput("Pixels/BU", 1000,1,10000) filenames = [sys.join(path, filename) for filename in os.listdir(path) if filename.lower().endswith(exten)] if not filenames: print '...No images found. Aborting!' else: count = 0 for fname in filenames: me = Mesh.Primitives.Plane(1.0) face = me.faces[0] # loading the image image = Image.Load(fname) #loading the image as the uv texture for that face face.image = image; tx = Texture.New("tx") tx.setType("Image") tx.image = image mat = Material.New("mat") mat.setTexture(0,tx) ob = Object.New("Mesh", "NewOb") ob.link(me) ob.setMaterials([mat]) dimen = image.getSize() ob.setSize((float(dimen.pop())/scale),(float(dimen.pop())/scale),1) ob.setLocation(count/2.0, 0, 0) ob.RotY = -1.570796 ob.RotX = 1.570796 sc = Scene.GetCurrent() sc.objects.link(ob) count += 1