-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial refactoring * minor tweaks * working refactor and tests * more refactoring * cleanup * more refactoring * BlenderObject is subclassed by Molecule * cleanup some trajectory * cleanup * more refactoring * tinkering * cleanup * refactoring * fix * fix * cleanup collections code * more refactoring of node code * some refactoring for centering * add missed file * fix adding operator * refactoring * cleanup pdbx extra annotations
- Loading branch information
1 parent
be51a5a
commit 4d792c5
Showing
45 changed files
with
1,591 additions
and
1,391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1 @@ | ||
from pathlib import Path | ||
from typing import Union | ||
import bpy | ||
|
||
|
||
def path_resolve(path: Union[str, Path]) -> Path: | ||
if isinstance(path, str): | ||
return Path(bpy.path.abspath(path)) | ||
elif isinstance(path, Path): | ||
return Path(bpy.path.abspath(str(path))) | ||
else: | ||
raise ValueError(f"Unable to resolve path: {path}") | ||
|
||
|
||
def active_object(context: bpy.types.Context = None) -> bpy.types.Object: | ||
if context is None: | ||
return bpy.context.active_object | ||
|
||
return context.active_object | ||
from .utils import path_resolve |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,34 @@ | ||
import bpy | ||
from bpy.types import Collection | ||
from ..bpyd.collection import create_collection | ||
|
||
|
||
def mn(): | ||
"""Return the MolecularNodes Collection | ||
def mn() -> Collection: | ||
"Return the 'MolecularNodes' collection, creating it first if required" | ||
return create_collection("MolecularNodes") | ||
|
||
The collection called 'MolecularNodes' inside the Blender scene is returned. If the | ||
collection does not exist first, it is created. | ||
""" | ||
coll = bpy.data.collections.get('MolecularNodes') | ||
if not coll: | ||
coll = bpy.data.collections.new('MolecularNodes') | ||
bpy.context.scene.collection.children.link(coll) | ||
return coll | ||
|
||
def data() -> Collection: | ||
"Return the MolecularNodes/data collection and disable it" | ||
name = ".MN_data" | ||
|
||
def armature(name='MN_armature'): | ||
coll = bpy.data.collections.get(name) | ||
if not coll: | ||
coll = bpy.data.collections.new(name) | ||
mn().children.link(coll) | ||
return coll | ||
try: | ||
return bpy.data.collections[name] | ||
except KeyError: | ||
collection = create_collection(name=name, parent=mn()) | ||
|
||
bpy.context.view_layer.layer_collection.children["MolecularNodes"].children[ | ||
collection.name | ||
].exclude = True | ||
return collection | ||
|
||
def data(suffix=""): | ||
"""A collection for storing MN related data objects. | ||
""" | ||
name = f"MN_data{suffix}" | ||
|
||
collection = bpy.data.collections.get(name) | ||
if not collection: | ||
collection = bpy.data.collections.new(name) | ||
mn().children.link(collection) | ||
def frames(name: str = "") -> Collection: | ||
"Return a collection for storing the objects that are the frames of a trajectory" | ||
return create_collection(f".data_{name}_frames", parent=data()) | ||
|
||
# disable the view of the data collection | ||
bpy.context.view_layer.layer_collection.children['MolecularNodes'].children[name].exclude = True | ||
return collection | ||
|
||
|
||
def frames(name="", parent=None, suffix="_frames"): | ||
"""Create a Collection for Frames of a Trajectory | ||
Args: | ||
name (str, optional): Name of the collection for the frames. Defaults to "". | ||
parent (_type_, optional): A blender collection which will become the parent | ||
collection. Defaults to the MolecularNodes collection if None. | ||
""" | ||
coll_frames = bpy.data.collections.new(name + suffix) | ||
if not parent: | ||
mn().children.link(coll_frames) | ||
else: | ||
parent.children.link(coll_frames) | ||
|
||
return coll_frames | ||
|
||
|
||
def cellpack(name="", parent=None, fallback=False): | ||
def cellpack(name: str = "") -> Collection: | ||
"Return a collection for storing the instances for a CellPack Ensemble" | ||
full_name = f"cellpack_{name}" | ||
coll = bpy.data.collections.get(full_name) | ||
if coll and fallback: | ||
return coll | ||
|
||
coll = bpy.data.collections.new(full_name) | ||
|
||
if parent: | ||
parent.children.link(coll) | ||
else: | ||
data().children.link(coll) | ||
|
||
return coll | ||
return create_collection(full_name, parent=data()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.