1 # SPDX-FileCopyrightText: 2019-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 "name": "Split Solidify",
7 "author": "zmj100, updated by zeffii to BMesh",
10 "location": "View3D > Tool Shelf",
19 from bpy
.types
import Operator
20 from bpy
.props
import (
29 # define the functions
30 def solidify_split(self
, list_0
):
32 loc_random
= self
.loc_random
33 random_dist
= self
.random_dist
34 distance
= self
.distance
35 thickness
= self
.thickness
36 normal_extr
= self
.normal_extr
41 bm
.faces
.ensure_lookup_table()
47 d
= random_dist
* random
.randrange(0, 10)
53 bm
.verts
.ensure_lookup_table()
54 v
= bm
.verts
[vi
.index
]
56 if normal_extr
== 'opt0':
57 p1
= (v
.co
).copy() + ((f
.normal
).copy() * d
) # out
58 p2
= (v
.co
).copy() + ((f
.normal
).copy() * (d
- thickness
)) # in
59 elif normal_extr
== 'opt1':
60 ang
= ((v
.normal
).copy()).angle((f
.normal
).copy())
61 h
= thickness
/ cos(ang
)
62 p1
= (v
.co
).copy() + ((f
.normal
).copy() * d
)
63 p2
= p1
+ (-h
* (f
.normal
).copy())
72 # add new faces, allows faces with more than 4 verts
75 k
= bm
.faces
.new(list_1
)
79 vseq
= list_1
[i
], list_2
[i
], list_2
[j
], list_1
[j
]
80 k
= bm
.faces
.new(vseq
)
84 k
= bm
.faces
.new(list_2
)
86 bpy
.ops
.mesh
.normals_make_consistent(inside
=False)
88 bmesh
.update_edit_mesh(self
.me
, loop_triangles
=True)
91 class MESH_OT_split_solidify(Operator
):
92 bl_idname
= "mesh.split_solidify"
93 bl_label
= "Split Solidify"
94 bl_description
= "Split and Solidify selected Faces"
95 bl_options
= {"REGISTER", "UNDO"}
97 distance
: FloatProperty(
99 description
="Distance of the splitted Faces to the original geometry",
101 min=-100.0, max=100.0,
105 thickness
: FloatProperty(
107 description
="Thickness of the splitted Faces",
109 min=-100.0, max=100.0,
113 random_dist
: FloatProperty(
115 description
="Randomization factor of the splitted Faces' location",
121 loc_random
: BoolProperty(
123 description
="Randomize the locations of splitted faces",
126 del_original
: BoolProperty(
127 name
="Delete original faces",
130 normal_extr
: EnumProperty(
131 items
=(('opt0', "Face", "Solidify along Face Normals"),
132 ('opt1', "Vertex", "Solidify along Vertex Normals")),
137 def draw(self
, context
):
139 layout
.label(text
="Normal:")
140 layout
.prop(self
, "normal_extr", expand
=True)
141 layout
.prop(self
, "loc_random")
143 if not self
.loc_random
:
144 layout
.label(text
="Distance:")
145 layout
.prop(self
, "distance")
146 elif self
.loc_random
:
147 layout
.label(text
="Random distance:")
148 layout
.prop(self
, "random_dist")
150 layout
.label(text
="Thickness:")
151 layout
.prop(self
, "thickness")
152 layout
.prop(self
, "del_original")
154 def execute(self
, context
):
155 obj
= bpy
.context
.active_object
157 self
.bm
= bmesh
.from_edit_mesh(self
.me
)
160 list_0
= [f
.index
for f
in self
.bm
.faces
if f
.select
]
163 self
.report({'WARNING'},
164 "No suitable selection found. Operation cancelled")
168 elif len(list_0
) != 0:
169 solidify_split(self
, list_0
)
170 context
.tool_settings
.mesh_select_mode
= (True, True, True)
171 if self
.del_original
:
172 bpy
.ops
.mesh
.delete(type='FACE')
180 bpy
.utils
.register_class(MESH_OT_split_solidify
)
184 bpy
.utils
.unregister_class(MESH_OT_split_solidify
)
187 if __name__
== "__main__":