Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@
- Robin Godwyll <<rodwyll+github@gmail.com>> [@robin-gdwl](https://github.com/robin-gdwl)
- Mattis Koh <<mattiskoh@gmail.com>> [@mattiskoh](https://github.com/mattiskoh)
- Andrea Ghensi <<a.ghensi@swsglobal.com>> [@sanzoghenzo](https://github.com/sanzoghenzo)
- Nizar Taha <<taha@arch.ethz.ch>> [@nizartaha](https://github.com/nizartaha)
8 changes: 7 additions & 1 deletion src/compas_rhino/utilities/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def wrapper(*args, **kwargs):

@wrap_drawfunc
def draw_labels(labels, **kwargs):
"""Draw labels as text dots and optionally set individual font, fontsize, name and color.
"""Draw labels as text dots and optionally set individual font, fontsize, name, layer and color.

Parameters
----------
Expand All @@ -132,6 +132,7 @@ def draw_labels(labels, **kwargs):
'text': And(str, len),
Optional('name', default=''): str,
Optional('color', default=None): (lambda x: len(x) == 3 and all(0 <= y <= 255 for y in x)),
Optional('layer', default=None): str,
Optional('fontsize', default=10): Or(int, float),
Optional('font', default="Arial Regular"): str
})
Expand All @@ -143,6 +144,7 @@ def draw_labels(labels, **kwargs):
text = label['text']
name = label.get('name', '')
color = label.get('color', None)
layer = label.get('layer')
size = label.get('fontsize', 10)
font = label.get('font', 'Arial Regular')
dot = TextDot(str(text), Point3d(*pos))
Expand All @@ -160,6 +162,10 @@ def draw_labels(labels, **kwargs):
attr.ColorSource = ColorFromObject
else:
attr.ColorSource = ColorFromLayer
if layer and find_layer_by_fullpath:
index = find_layer_by_fullpath(layer, True)
if index >= 0:
attr.LayerIndex = index
attr.Name = name
obj.CommitChanges()
guids.append(guid)
Expand Down