-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathconvenience.py
85 lines (62 loc) · 2.32 KB
/
convenience.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
'''
Created on Feb 14, 2017
@author: Patrick
'''
import bpy
class CUTMESH_OT_join_strokes(bpy.types.Operator):
"""Join all polytrim stokes into single object"""
bl_idname = "cut_mesh.polytrim_join_strokes"
bl_label = "Join Polytrim Strokes"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
if context.mode == "OBJECT":
return True
else:
return False
def execute(self, context):
obs = [ob for ob in context.scene.objects if 'polyknife' in ob.name and 'join' not in ob.name]
bpy.ops.object.select_all(action = 'DESELECT')
for ob in obs:
ob.hide = False
ob.select = True
context.scene.objects.active = ob
bpy.ops.object.join()
context.obejct.name = 'polyknife_joined'
return {'FINISHED'}
class CUTMESH_OT_hide_strokes(bpy.types.Operator):
"""Hide all polytrim stokes to get them out of the way"""
bl_idname = "cut_mesh.polytrim_hide_strokes"
bl_label = "Hide Polytrim Strokes"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
if context.mode == "OBJECT":
return True
else:
return False
def execute(self, context):
obs = [ob for ob in context.scene.objects if 'polyknife' in ob.name]
for ob in obs:
ob.hide = True
return {'FINISHED'}
class CUTMESH_OT_delete_strokes(bpy.types.Operator):
"""Delete all polytrim stokes if they are not needed"""
bl_idname = "cut_mesh.polytrim_strokes_delete"
bl_label = "Delete Polytrim Strokes"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
if context.mode == "OBJECT":
return True
else:
return False
def execute(self, context):
obs = [ob for ob in context.scene.objects if 'polyknife' in ob.name and 'join' not in ob.name]
bpy.ops.object.select_all(action = 'DESELECT')
for ob in obs:
ob.hide = False
ob.select = True
context.scene.objects.active = ob
bpy.ops.object.delete(use_global = True)
return {'FINISHED'}