Skip to content

Commit

Permalink
more tests working!!
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyAJohnston committed Mar 7, 2025
1 parent 89b6c61 commit c2f775d
Show file tree
Hide file tree
Showing 5 changed files with 1,014 additions and 10 deletions.
7 changes: 2 additions & 5 deletions molecularnodes/entities/molecule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def add_style(

if assembly:
bl.nodes.assembly_initialise(self.object)
bl.nodes.assembly_insert(self.object)

return self

Expand Down Expand Up @@ -310,11 +311,7 @@ def _setup_frames_collection(self):
def _store_object_custom_properties(obj, reader: ReaderBase):
obj["entity_ids"] = reader.entity_ids()
obj["chain_ids"] = reader.chain_ids()

try:
obj.mn.biological_assemblies = json.dumps(reader.assemblies())
except InvalidFileError:
obj.mn.biological_assemblies = ""
obj.mn.biological_assemblies = reader.assemblies(as_json_string=True)

@classmethod
def _create_object(
Expand Down
8 changes: 5 additions & 3 deletions molecularnodes/entities/molecule/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ def entity_ids(self) -> list[str] | None:
def chain_ids(self) -> list[str] | None:
return np.unique(self.array.chain_id).tolist()

def assemblies(self):
return json.dumps(self._assemblies())
def assemblies(self, as_json_string: bool = False) -> dict | str:
if as_json_string:
return json.dumps(self._assemblies())
return self._assemblies()

def _assemblies(self):
return ""
return {}

@staticmethod
def set_extra_annotations(
Expand Down
3 changes: 3 additions & 0 deletions molecularnodes/ui/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def poll(self, context):

def execute(self, context):
obj = context.active_object
if not isinstance(obj, bpy.types.Object):
self.report({"ERROR"}, "No active object")
return {"CANCELLED"}
with databpy.nodes.DuplicatePrevention():
try:
if self.inset_node:
Expand Down
Loading

0 comments on commit c2f775d

Please sign in to comment.