Skip to content

Commit

Permalink
fixed creation of color chains
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyAJohnston committed Nov 30, 2023
1 parent 1b92bfa commit 0e9bde8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion molecularnodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
2 changes: 1 addition & 1 deletion molecularnodes/blender/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions molecularnodes/ui/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
Expand Down
12 changes: 11 additions & 1 deletion tests/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import tempfile

from . import utils
from .constants import codes
from .constants import codes, test_data_directory
random.seed(6)


Expand Down Expand Up @@ -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'

0 comments on commit 0e9bde8

Please sign in to comment.