-
Notifications
You must be signed in to change notification settings - Fork 36
/
measureit_arch_material_hatches.py
187 lines (156 loc) · 5.07 KB
/
measureit_arch_material_hatches.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import bpy
from bpy.props import (
CollectionProperty,
FloatVectorProperty,
IntProperty,
BoolProperty,
FloatProperty,
PointerProperty)
from bpy.types import PropertyGroup, Panel, Operator, UIList, Collection
class HatchProperties(PropertyGroup):
visible: BoolProperty(
name="Visibility",
description="how/hide",
default=False)
pattern: PointerProperty(name='Hatch Pattern', type=Collection)
patternWeight: FloatProperty(
name="Pattern Weight",
description="Lineweight",
default=1,
soft_min=1.0,
step=25,
min=0)
patternSize: FloatProperty(
name="Pattern Size",
description="Lineweight",
default=1,
soft_min=1.0,
step=25,
min=0)
patternRot: FloatProperty(
name="Pattern Rotation",
description="Rotation",
default=0,
soft_min=0,
step=25,
subtype='ANGLE')
patternOpacity: FloatProperty(
name="Pattern Opacity",
description="Pattern Opacity",
default=1.0,
min=0.0,
max=1.0,
step=1,)
use_object_color: BoolProperty(
name="Use Object Color",
description="Use Object Color for Fill Color",
default=False)
use_object_pattern: BoolProperty(
name="Use Object Pattern",
description="Use Object Pattern for Fill Patern",
default=False)
use_material_offset: BoolProperty(
name="Use Material Offset",
description="Use the next material in the Stack for Hatch Settings",
default=False)
fill_color: FloatVectorProperty(
name="Color",
description="Color for the Item",
default=(0.0, 0.0, 0.0, 1.0),
min=0,
max=1,
subtype='COLOR',
size=4,)
line_color: FloatVectorProperty(
name="Color",
description="Color for the Item",
default=(0.0, 0.0, 0.0, 1.0),
min=0,
max=1,
subtype='COLOR',
size=4,)
lineWeight: FloatProperty(
name="Line Weight",
description="Lineweight",
default=1,
soft_min=1.0,
step=25,
min=0)
lineDrawDashed: BoolProperty(
name="Draw Dashed",
description="Force Line Group to Draw Dashed",
default=False)
dash_size: IntProperty(
name="Dash Size",
description ="Dash Size",
default = 5,
subtype = 'PIXEL'
)
gap_size: IntProperty(
name="Gap Size",
description ="Gap Size",
default = 5,
subtype = 'PIXEL'
)
class MATERIAL_PT_UIHatch(Panel):
""" A Panel in the Material properties window """
#bl_parent_id = 'MATERIAL_PT_Panel'
bl_label = "Hatch"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "material"
@classmethod
def poll(cls, context):
idx = context.object.active_material_index
try:
mat = context.object.material_slots[idx]
except IndexError:
return False
if mat.name == '' or mat == None:
return False
else:
return True
def draw_header(self, context):
if context.material == None:
return
layout = self.layout
row = layout.row()
hatch = context.material.Hatch
row.prop(hatch, "visible", text="",)
row.label(text="", icon = "FILE_VOLUME")
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
if context.material == None:
return
hatch = context.material.Hatch
obj = context.active_object
main_col = layout.column()
col = main_col.column()
main_col.enabled = hatch.visible
col = main_col.column()
col.prop(hatch, 'use_object_color',)
col.prop(hatch, 'use_object_pattern',)
if hatch.use_object_color:
col.prop(obj, 'color', text="Object Color")
else:
col.prop(hatch, 'fill_color', text="Fill Color",)
col.prop(hatch, 'line_color', text="Line Color",)
col.prop(hatch, 'lineWeight', text="Line Weight",)
col = main_col.column()
if hatch.use_object_pattern:
obj_props = obj.MeasureItArchProps
col.prop(obj_props, 'obj_hatch_pattern', text="Object Pattern",)
col.prop(obj_props, 'obj_patternSize', text="Object Pattern Size",)
col.prop(obj_props, 'obj_patternRot', text="Object Pattern Size",)
else:
col.prop(hatch, 'pattern', text="Hatch Pattern",)
col.prop(hatch, 'patternSize', text="Pattern Size",)
col.prop(hatch, 'patternRot', text="Pattern Rotation",)
col.prop(hatch, 'patternWeight', text="Pattern Weight",)
col.prop(hatch, 'patternOpacity', text="Pattern Opacity",)
col = main_col.column()
col.prop(hatch, 'lineDrawDashed', text="Draw Dashed",)
col.prop(hatch, 'dash_size', text="Dash Size",)
col.prop(hatch, 'gap_size', text="Gap Size",)