Skip to content

Commit

Permalink
fixes menu generation
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyAJohnston committed Jan 13, 2025
1 parent 2125b1c commit 1dfa23b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions molecularnodes/operators/node_add_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def poll(self, context):
# is associated with the object / molecule. If there isn't then the assembly
# operator will be greyed out and unable to be executed
obj = context.active_object
if obj is None:
return False
return obj.mn.biological_assemblies != ""

def execute(self, context):
Expand Down Expand Up @@ -135,6 +137,13 @@ class MN_OT_iswitch_custom(Operator):
node_name: StringProperty(name="node_name", default="chain") # type: ignore
starting_value: IntProperty(name="starting_value", default=0) # type: ignore

@classmethod
def poll(cls, context: Context) -> bool:
obj = context.active_object
if obj is None:
return False
return True

@classmethod
def description(cls, context, properties):
return properties.description
Expand Down
6 changes: 5 additions & 1 deletion molecularnodes/ui/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ def menu(
else:
raise ValueError(f"Data type currently not supported: {self.dtype}")
# test if the object has the currently tested property to enable operator
row.enabled = bool(context.active_object.get(self.property_id))
obj = context.active_object
if obj is None:
row.enabled = False
else:
row.enabled = bool(obj.get(self.property_id))


class Break:
Expand Down

0 comments on commit 1dfa23b

Please sign in to comment.