-
Notifications
You must be signed in to change notification settings - Fork 1
/
whiteMaterialize.py
68 lines (49 loc) · 1.6 KB
/
whiteMaterialize.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
# this script convert setting to monochrome lineart for comics
import bpy
# set white materials whole objects, then set edge and freestyle line
def whiteMaterialize(name="lineartWhite"):
# apply white material and edge
for item in bpy.data.objects:
if item.type == 'MESH':
item.data.materials.append(bpy.data.materials[name])
return
# add lineart white material
def addLineartMaterial(name="lineartWhite"):
mat = bpy.data.materials.new(name)
mat.use_shadeless = False
mat.diffuse_color = (float(1), float(1), float(1))
return
# clear lamps and materials exist
def clearObjects():
scn = bpy.context.scene
for ob in scn.objects:
if ob.type == 'LAMP':
# if ob.type == 'CAMERA' or ob.type == 'LAMP':
scn.objects.unlink(ob)
for item in bpy.data.objects:
if item.type == 'MESH':
while item.data.materials:
item.data.materials.pop(0, update_data=True)
return
################### add on setting section###########################
bl_info = {
"name": "White Materialize",
"category": "Object",
}
import bpy
class WhiteMaterial(bpy.types.Operator):
"""lineart converter"""
bl_idname = "white.material"
bl_label = "white material"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
clearObjects()
addLineartMaterial()
whiteMaterialize()
return {'FINISHED'}
def register():
bpy.utils.register_class(WhiteMaterial)
def unregister():
bpy.utils.unregister_class(WhiteMaterial)
if __name__ == "__main__":
register()