forked from hlorus/CAD_Sketcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_distance.py
49 lines (36 loc) · 1.36 KB
/
add_distance.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
import logging
from bpy.types import Operator, Context
from bpy.props import FloatProperty, EnumProperty
from ..model.distance import align_items
from ..declarations import Operators
from ..stateful_operator.utilities.register import register_stateops_factory
from .base_constraint import GenericConstraintOp
logger = logging.getLogger(__name__)
class VIEW3D_OT_slvs_add_distance(Operator, GenericConstraintOp):
"""Add a distance constraint"""
bl_idname = Operators.AddDistance
bl_label = "Distance"
bl_options = {"UNDO", "REGISTER"}
value: FloatProperty(
name="Distance",
subtype="DISTANCE",
unit="LENGTH",
min=0.0,
precision=5,
options={"SKIP_SAVE"},
)
align: EnumProperty(name="Alignment", items=align_items)
type = "DISTANCE"
def fini(self, context: Context, succeede: bool):
super().fini(context, succeede)
if hasattr(self, "target"):
self.target.align = self.align
self.target.draw_offset = 0.05 * context.region_data.view_distance
def draw_settings(self, context: Context):
if not hasattr(self, "target"):
return
layout = self.layout
row = layout.row()
row.enabled = self.target.use_align()
row.prop(self, "align")
register, unregister = register_stateops_factory((VIEW3D_OT_slvs_add_distance,))