-
Notifications
You must be signed in to change notification settings - Fork 96
/
op_set_edge_linear.py
56 lines (41 loc) · 1.67 KB
/
op_set_edge_linear.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
import bpy
from bpy.props import BoolProperty, FloatProperty, EnumProperty
import bmesh
from . import util
from . import op_set_edge_flow
class SetEdgeLinearOP(bpy.types.Operator, op_set_edge_flow.SetEdgeLoopBase):
bl_idname = "mesh.set_edge_linear"
bl_label = "Set Edge Linear"
bl_options = {'REGISTER', 'UNDO'}
bl_description = "Makes edge loops linear between start and end vertices"
space_evenly: BoolProperty(name="Space evenly", default=False,
description="Spread the vertices in even distances")
def invoke(self, context, event):
super(SetEdgeLinearOP, self).invoke(context)
if event and not event.alt:
self.mix = 1.0
return self.execute(context)
def can_straighten(self):
for obj in self.objects:
for edgeloop in self.edgeloops[obj]:
if len(edgeloop.edges) != 1:
return False
return True
def execute(self, context):
if not self.is_invoked:
return self.invoke(context, None)
else:
self.revert_to_intial_positions()
refresh_positions = self.mix == self.last_mix
if refresh_positions:
for obj in self.objects:
for edgeloop in self.edgeloops[obj]:
edgeloop.set_linear(self.space_evenly)
self.store_final_positions()
self.apply_mix()
for obj in self.objects:
self.bm[obj].normal_update()
bmesh.update_edit_mesh(obj.data)
self.last_mix = self.mix
self.is_invoked = False
return {'FINISHED'}