-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1200 from compas-dev/ellipse-artists
Add ellipse artists for rhino/gh
- Loading branch information
Showing
7 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ Classes | |
ConeArtist | ||
CurveArtist | ||
CylinderArtist | ||
EllipseArtist | ||
FrameArtist | ||
LineArtist | ||
MeshArtist | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ Classes | |
ConeArtist | ||
CurveArtist | ||
CylinderArtist | ||
EllipseArtist | ||
FrameArtist | ||
LineArtist | ||
MeshArtist | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from __future__ import print_function | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
|
||
from compas_rhino import conversions | ||
|
||
from compas.artists import GeometryArtist | ||
from .artist import GHArtist | ||
|
||
|
||
class EllipseArtist(GHArtist, GeometryArtist): | ||
"""Artist for drawing ellipses. | ||
Parameters | ||
---------- | ||
ellipse : :class:`~compas.geometry.Ellipse` | ||
A COMPAS ellipse. | ||
**kwargs : dict, optional | ||
Additional keyword arguments. | ||
""" | ||
|
||
def __init__(self, ellipse, **kwargs): | ||
super(EllipseArtist, self).__init__(geometry=ellipse, **kwargs) | ||
|
||
def draw(self): | ||
"""Draw the ellipse. | ||
Returns | ||
------- | ||
:rhino:`Rhino.Geometry.Ellipse` | ||
""" | ||
ellipse = conversions.ellipse_to_rhino(self.geometry) | ||
|
||
if self.transformation: | ||
transformation = conversions.transformation_to_rhino(self.transformation) | ||
ellipse.Transform(transformation) | ||
|
||
return ellipse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from __future__ import print_function | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
|
||
import scriptcontext as sc # type: ignore | ||
|
||
from compas.artists import GeometryArtist | ||
from compas.colors import Color | ||
from compas_rhino.conversions import ellipse_to_rhino | ||
|
||
from compas_rhino.conversions import transformation_to_rhino | ||
from .artist import RhinoArtist | ||
from ._helpers import attributes | ||
|
||
|
||
class EllipseArtist(RhinoArtist, GeometryArtist): | ||
"""Artist for drawing ellipses. | ||
Parameters | ||
---------- | ||
ellipse : :class:`~compas.geometry.Ellipse` | ||
A COMPAS ellipse. | ||
**kwargs : dict, optional | ||
Additional keyword arguments. | ||
""" | ||
|
||
def __init__(self, ellipse, **kwargs): | ||
super(EllipseArtist, self).__init__(geometry=ellipse, **kwargs) | ||
|
||
def draw(self, color=None): | ||
"""Draw the ellipse. | ||
Parameters | ||
---------- | ||
color : rgb1 | rgb255 | :class:`~compas.colors.Color`, optional | ||
The RGB color of the ellipse. | ||
Returns | ||
------- | ||
System.Guid | ||
The GUID of the created Rhino object. | ||
""" | ||
color = Color.coerce(color) or self.color | ||
attr = attributes(name=self.geometry.name, color=color, layer=self.layer) | ||
|
||
geometry = ellipse_to_rhino(self.geometry) | ||
|
||
if self.transformation: | ||
geometry.Transform(transformation_to_rhino(self.transformation)) | ||
|
||
return sc.doc.Objects.AddEllipse(geometry, attr) |