-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
104 lines (86 loc) · 4.72 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
bl_info = {
"name" : "SelectByVolume",
"author" : "Filippo Maria Castelli",
"description" : "Select meshes by their volume",
"blender" : (2, 80, 0),
"version" : (0, 2, 3),
"location" : "View3D",
"warning" : "",
"category" : "Generic"
}
import bpy
from bpy.props import BoolProperty, FloatProperty, CollectionProperty, IntProperty, StringProperty, CollectionProperty, PointerProperty
from .property_groups import MaterialGroup, InputFieldGroup, ColormapGroup
from .select_volume_op import SelectByVolume_OT_Operator
from .multi_selection_op import AddInputField_OT_Operator, ResetFields_OT_Operator, RemoveInputField_OT_Operator, ApplyMaterials_OT_Operator, SelectChunk_OT_Operator, GenerateSpaced_OT_Operator
from .material_op import ApplyAllMaterials_OT_Operator, ApplyColormap_OT_Operator, RandomizeColors_OT_Operator, ApplySelectedColors_OT_Operator
from .panel import SelectByVolume_PT_Panel
# REGISTERING / UNREGISTERING CLASSES
# custom PropertyGroups must be registered before being used
# by including them in register_classes_factory() the rest of the __init__.py
# would be executed before InputFieldGroup has a chance to be registered
# CUSTOM PROPS REGISTERING
bpy.utils.register_class(InputFieldGroup)
bpy.utils.register_class(MaterialGroup)
bpy.utils.register_class(ColormapGroup)
classes = (SelectByVolume_OT_Operator,
SelectByVolume_PT_Panel,
AddInputField_OT_Operator,
RemoveInputField_OT_Operator,
ResetFields_OT_Operator,
SelectChunk_OT_Operator,
ApplyMaterials_OT_Operator,
ApplyColormap_OT_Operator,
ApplyAllMaterials_OT_Operator,
RandomizeColors_OT_Operator,
GenerateSpaced_OT_Operator,
ApplySelectedColors_OT_Operator
)
fac_register, fac_unregister = bpy.utils.register_classes_factory(classes)
def register():
fac_register()
def unregister():
fac_unregister()
#bpy.utils.unregister_class(InputFieldGroup)
#del(bpy.types.Scene.sbv_use_multithread)
#del(bpy.types.Scene.sbv_use_cached)
#del(bpy.types.Scene.sbv_vol_max)
#del(bpy.types.Scene.sbv_vol_min)
#del(bpy.types.Scene.inputfields)
# INITIALIZING PROPS / PROPGROUPS
bpy.types.Scene.sbv_use_multithread = BoolProperty(name="use multithreading",
description="Use multithreading for object selection, useful for large files.",
default=False)
bpy.types.Scene.sbv_use_cached = BoolProperty(name="use cached volumes",
description="Use cached volumes instead of calculating ex novo.",
default=True)
bpy.types.Scene.sbv_vol_max = FloatProperty(name="max volume",
description="Max volume selected.",
min=0.,
default=500.)
bpy.types.Scene.sbv_vol_min = FloatProperty(name="min volume",
description="Min volume selected.",
min=0,
default=0.)
bpy.types.Scene.sbv_reset_materials = BoolProperty(name="reset materials", description="reset materials", default=True)
bpy.types.Scene.inputfields = CollectionProperty(type=InputFieldGroup)
bpy.types.Scene.sbv_custom_materials = CollectionProperty(type=MaterialGroup)
bpy.types.Scene.sbv_colormaps = PointerProperty(type=ColormapGroup)
bpy.types.Scene.sbv_spacing_max = FloatProperty(name="Max Volume", min=0.00001, default=0.00001, description="spacing max volume")
bpy.types.Scene.sbv_spacing_min = FloatProperty(name="Min Volume", min=0.00001, default=0.00001, description="spacing min volume")
bpy.types.Scene.sbv_spacings = IntProperty(name="slices", min=0, default=1, description="slices")
bpy.types.Scene.sbv_logspace = BoolProperty(name="logspace", default=True)
bpy.types.Scene.sbv_id_string = StringProperty(name="id_string", default="Cube")
bpy.types.Scene.sbv_base_material_name = StringProperty()