Maniphest T60183

Images as Planes (addon) Attribute Error
Closed, Resolved

Assigned To
Bastien Montagne (mont29)
Authored By
Douglas Hajj (precognist)
Jan 5 2019, 5:54 AM
Tags
  • Add-ons (Community)
Subscribers
Bastien Montagne (mont29)
Campbell Barton (campbellbarton)
Douglas Hajj (precognist)
Zachary (AFWS)

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]

Revisions and Commits

rB Blender

Related Objects

Mentioned Here
rB1b8c3774a86e: Fix T54771: Can't change multiple dimensions at once

Event Timeline

Douglas Hajj (precognist) created this task.Jan 5 2019, 5:54 AM
Bastien Montagne (mont29) claimed this task.Jan 5 2019, 12:07 PM
Bastien Montagne (mont29) lowered the priority of this task from 90 to 50.
Bastien Montagne (mont29) added a project: Add-ons (Community).
Bastien Montagne (mont29) added subscribers: Campbell Barton (campbellbarton), Bastien Montagne (mont29).

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
In T60183#594138, @Bastien Montagne (mont29) wrote:

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
Bastien Montagne (mont29) added a comment.Jan 5 2019, 2:59 PM

I believe you can do that with that single line:

obj.scale.x *= new_dim_x/obj.dimensions.x
Zachary (AFWS) added a comment.Jan 5 2019, 3:52 PM
In T60183#594174, @Bastien Montagne (mont29) wrote:

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.

Bastien Montagne (mont29) added a comment.Jan 5 2019, 4:35 PM

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.

Bastien Montagne (mont29) changed the task status from Unknown Status to Resolved by committing rB9c928bb93e04: Fix T60183: Images as Planes (addon) Attribute Error..Jan 5 2019, 4:38 PM
Bastien Montagne (mont29) added a commit: rB9c928bb93e04: Fix T60183: Images as Planes (addon) Attribute Error..