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:
authorClemens Barth <barth@root-1.de>2022-01-21 19:54:49 +0300
committerClemens Barth <barth@root-1.de>2022-01-21 19:54:49 +0300
commit4009ff189d59f7cd69370aa94178d04a7ee60dac (patch)
treeaa792fd02c500e616c6fd63fdce3e966320da198
parenteb9a4e79d3df7b24046a6acc0e6e17c4b51f084d (diff)
io_mesh_atomic, utility panel: bug in option 'Default values'
- Error message "'NoneType' object has no attribute 'nodes'" because of wrong handling of the material properties. - After bug removal, the standard size and material properties can be assigned to all selected atom strctures.
-rw-r--r--io_mesh_atomic/utility_panel.py45
1 files changed, 30 insertions, 15 deletions
diff --git a/io_mesh_atomic/utility_panel.py b/io_mesh_atomic/utility_panel.py
index 9910bb8a..07974777 100644
--- a/io_mesh_atomic/utility_panel.py
+++ b/io_mesh_atomic/utility_panel.py
@@ -492,27 +492,41 @@ def modify_objects(action_type,
if atom.parent != None:
atom.hide_set(True)
- # Default shapes and colors for atoms
+ # Default shape and colors for atoms
if action_type == "ATOM_DEFAULT_OBJ" and "STICK" not in atom.name.upper():
scn = bpy.context.scene.atom_blend
- # Create new material
- new_material = bpy.data.materials.new("tmp")
- # Create new object (NURBS sphere = '1b')
- new_atom = draw_obj('1b', atom, new_material)
- new_atom.active_material = new_material
- new_material = draw_obj_material('0', new_material)
-
- # Change size and color of the new object
+ # We first obtain the element form the list of elements.
for element in ELEMENTS:
- if element.name in new_atom.name:
- new_atom.scale = (element.radii[0],) * 3
- new_atom.active_material.diffuse_color = element.color
- new_atom.name = element.name + "_ball"
- new_atom.active_material.name = element.name
+ if element.name in atom.name:
break
+ # Create now a new material with normal properties. Note that the
+ # 'normal material' initially used during the import could have been
+ # deleted by the user. This is why we create a new one.
+ if "vacancy" in atom.name.lower():
+ new_material = draw_obj_material('2', atom.active_material)
+ else:
+ new_material = draw_obj_material('1', atom.active_material)
+ # Assign now the correct color.
+ mat_P_BSDF = new_material.node_tree.nodes['Principled BSDF']
+ mat_P_BSDF.inputs['Base Color'].default_value = element.color
+ new_material.name = element.name + "_normal"
+
+ # Create a new atom because the current atom might have any kind
+ # of shape. For this, we use a definition from below since it also
+ # deletes the old atom.
+ if "vacancy" in atom.name.lower():
+ new_atom = draw_obj('2', atom, new_material)
+ else:
+ new_atom = draw_obj('1b', atom, new_material)
+
+ # Now assign the material properties, name and size.
+ new_atom.active_material = new_material
+ new_atom.name = element.name + "_ball"
+ new_atom.scale = (element.radii[0],) * 3
+
# Separating atoms from a dupliverts structure.
def separate_atoms(scn):
@@ -1154,7 +1168,6 @@ def read_elements():
# Custom data file: changing color and radii by using the list 'ELEMENTS'.
def custom_datafile_change_atom_props():
-
for atom in bpy.context.selected_objects:
FLAG = False
@@ -1213,6 +1226,8 @@ def custom_datafile_change_atom_props():
FLAG = False
+ bpy.ops.object.select_all(action='DESELECT')
+
# Reading a custom data file and modifying the list 'ELEMENTS'.
def custom_datafile(path_datafile):