-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdks_modeling.py
More file actions
99 lines (68 loc) · 2.75 KB
/
dks_modeling.py
File metadata and controls
99 lines (68 loc) · 2.75 KB
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
# ##### BEGIN GPL LICENSE BLOCK #####
#
# 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
# MERCHANTABILITY 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, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
import bpy
class object_center(bpy.types.Operator):
bl_label = "Center Object"
bl_idname = "dks_modeling.object_center"
def execute(self, context):
bpy.ops.view3d.snap_cursor_to_center()
bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='BOUNDS')
bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN', center='BOUNDS')
return {'FINISHED'}
class object_transform_apply(bpy.types.Operator):
bl_label = "Transform Apply"
bl_idname = "dks_modeling.object_transform_apply"
def execute(self, context):
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
return {'FINISHED'}
class object_origin_geometry(bpy.types.Operator):
bl_label = "Origin to Geometry"
bl_idname = "dks_modeling.object_origin_geometry"
def execute(self, context):
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN')
return {'FINISHED'}
class object_remove_doubles(bpy.types.Operator):
bl_label = "Remove Doubles"
bl_idname = "dks_modeling.object_remove_doubles"
def execute(self, context):
#bpy.ops.mesh.select_all(action='SELECT')
#bpy.ops.mesh.remove_doubles()
bpy.ops.mesh.remove_doubles(threshold=0.1, use_unselected=True)
return {'FINISHED'}
class object_normals_reset(bpy.types.Operator):
bl_label = "Normals Reset"
bl_idname = "dks_modeling.object_normals_reset"
def execute(self, context):
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.normals_tools(mode='RESET')
return {'FINISHED'}
classes = (
object_center,
object_transform_apply,
object_origin_geometry,
object_remove_doubles,
object_normals_reset
)
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
def unregister():
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)