From 998461835d10a0c5820085d0d209f876b8babb84 Mon Sep 17 00:00:00 2001 From: AnimNyan Date: Tue, 5 Apr 2022 22:54:10 +1000 Subject: [PATCH] make sure nodes don't appear on top of each other by adding a function to change position based on the number of nodes in the tree --- io_import_scene_lwo.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/io_import_scene_lwo.py b/io_import_scene_lwo.py index 48fbf2a..05d40cd 100644 --- a/io_import_scene_lwo.py +++ b/io_import_scene_lwo.py @@ -1339,11 +1339,13 @@ def build_objects(object_layers, object_surfs, object_clips, object_tags, object vertex_color_node = curr_material.node_tree.nodes.new('ShaderNodeVertexColor') #position x, y - vertex_color_node.location = (-800, 0) + vertex_color_node.location = get_new_node_location(curr_material) #create a mixRGB node mix_rgb_tint_node = curr_material.node_tree.nodes.new('ShaderNodeMixRGB') + mix_rgb_tint_node.location = get_new_node_location(curr_material) + mix_rgb_tint_node.blend_type = 'MULTIPLY' mix_rgb_tint_node.inputs["Fac"].default_value = 1 @@ -1455,7 +1457,7 @@ def build_objects(object_layers, object_surfs, object_clips, object_tags, object vertex_color_node_2 = curr_material.node_tree.nodes.new('ShaderNodeVertexColor') #position x, y - vertex_color_node_2.location = (-900, -200) + vertex_color_node_2.location = get_new_node_location(curr_material) #-------------------------------------------------------NEED TO CHANGE IS HARDCODED #------------------------------------------------------- @@ -1571,7 +1573,7 @@ def build_objects(object_layers, object_surfs, object_clips, object_tags, object uv_map_node = curr_material.node_tree.nodes.new('ShaderNodeUVMap') #position x, y - uv_map_node.location = (-600, 150) + uv_map_node.location = get_new_node_location(curr_material) material_link(uv_map_node.outputs["UV"], image_texture_node.inputs["Vector"]) #image_texture_node.uv_layer = texture.uvname @@ -2005,6 +2007,18 @@ def build_objects(object_layers, object_surfs, object_clips, object_tags, object print("Done Importing LWO File") +#return a different (x,y) position +#this depends upon how many nodes currently exist +#so every node will return a different x and y position +def get_new_node_location(curr_material): + count = len(curr_material.node_tree.nodes) + + x_location = count * -150 + y_location = count * -20 + + return (x_location,y_location) + + from bpy.props import StringProperty, BoolProperty, CollectionProperty