Skip to content

Commit 18e8914

Browse files
committed
overwrite all options in draw call
1 parent 9d4be79 commit 18e8914

File tree

8 files changed

+46
-17
lines changed

8 files changed

+46
-17
lines changed

src/compas/artists/shapeartist.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ class ShapeArtist(Artist):
3838
default_color = (1, 1, 1)
3939

4040
def __init__(self, shape, color=None, **kwargs):
41-
super(ShapeArtist, self).__init__(**kwargs)
41+
super(ShapeArtist, self).__init__()
4242
self._u = None
4343
self._v = None
4444
self._shape = None
4545
self._color = None
4646
self.shape = shape
4747
self.color = color
48+
self.u = kwargs.get('u')
49+
self.v = kwargs.get('v')
4850

4951
@property
5052
def shape(self):
@@ -73,7 +75,7 @@ def u(self):
7375

7476
@u.setter
7577
def u(self, u):
76-
if u > 3:
78+
if u and u > 3:
7779
self._u = u
7880

7981
@property
@@ -84,5 +86,5 @@ def v(self):
8486

8587
@v.setter
8688
def v(self, v):
87-
if v > 3:
89+
if v and v > 3:
8890
self._v = v

src/compas_blender/artists/boxartist.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@ def __init__(self,
2727

2828
super().__init__(shape=box, collection=collection or box.name, **kwargs)
2929

30-
def draw(self):
30+
def draw(self, color=None):
3131
"""Draw the box associated with the artist.
3232
33+
Parameters
34+
----------
35+
color : tuple of float, optional
36+
The RGB color of the box.
37+
3338
Returns
3439
-------
3540
list
3641
The objects created in Blender.
3742
"""
43+
color = color or self.color
3844
vertices, faces = self.shape.to_vertices_and_faces()
39-
obj = compas_blender.draw_mesh(vertices, faces, name=self.shape.name, color=self.color, collection=self.collection)
45+
obj = compas_blender.draw_mesh(vertices, faces, name=self.shape.name, color=color, collection=self.collection)
4046
return [obj]

src/compas_blender/artists/capsuleartist.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ def __init__(self,
2828

2929
super().__init__(shape=capsule, collection=collection or capsule.name, **kwargs)
3030

31-
def draw(self, u=None, v=None):
31+
def draw(self, color=None, u=None, v=None):
3232
"""Draw the capsule associated with the artist.
3333
3434
Parameters
3535
----------
36+
color : tuple of float, optional
37+
The RGB color of the capsule.
3638
u : int, optional
3739
Number of faces in the "u" direction.
3840
Default is ``~CapsuleArtist.u``.
@@ -47,6 +49,7 @@ def draw(self, u=None, v=None):
4749
"""
4850
u = u or self.u
4951
v = v or self.v
52+
color = color or self.color
5053
vertices, faces = self.shape.to_vertices_and_faces(u=u, v=v)
51-
obj = compas_blender.draw_mesh(vertices, faces, name=self.shape.name, color=self.color, collection=self.collection)
54+
obj = compas_blender.draw_mesh(vertices, faces, name=self.shape.name, color=color, collection=self.collection)
5255
return [obj]

src/compas_blender/artists/coneartist.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ def __init__(self,
2828

2929
super().__init__(shape=cone, collection=collection or cone.name, **kwargs)
3030

31-
def draw(self, u=None):
31+
def draw(self, color=None, u=None):
3232
"""Draw the cone associated with the artist.
3333
3434
Parameters
3535
----------
36+
color : tuple of float, optional
37+
The RGB color of the cone.
3638
u : int, optional
3739
Number of faces in the "u" direction.
3840
Default is ``~ConeArtist.u``.
@@ -43,6 +45,7 @@ def draw(self, u=None):
4345
The objects created in Blender.
4446
"""
4547
u = u or self.u
48+
color = color or self.color
4649
vertices, faces = self.shape.to_vertices_and_faces(u=u)
47-
obj = compas_blender.draw_mesh(vertices, faces, name=self.shape.name, color=self.color, collection=self.collection)
50+
obj = compas_blender.draw_mesh(vertices, faces, name=self.shape.name, color=color, collection=self.collection)
4851
return [obj]

src/compas_blender/artists/cylinderartist.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ def __init__(self,
2828

2929
super().__init__(shape=cylinder, collection=collection or cylinder.name, **kwargs)
3030

31-
def draw(self, u=None):
31+
def draw(self, color=None, u=None):
3232
"""Draw the cylinder associated with the artist.
3333
3434
Parameters
3535
----------
36+
color : tuple of float, optional
37+
The RGB color of the cylinder.
3638
u : int, optional
3739
Number of faces in the "u" direction.
3840
Default is ``~CylinderArtist.u``.
@@ -43,6 +45,7 @@ def draw(self, u=None):
4345
The objects created in Blender.
4446
"""
4547
u = u or self.u
48+
color = color or self.color
4649
vertices, faces = self.shape.to_vertices_and_faces(u=u)
47-
obj = compas_blender.draw_mesh(vertices, faces, name=self.shape.name, color=self.color, collection=self.collection)
50+
obj = compas_blender.draw_mesh(vertices, faces, name=self.shape.name, color=color, collection=self.collection)
4851
return [obj]

src/compas_blender/artists/polyhedronartist.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@ def __init__(self,
2727

2828
super().__init__(shape=polyhedron, collection=collection or polyhedron.name, **kwargs)
2929

30-
def draw(self):
30+
def draw(self, color=None):
3131
"""Draw the polyhedron associated with the artist.
3232
33+
Parameters
34+
----------
35+
color : tuple of float, optional
36+
The RGB color of the polyhedron.
37+
3338
Returns
3439
-------
3540
list
3641
The objects created in Blender.
3742
"""
43+
color = color or self.color
3844
vertices, faces = self.shape.to_vertices_and_faces()
39-
obj = compas_blender.draw_mesh(vertices, faces, name=self.shape.name, color=self.color, collection=self.collection)
45+
obj = compas_blender.draw_mesh(vertices, faces, name=self.shape.name, color=color, collection=self.collection)
4046
return [obj]

src/compas_blender/artists/sphereartist.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ def __init__(self,
2828

2929
super().__init__(shape=sphere, collection=collection or sphere.name, **kwargs)
3030

31-
def draw(self, u=None, v=None):
31+
def draw(self, color=None, u=None, v=None):
3232
"""Draw the sphere associated with the artist.
3333
3434
Parameters
3535
----------
36+
color : tuple of float, optional
37+
The RGB color of the sphere.
3638
u : int, optional
3739
Number of faces in the "u" direction.
3840
Default is ``~SphereArtist.u``.
@@ -47,6 +49,7 @@ def draw(self, u=None, v=None):
4749
"""
4850
u = u or self.u
4951
v = v or self.v
52+
color = color or self.color
5053
vertices, faces = self.shape.to_vertices_and_faces(u=u, v=v)
51-
obj = compas_blender.draw_mesh(vertices, faces, name=self.shape.name, color=self.color, collection=self.collection)
54+
obj = compas_blender.draw_mesh(vertices, faces, name=self.shape.name, color=color, collection=self.collection)
5255
return [obj]

src/compas_blender/artists/torusartist.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ def __init__(self,
2828

2929
super().__init__(shape=torus, collection=collection or torus.name, **kwargs)
3030

31-
def draw(self, u=None, v=None):
31+
def draw(self, color=None, u=None, v=None):
3232
"""Draw the torus associated with the artist.
3333
3434
Parameters
3535
----------
36+
color : tuple of float, optional
37+
The RGB color of the torus.
3638
u : int, optional
3739
Number of faces in the "u" direction.
3840
Default is ``~TorusArtist.u``.
@@ -47,6 +49,7 @@ def draw(self, u=None, v=None):
4749
"""
4850
u = u or self.u
4951
v = v or self.v
52+
color = color or self.color
5053
vertices, faces = self.shape.to_vertices_and_faces(u=u, v=v)
51-
obj = compas_blender.draw_mesh(vertices, faces, name=self.shape.name, color=self.color, collection=self.collection)
54+
obj = compas_blender.draw_mesh(vertices, faces, name=self.shape.name, color=color, collection=self.collection)
5255
return [obj]

0 commit comments

Comments
 (0)