Page MenuHome

Images as Planes (addon) Attribute Error
Closed, ResolvedPublic

Description

bpy_struct: attribute "dimensions" from "Object" is read-only
    plane.dimensions = width, height, 0.0

location \scripts\addons\io_import_images_as_planes.py, line 1047

to replicate error:

  1. open blender 2.8 beta
  2. File -> import -> Images as Planes
  3. select a png/jpg

Running windows 10 on MSI GT73VR 7RE Titan SLI
Geforce GTX 1070 SLI

[BlenderTeamRocks]

Event Timeline

Bastien Montagne (mont29) triaged this task as Confirmed, Medium priority.

Ah, @Campbell Barton (campbellbarton) changed that API yesterday or so, will check all of our add-ons in case others used that prop too…

Zachary (AFWS) added a subscriber: Zachary (AFWS).EditedJan 5 2019, 12:53 PM

Ah, @Campbell Barton (campbellbarton) changed that API yesterday or so, will check all of our add-ons in case others used that prop too…

Dimensions is now read only? That kinda sucks. I know I used and seen other addons use that. How are we suppose to size objects with python now?

Edit:

I found a way ,but it now uses 5 times as many lines of code, LOL.

import bpy

NEW_X_DIM = 30

ACT_OBJ = bpy.context.active_object

X_SCALE = NEW_X_DIM/ACT_OBJ.dimensions[0]

if X_SCALE != 1.0:
	bpy.ops.object.transform_apply(scale=True)
	ACT_OBJ.scale[0] = X_SCALE
else:
	ACT_OBJ.scale[0] = X_SCALE

I believe you can do that with that single line:

obj.scale.x *= new_dim_x/obj.dimensions.x

I believe you can do that with that single line:

obj.scale.x *= new_dim_x/obj.dimensions.x

Looks like I need to read up on my python more. I never could get it to work without first getting my scale back to 1.0.

That’s more like transformation math or something… ;)

Anyway, after second thoughts, I really do not see why that was made read-only, for python API it's a handy shortcut, even if it may have not been working well for UI (only because of multi-editing, actually…). So will revert that part of rB1b8c3774a86ebc04fceb9cd.