Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2013-04-11 19:35:14 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2013-04-11 19:35:14 +0400
commitcc9f663c54eca82b703979b255ea5e285ad96b45 (patch)
tree8fece490517d1e80e859bf44996618c54faf1621 /io_import_images_as_planes.py
parent79d1a85d09520ea2a32d19da363489324fbb1ed0 (diff)
Small changes to images as planes:
*Use absolute as default size mode (dpi with BU is not that nice). *Use default plane primitive instead of creating our own square (this way we can be sure things like verts order will always match those of default plane!), request from Christopher Barrett in tracker.
Diffstat (limited to 'io_import_images_as_planes.py')
-rw-r--r--io_import_images_as_planes.py27
1 files changed, 11 insertions, 16 deletions
diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py
index 09bd0ddf..2c484b1f 100644
--- a/io_import_images_as_planes.py
+++ b/io_import_images_as_planes.py
@@ -19,7 +19,7 @@
bl_info = {
"name": "Import Images as Planes",
"author": "Florian Meyer (tstscr), mont29, matali",
- "version": (1, 8),
+ "version": (1, 9),
"blender": (2, 66, 4),
"location": "File > Import > Images as Planes or Add > Mesh > Images as Planes",
"description": "Imports images and creates planes with the appropriate aspect ratio. "
@@ -214,7 +214,7 @@ class IMPORT_OT_image_to_plane(Operator, AddObjectHelper):
('DPI', "Dpi", "Use definition of the image as dots per inch"),
('DPBU', "Dots/BU", "Use definition of the image as dots per Blender Unit"),
)
- size_mode = EnumProperty(name="Size Mode", default='DPI', items=_size_modes,
+ size_mode = EnumProperty(name="Size Mode", default='ABSOLUTE', items=_size_modes,
description="How the size of the plane is computed")
height = FloatProperty(name="Height", description="Height of the created plane",
@@ -369,29 +369,24 @@ class IMPORT_OT_image_to_plane(Operator, AddObjectHelper):
px = py = 1
if self.size_mode == 'ABSOLUTE':
- y = self.height / 2
+ y = self.height
x = px / py * y
elif self.size_mode == 'DPI':
- fact = 1 / self.factor / context.scene.unit_settings.scale_length * 0.0254 / 2
+ fact = 1 / self.factor / context.scene.unit_settings.scale_length * 0.0254
x = px * fact
y = py * fact
else: # elif self.size_mode == 'DPBU'
- fact = 1 / self.factor / 2
+ fact = 1 / self.factor
x = px * fact
y = py * fact
- verts = ((-x, -y, 0.0),
- (+x, -y, 0.0),
- (+x, +y, 0.0),
- (-x, +y, 0.0),
- )
- faces = ((0, 1, 2, 3), )
-
- mesh_data = bpy.data.meshes.new(img.name)
- mesh_data.from_pydata(verts, [], faces)
- mesh_data.update()
- object_data_add(context, mesh_data, operator=self)
+ bpy.ops.mesh.primitive_plane_add('INVOKE_REGION_WIN')
plane = context.scene.objects.active
+ # Why does mesh.primitive_plane_add leave the object in edit mode???
+ if plane.mode is not 'OBJECT':
+ bpy.ops.object.mode_set(mode='OBJECT')
+ plane.dimensions = x, y, 0.0
+ bpy.ops.object.transform_apply(scale=True)
plane.data.uv_textures.new()
plane.data.materials.append(material)
plane.data.uv_textures[0].data[0].image = img