-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTimeSavers.py
152 lines (125 loc) · 5.38 KB
/
TimeSavers.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
bl_info = {
"name": "TimeSavers",
"author": "Citrine's Animations",
"version": (1, 1, 0),
"blender": (2, 80, 0),
"location": "Side Bar",
"description": "Nice little time savers",
"warning": "",
"wiki_url": "",
"category": "Add Mesh",
}
import bpy
from bpy.props import (StringProperty,
BoolProperty,
IntProperty,
FloatProperty,
FloatVectorProperty,
EnumProperty,
PointerProperty,
)
from bpy.types import (Panel,
Menu,
Operator,
PropertyGroup,
)
def mbColourPickerUp(context, self):
objs = bpy.context.scene.obie
if objs.type == 'MESH':
if objs.material_slots[0].material.node_tree.nodes.find("Group.004") > 0:
objs.mbColour = objs.material_slots[0].material.node_tree.nodes["Group.004"].inputs[0].default_value
bpy.context.object.mbColour = bpy.context.scene.obie.mbColour
bpy.context.scene.obie = None
bpy.types.Object.Start = bpy.props.IntProperty(default=0, min=0)
bpy.types.Object.End = bpy.props.IntProperty(default=1, min=0)
bpy.types.Scene.obie = bpy.props.PointerProperty(type=bpy.types.Object, name="", update=mbColourPickerUp)
def mbColourUpdate(context, self):
bpy.context.object.material_slots[0].material.node_tree.nodes["Group.004"].inputs[0].default_value = bpy.context.object.mbColour
bpy.context.object.material_slots[0].material.diffuse_color = bpy.context.object.mbColour
bpy.types.Object.mbColour = bpy.props.FloatVectorProperty(name = "",subtype = "COLOR",size = 4,min = 0.0,max = 1.0, default = (0,0,0,1),update=mbColourUpdate)
class fixedUpdateC(bpy.types.Operator):
bl_idname = "fix.updatec"
bl_label = "Reload Colours"
def execute(self, context):
for objs in bpy.context.selected_objects:
if objs.type == 'MESH':
if objs.material_slots[0].material.node_tree.nodes.find("Group.004") > 0:
objs.mbColour = objs.material_slots[0].material.node_tree.nodes["Group.004"].inputs[0].default_value
return {'FINISHED'}
class indentmats(bpy.types.Operator):
bl_idname = "indent.mats"
bl_label = "SU"
def execute(self, context):
bpy.context.object.material_slots[0].material = bpy.context.object.material_slots[0].material.copy()
return {'FINISHED'}
class Helpfullsh(bpy.types.Panel):
bl_label = "TimeSavers"
bl_idname = "TimeSavers"
bl_category = "TimeSavers"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
def draw(self, context):
layout = self.layout
obj = context.object
row = layout.row(align=True)
row.operator('oi.oi', text='2s')
row = layout.row(align=True)
row.prop(obj, "Start")
row.operator('smeared.s')
row.prop(obj, "End")
row = layout.row(align=True)
row.split()
row = layout.row(align=True)
row.operator('fix.updatec')
row.operator('indent.mats', text="", icon='RESTRICT_INSTANCED_ON')
row = layout.row(align=True)
row.prop(obj, 'mbColour')
row.prop(context.scene, 'obie')
class oiOi(bpy.types.Operator):
bl_idname = "oi.oi"
bl_label = "2s"
def execute(self, context):
#self.report({'INFO'}, "Hello world!")
obj = bpy.context.selected_objects
for heh in obj:
fcurve = heh.animation_data.action.fcurves
for jeff in fcurve:
jeff.modifiers.new(type='STEPPED')
return {'FINISHED'}
class smearedS(bpy.types.Operator):
bl_idname = "smeared.s"
bl_label = "Smear"
def execute(self, context):
#self.report({'INFO'}, "Hello world!")
obj = bpy.context.selected_objects
for afaf in obj:
bruv = bpy.context.scene.frame_current-afaf.Start
bruv2 = bpy.context.scene.frame_current+afaf.End+1
bruv3 = bpy.context.scene.frame_current-afaf.Start-1
afaf.hide_render = True
afaf.hide_viewport = True
afaf.keyframe_insert(data_path="hide_render", frame = bruv3)
afaf.keyframe_insert(data_path="hide_viewport", frame = bruv3)
afaf.hide_render = False
afaf.hide_viewport = False
afaf.keyframe_insert(data_path="hide_render", frame = bruv)
afaf.keyframe_insert(data_path="hide_viewport", frame = bruv)
afaf.hide_render = True
afaf.hide_viewport = True
afaf.keyframe_insert(data_path="hide_render", frame = bruv2)
afaf.keyframe_insert(data_path="hide_viewport", frame = bruv2)
return {'FINISHED'}
def register():
bpy.utils.register_class(oiOi)
bpy.utils.register_class(smearedS)
bpy.utils.register_class(Helpfullsh)
bpy.utils.register_class(fixedUpdateC)
bpy.utils.register_class(indentmats)
def unregister():
bpy.utils.unregister_class(Helpfullsh)
bpy.utils.unregister_class(oiOi)
bpy.utils.unregister_class(smearedS)
bpy.utils.unregister_class(fixedUpdateC)
bpy.utils.unregister_class(indentmats)
if __name__ == '__main__':
register()