From 5052861141161cea4af796dbedd9b2e1db4ed3f7 Mon Sep 17 00:00:00 2001 From: nizartaha <38039580+nizartaha@users.noreply.github.com> Date: Mon, 30 Aug 2021 11:57:46 +0200 Subject: [PATCH 1/4] optional layer for labels added an option to create a layer for dot text in rhino --- src/compas_rhino/utilities/drawing.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/compas_rhino/utilities/drawing.py b/src/compas_rhino/utilities/drawing.py index 207e75c76720..6542dc376468 100644 --- a/src/compas_rhino/utilities/drawing.py +++ b/src/compas_rhino/utilities/drawing.py @@ -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 }) @@ -143,6 +144,7 @@ def draw_labels(labels, **kwargs): text = label['text'] name = label.get('name', '') color = label.get('color', None) + layer = p.get('layer') size = label.get('fontsize', 10) font = label.get('font', 'Arial Regular') dot = TextDot(str(text), Point3d(*pos)) @@ -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) From 646e279a32594e125e30568e77bda0ae2c209314 Mon Sep 17 00:00:00 2001 From: nizartaha <38039580+nizartaha@users.noreply.github.com> Date: Mon, 30 Aug 2021 12:06:48 +0200 Subject: [PATCH 2/4] Update AUTHORS.md --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 8c720bcfad0a..8dc6f4182357 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -31,3 +31,4 @@ - Robin Godwyll <> [@robin-gdwl](https://github.com/robin-gdwl) - Mattis Koh <> [@mattiskoh](https://github.com/mattiskoh) - Andrea Ghensi <> [@sanzoghenzo](https://github.com/sanzoghenzo) +- Nizar Taha <> [@nizartaha](https://github.com/nizartaha) From 0b38a3308d290ab02c60b6eddcba0e8dc709ca0d Mon Sep 17 00:00:00 2001 From: nizartaha <38039580+nizartaha@users.noreply.github.com> Date: Mon, 30 Aug 2021 12:29:11 +0200 Subject: [PATCH 3/4] update draw_labels docstring --- src/compas_rhino/utilities/drawing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compas_rhino/utilities/drawing.py b/src/compas_rhino/utilities/drawing.py index 6542dc376468..21b47d158b71 100644 --- a/src/compas_rhino/utilities/drawing.py +++ b/src/compas_rhino/utilities/drawing.py @@ -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 ---------- From 68f1c66cb11b2066669c46fdcda135f3041ef840 Mon Sep 17 00:00:00 2001 From: nizartaha <38039580+nizartaha@users.noreply.github.com> Date: Mon, 30 Aug 2021 14:37:06 +0200 Subject: [PATCH 4/4] Typo --- src/compas_rhino/utilities/drawing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compas_rhino/utilities/drawing.py b/src/compas_rhino/utilities/drawing.py index 21b47d158b71..cd0e981786c9 100644 --- a/src/compas_rhino/utilities/drawing.py +++ b/src/compas_rhino/utilities/drawing.py @@ -144,7 +144,7 @@ def draw_labels(labels, **kwargs): text = label['text'] name = label.get('name', '') color = label.get('color', None) - layer = p.get('layer') + layer = label.get('layer') size = label.get('fontsize', 10) font = label.get('font', 'Arial Regular') dot = TextDot(str(text), Point3d(*pos))