@@ -31,60 +31,67 @@ class SaveAllToShare(bpy.types.Operator):
31
31
bl_label = "Save All Staged Data"
32
32
bl_description = "Save all staged data for sharing"
33
33
34
+ save_layer : bpy .props .BoolProperty (
35
+ name = "Save Layer VDB Cache" ,
36
+ default = True ,
37
+ ) # type: ignore
38
+
34
39
layer_dir : bpy .props .StringProperty (
35
40
name = "Layer Directory" ,
36
41
subtype = 'DIR_PATH' ,
37
42
default = "//"
38
43
) # type: ignore
39
44
40
- save_node : bpy .props .BoolProperty (
45
+ save_lib : bpy .props .BoolProperty (
41
46
name = "Save Node Library File" ,
42
47
default = True ,
43
48
) # type: ignore
44
49
45
- node_file_dir : bpy .props .StringProperty (
50
+ lib_dir : bpy .props .StringProperty (
46
51
name = "Library Directory" ,
47
52
subtype = 'DIR_PATH' ,
48
53
default = "//"
49
54
) # type: ignore
50
55
51
56
def execute (self , context ):
52
- files = []
53
- for classname in dir (bpy .types ):
54
- if CLASS_PREFIX in classname :
55
- cls = getattr (bpy .types , classname )
56
- files .append (cls .nodes_file )
57
- files = list (set (files ))
58
-
59
- for file in files :
60
- file_name = Path (file ).name
61
- # "//"
62
- node_file_dir = bpy .path .abspath (self .node_file_dir )
63
-
64
- output_path : Path = Path (node_file_dir , file_name ).resolve ()
65
- source_path : Path = Path (file ).resolve ()
66
-
67
- if output_path != source_path :
68
- shutil .copy (source_path , output_path )
69
-
70
- for lib in bpy .data .libraries :
71
- lib_path = Path (bpy .path .abspath (lib .filepath )).resolve ()
72
- if lib_path == source_path :
73
- blend_path = Path (bpy .path .abspath ("//" )).resolve ()
74
- lib .filepath = bpy .path .relpath (
75
- str (output_path ), start = str (blend_path ))
76
-
77
- self .report ({"INFO" }, f"Successfully saved to { output_path } " )
78
-
79
- layers = get_all_layers ()
80
- for layer in layers :
81
- try :
82
- save_layer (layer , self .layer_dir )
83
- except :
84
- self .report (
85
- {"WARNING" }, f"Fail to save { layer .name } , skiped" )
86
-
87
- self .report ({"INFO" }, f"Successfully saved bioxel layers." )
57
+ if self .save_lib :
58
+ files = []
59
+ for classname in dir (bpy .types ):
60
+ if CLASS_PREFIX in classname :
61
+ cls = getattr (bpy .types , classname )
62
+ files .append (cls .nodes_file )
63
+ files = list (set (files ))
64
+
65
+ for file in files :
66
+ file_name = Path (file ).name
67
+ # "//"
68
+ lib_dir = bpy .path .abspath (self .lib_dir )
69
+
70
+ output_path : Path = Path (lib_dir , file_name ).resolve ()
71
+ source_path : Path = Path (file ).resolve ()
72
+
73
+ if output_path != source_path :
74
+ shutil .copy (source_path , output_path )
75
+
76
+ for lib in bpy .data .libraries :
77
+ lib_path = Path (bpy .path .abspath (lib .filepath )).resolve ()
78
+ if lib_path == source_path :
79
+ blend_path = Path (bpy .path .abspath ("//" )).resolve ()
80
+ lib .filepath = bpy .path .relpath (
81
+ str (output_path ), start = str (blend_path ))
82
+
83
+ self .report ({"INFO" }, f"Successfully saved to { output_path } " )
84
+
85
+ if self .save_layer :
86
+ layers = get_all_layers ()
87
+ for layer in layers :
88
+ try :
89
+ save_layer (layer , self .layer_dir )
90
+ except :
91
+ self .report (
92
+ {"WARNING" }, f"Fail to save { layer .name } , skiped" )
93
+
94
+ self .report ({"INFO" }, f"Successfully saved bioxel layers." )
88
95
89
96
return {'FINISHED' }
90
97
@@ -100,11 +107,11 @@ def poll(cls, context):
100
107
def draw (self , context ):
101
108
layout = self .layout
102
109
panel = layout .box ()
110
+ panel .prop (self , "save_layer" )
103
111
panel .prop (self , "layer_dir" )
104
112
panel = layout .box ()
105
- panel .prop (self , "save_node" )
106
- panel .prop (self , "node_file_dir" )
107
- layout .label (text = "Save your blender file first." )
113
+ panel .prop (self , "save_lib" )
114
+ panel .prop (self , "lib_dir" )
108
115
109
116
110
117
def save_layer (layer , output_dir ):
0 commit comments