Gltf-blender-io: Test fail in master after Blender API change for future 2.81

Created on 5 Sep 2019  路  9Comments  路  Source: KhronosGroup/glTF-Blender-IO

File "/opt/blender281/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_material_normal_texture_info_class.py", line 69, in __gather_extensions
texture_transform = gltf2_blender_get.get_texture_transform_from_texture_node(texture_node)
File "/opt/blender281/2.81/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_get.py", line 151, in get_texture_transform_from_texture_node
if mapping_node.rotation[0] or mapping_node.rotation[1]:
AttributeError: 'ShaderNodeMapping' object has no attribute 'rotation'

https://circleci.com/gh/KhronosGroup/glTF-Blender-IO/858#tests/containers/1

All 9 comments

Actually this may have been introduced by an API change in a 2.81 experimental build.

Confirmed that this is in 2.81 experimental build :
https://developer.blender.org/rBbaaa89a0bc54a659f9ddbc34cce21d6920c0f6a6

Fix is quite easy to do, see https://developer.blender.org/D5693 for example

Is the fix backwards-compatible to 2.80?

@emackey No, this is not back-compatible

Instead of try/except, could we use

    if bpy.app.version < (2, 81, 0):

The convert script should still flag this for removal, it only looks for if bpy.app.version now.

I will try it after I'm sure that I change the code everywhere

(We have to use 2.81.8 , seems to be the subversion set in blender commit for this change)

I found this issue by Google, because of changes by Blender community specified here.

Specifically note:
ShaderNodeMapping was rewritten to have dynamic inputs, so direct access to translation, rotation and scale has been removed and is now done via inputs['Location'], inputs['Rotation'] and inputs['Scale']. Also min/max was removed entirely and should be replaced by access to the Extension parameter of the Texture node

It took me a while to convert old code that I had, so to help others here is an example:

    light_object = bpy.data.lights.new(name="light_name", type='SPOT')
    light_node = light_object.node_tree.nodes.new(type='ShaderNodeMapping')
    # old way: light_node.rotation[0] = 3.14159
    # new way, basically just add .inputs then 'Rotation', 'Location', or 'Scale' as you need, and then .default_value
    light_node.inputs['Rotation'].default_value = (0,0,3.14159)

Happy 3D graphing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nehon picture Nehon  路  5Comments

cstfan picture cstfan  路  4Comments

UX3D-nopper picture UX3D-nopper  路  3Comments

donmccurdy picture donmccurdy  路  5Comments

julienduroure picture julienduroure  路  5Comments