1 # SPDX-License-Identifier: GPL-2.0-or-later
4 "name": "Split Solidify",
5 "author": "zmj100, updated by zeffii to BMesh",
8 "location": "View3D > Tool Shelf",
17 from bpy
.types
import Operator
18 from bpy
.props
import (
27 # define the functions
28 def solidify_split(self
, list_0
):
30 loc_random
= self
.loc_random
31 random_dist
= self
.random_dist
32 distance
= self
.distance
33 thickness
= self
.thickness
34 normal_extr
= self
.normal_extr
39 bm
.faces
.ensure_lookup_table()
45 d
= random_dist
* random
.randrange(0, 10)
51 bm
.verts
.ensure_lookup_table()
52 v
= bm
.verts
[vi
.index
]
54 if normal_extr
== 'opt0':
55 p1
= (v
.co
).copy() + ((f
.normal
).copy() * d
) # out
56 p2
= (v
.co
).copy() + ((f
.normal
).copy() * (d
- thickness
)) # in
57 elif normal_extr
== 'opt1':
58 ang
= ((v
.normal
).copy()).angle((f
.normal
).copy())
59 h
= thickness
/ cos(ang
)
60 p1
= (v
.co
).copy() + ((f
.normal
).copy() * d
)
61 p2
= p1
+ (-h
* (f
.normal
).copy())
70 # add new faces, allows faces with more than 4 verts
73 k
= bm
.faces
.new(list_1
)
77 vseq
= list_1
[i
], list_2
[i
], list_2
[j
], list_1
[j
]
78 k
= bm
.faces
.new(vseq
)
82 k
= bm
.faces
.new(list_2
)
84 bpy
.ops
.mesh
.normals_make_consistent(inside
=False)
86 bmesh
.update_edit_mesh(self
.me
, loop_triangles
=True)
89 class MESH_OT_split_solidify(Operator
):
90 bl_idname
= "mesh.split_solidify"
91 bl_label
= "Split Solidify"
92 bl_description
= "Split and Solidify selected Faces"
93 bl_options
= {"REGISTER", "UNDO"}
95 distance
: FloatProperty(
97 description
="Distance of the splitted Faces to the original geometry",
99 min=-100.0, max=100.0,
103 thickness
: FloatProperty(
105 description
="Thickness of the splitted Faces",
107 min=-100.0, max=100.0,
111 random_dist
: FloatProperty(
113 description
="Randomization factor of the splitted Faces' location",
119 loc_random
: BoolProperty(
121 description
="Randomize the locations of splitted faces",
124 del_original
: BoolProperty(
125 name
="Delete original faces",
128 normal_extr
: EnumProperty(
129 items
=(('opt0', "Face", "Solidify along Face Normals"),
130 ('opt1', "Vertex", "Solidify along Vertex Normals")),
135 def draw(self
, context
):
137 layout
.label(text
="Normal:")
138 layout
.prop(self
, "normal_extr", expand
=True)
139 layout
.prop(self
, "loc_random")
141 if not self
.loc_random
:
142 layout
.label(text
="Distance:")
143 layout
.prop(self
, "distance")
144 elif self
.loc_random
:
145 layout
.label(text
="Random distance:")
146 layout
.prop(self
, "random_dist")
148 layout
.label(text
="Thickness:")
149 layout
.prop(self
, "thickness")
150 layout
.prop(self
, "del_original")
152 def execute(self
, context
):
153 obj
= bpy
.context
.active_object
155 self
.bm
= bmesh
.from_edit_mesh(self
.me
)
158 list_0
= [f
.index
for f
in self
.bm
.faces
if f
.select
]
161 self
.report({'WARNING'},
162 "No suitable selection found. Operation cancelled")
166 elif len(list_0
) != 0:
167 solidify_split(self
, list_0
)
168 context
.tool_settings
.mesh_select_mode
= (True, True, True)
169 if self
.del_original
:
170 bpy
.ops
.mesh
.delete(type='FACE')
178 bpy
.utils
.register_class(MESH_OT_split_solidify
)
182 bpy
.utils
.unregister_class(MESH_OT_split_solidify
)
185 if __name__
== "__main__":