diff --git a/molecularnodes/__init__.py b/molecularnodes/__init__.py index 91f05c94..d344f3ca 100644 --- a/molecularnodes/__init__.py +++ b/molecularnodes/__init__.py @@ -16,7 +16,7 @@ "author" : "Brady Johnston", "description" : "Toolbox for molecular animations in Blender & Geometry Nodes.", "blender" : (4, 0, 0), - "version" : (4, 0, 1), + "version" : (4, 0, 2), "location" : "Scene Properties -> Molecular Nodes", "warning" : "", "doc_url" : "https://bradyajohnston.github.io/MolecularNodes/", diff --git a/molecularnodes/blender/nodes.py b/molecularnodes/blender/nodes.py index 2b73b666..75fb5065 100644 --- a/molecularnodes/blender/nodes.py +++ b/molecularnodes/blender/nodes.py @@ -651,7 +651,7 @@ def chain_color(name, input_list, label_prefix = "Chain ", field = "chain_id", s the chain_id named attribute to manually set the colours for each of the chains. """ - group = new_group(name) + group = new_group(name, geometry=False) link = group.links.new # create a named attribute node that gets the chain_number attribute diff --git a/molecularnodes/ui/ops.py b/molecularnodes/ui/ops.py index 3efca0ca..86d60f10 100644 --- a/molecularnodes/ui/ops.py +++ b/molecularnodes/ui/ops.py @@ -73,7 +73,7 @@ class MN_OT_Color_Custom(bpy.types.Operator): description: bpy.props.StringProperty(name = "description", default = "") node_name: bpy.props.StringProperty(name = "node_name", default = "") - node_property: bpy.props.StringProperty(name = "node_property", default = "") + node_property: bpy.props.StringProperty(name = "node_property", default = "chain_id_unique") field: bpy.props.StringProperty(name = "field", default = "chain_id") prefix: bpy.props.StringProperty(name = "prefix", default = "Chain") starting_value: bpy.props.IntProperty(name = "starting_value", default = 0) @@ -86,7 +86,7 @@ def execute(self, context): obj = context.active_object # try: node_color = nodes.chain_color( - node_name = f"MN_color_{self.node_name}_{obj.name}", + name = f"MN_color_{self.node_name}_{obj.name}", input_list = obj[self.node_property], field = self.field, label_prefix= self.prefix, diff --git a/pyproject.toml b/pyproject.toml index 256c1d27..52100513 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "molecularnodes" -version = "4.0.1" +version = "4.0.2" description = "Toolbox for molecular animations with Blender and Geometry Nodes." authors = ["Brady Johnston "] license = "MIT" diff --git a/tests/test_nodes.py b/tests/test_nodes.py index 1bed1ea9..1ce3bc05 100644 --- a/tests/test_nodes.py +++ b/tests/test_nodes.py @@ -6,7 +6,7 @@ import tempfile from . import utils -from .constants import codes +from .constants import codes, test_data_directory random.seed(6) @@ -65,3 +65,13 @@ def test_custom_resid_selection(): if item.in_out == "INPUT": assert item.default_value == numbers[counter] counter += 1 + +def test_op_custom_color(): + mol = mn.io.local.load(test_data_directory / '1cd3.cif') + mol.select_set(True) + group = mn.blender.nodes.chain_color(f'MN_color_chain_{mol.name}', input_list=mol['chain_id_unique']) + + assert group + assert group.interface.items_tree['Chain G'].name == 'Chain G' + assert group.interface.items_tree[-1].name == 'Chain G' + assert group.interface.items_tree[0].name == 'Color' \ No newline at end of file