Skip to content

Commit 5052861

Browse files
authored
optional layer for labels
added an option to create a layer for dot text in rhino
1 parent 57a430d commit 5052861

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/compas_rhino/utilities/drawing.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def draw_labels(labels, **kwargs):
132132
'text': And(str, len),
133133
Optional('name', default=''): str,
134134
Optional('color', default=None): (lambda x: len(x) == 3 and all(0 <= y <= 255 for y in x)),
135+
Optional('layer', default=None): str,
135136
Optional('fontsize', default=10): Or(int, float),
136137
Optional('font', default="Arial Regular"): str
137138
})
@@ -143,6 +144,7 @@ def draw_labels(labels, **kwargs):
143144
text = label['text']
144145
name = label.get('name', '')
145146
color = label.get('color', None)
147+
layer = p.get('layer')
146148
size = label.get('fontsize', 10)
147149
font = label.get('font', 'Arial Regular')
148150
dot = TextDot(str(text), Point3d(*pos))
@@ -160,6 +162,10 @@ def draw_labels(labels, **kwargs):
160162
attr.ColorSource = ColorFromObject
161163
else:
162164
attr.ColorSource = ColorFromLayer
165+
if layer and find_layer_by_fullpath:
166+
index = find_layer_by_fullpath(layer, True)
167+
if index >= 0:
168+
attr.LayerIndex = index
163169
attr.Name = name
164170
obj.CommitChanges()
165171
guids.append(guid)

0 commit comments

Comments
 (0)