Skip to content

Commit

Permalink
Merge pull request #27 from OmooLab/feature/dev
Browse files Browse the repository at this point in the history
feat: add primitive cutter
  • Loading branch information
icrdr authored Jul 10, 2024
2 parents 5922269 + 8b862b3 commit 2eb2358
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 46 deletions.
2 changes: 1 addition & 1 deletion bioxelnodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "Ma Nan",
"description": "",
"blender": (4, 1, 0),
"version": (0, 2, 5),
"version": (0, 2, 6),
"location": "File -> Import",
"warning": "",
"category": "Node"
Expand Down
4 changes: 2 additions & 2 deletions bioxelnodes/assets/Nodes/BioxelNodes_4.1.blend
Git LFS file not shown
7 changes: 7 additions & 0 deletions bioxelnodes/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@
'node_description': ''
},
"separator",
{
'label': 'Primitive Cutter',
'icon': 'MOD_LINEART',
'node_type': 'BioxelNodes_PrimitiveCutter',
'node_description': ''
},
"separator",
{
'label': 'Plane Cutter',
'icon': 'MESH_PLANE',
Expand Down
89 changes: 48 additions & 41 deletions bioxelnodes/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,60 +31,67 @@ class SaveAllToShare(bpy.types.Operator):
bl_label = "Save All Staged Data"
bl_description = "Save all staged data for sharing"

save_layer: bpy.props.BoolProperty(
name="Save Layer VDB Cache",
default=True,
) # type: ignore

layer_dir: bpy.props.StringProperty(
name="Layer Directory",
subtype='DIR_PATH',
default="//"
) # type: ignore

save_node: bpy.props.BoolProperty(
save_lib: bpy.props.BoolProperty(
name="Save Node Library File",
default=True,
) # type: ignore

node_file_dir: bpy.props.StringProperty(
lib_dir: bpy.props.StringProperty(
name="Library Directory",
subtype='DIR_PATH',
default="//"
) # type: ignore

def execute(self, context):
files = []
for classname in dir(bpy.types):
if CLASS_PREFIX in classname:
cls = getattr(bpy.types, classname)
files.append(cls.nodes_file)
files = list(set(files))

for file in files:
file_name = Path(file).name
# "//"
node_file_dir = bpy.path.abspath(self.node_file_dir)

output_path: Path = Path(node_file_dir, file_name).resolve()
source_path: Path = Path(file).resolve()

if output_path != source_path:
shutil.copy(source_path, output_path)

for lib in bpy.data.libraries:
lib_path = Path(bpy.path.abspath(lib.filepath)).resolve()
if lib_path == source_path:
blend_path = Path(bpy.path.abspath("//")).resolve()
lib.filepath = bpy.path.relpath(
str(output_path), start=str(blend_path))

self.report({"INFO"}, f"Successfully saved to {output_path}")

layers = get_all_layers()
for layer in layers:
try:
save_layer(layer, self.layer_dir)
except:
self.report(
{"WARNING"}, f"Fail to save {layer.name}, skiped")

self.report({"INFO"}, f"Successfully saved bioxel layers.")
if self.save_lib:
files = []
for classname in dir(bpy.types):
if CLASS_PREFIX in classname:
cls = getattr(bpy.types, classname)
files.append(cls.nodes_file)
files = list(set(files))

for file in files:
file_name = Path(file).name
# "//"
lib_dir = bpy.path.abspath(self.lib_dir)

output_path: Path = Path(lib_dir, file_name).resolve()
source_path: Path = Path(file).resolve()

if output_path != source_path:
shutil.copy(source_path, output_path)

for lib in bpy.data.libraries:
lib_path = Path(bpy.path.abspath(lib.filepath)).resolve()
if lib_path == source_path:
blend_path = Path(bpy.path.abspath("//")).resolve()
lib.filepath = bpy.path.relpath(
str(output_path), start=str(blend_path))

self.report({"INFO"}, f"Successfully saved to {output_path}")

if self.save_layer:
layers = get_all_layers()
for layer in layers:
try:
save_layer(layer, self.layer_dir)
except:
self.report(
{"WARNING"}, f"Fail to save {layer.name}, skiped")

self.report({"INFO"}, f"Successfully saved bioxel layers.")

return {'FINISHED'}

Expand All @@ -100,11 +107,11 @@ def poll(cls, context):
def draw(self, context):
layout = self.layout
panel = layout.box()
panel.prop(self, "save_layer")
panel.prop(self, "layer_dir")
panel = layout.box()
panel.prop(self, "save_node")
panel.prop(self, "node_file_dir")
layout.label(text="Save your blender file first.")
panel.prop(self, "save_lib")
panel.prop(self, "lib_dir")


def save_layer(layer, output_dir):
Expand Down
2 changes: 1 addition & 1 deletion extension/blender_manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ schema_version = "1.0.0"
# Example of manifest file for a Blender extension
# Change the values according to your extension
id = "bioxelnodes"
version = "0.2.5"
version = "0.2.6"
name = "Bioxel Nodes"
tagline = "For scientific volumetric data visualization in Blender"
maintainer = "Ma Nan <icrdr2010@outlook.com>"
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 = "bioxelnodes"
version = "0.2.5"
version = "0.2.6"
description = ""
authors = ["Ma Nan <icrdr2010@outlook.com>"]
license = "MIT"
Expand Down

0 comments on commit 2eb2358

Please sign in to comment.