Skip to content

Commit 72c8cca

Browse files
committed
fix up
1 parent 9bb812c commit 72c8cca

File tree

4 files changed

+28
-41
lines changed

4 files changed

+28
-41
lines changed

src/compas_blender/artists/frameartist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class FrameArtist(BaseArtist):
6464
def __init__(self,
6565
frame: Frame,
6666
collection: Optional[bpy.types.Collection] = None,
67-
scale: Optional[float] = 1.0):
67+
scale: float = 1.0):
6868
super(FrameArtist, self).__init__()
6969
self.collection = collection
7070
self.frame = frame

src/compas_blender/artists/meshartist.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import List
44
from typing import Optional
55
from typing import Tuple
6+
from typing import Union
67

78
import bpy
89

@@ -18,6 +19,7 @@
1819
from compas.utilities import color_to_colordict
1920

2021
colordict = partial(color_to_colordict, colorformat='rgb', normalize=True)
22+
Color = Union[Tuple[int, int, int], Tuple[float, float, float]]
2123

2224

2325
__all__ = ['MeshArtist']
@@ -270,7 +272,7 @@ def draw_mesh(self) -> List[bpy.types.Object]:
270272

271273
def draw_vertices(self,
272274
vertices: Optional[List[int]] = None,
273-
color: Optional[str, Tuple, List, Dict] = None) -> List[bpy.types.Object]:
275+
color: Optional[str, Color, List[Color], Dict[int, Color]] = None) -> List[bpy.types.Object]:
274276
"""Draw a selection of vertices.
275277
276278
Parameters
@@ -302,7 +304,7 @@ def draw_vertices(self,
302304

303305
def draw_faces(self,
304306
faces: Optional[List[int]] = None,
305-
color: Optional[str, Tuple, List, Dict] = None) -> List[bpy.types.Object]:
307+
color: Optional[str, Color, List[Color], Dict[int, Color]] = None) -> List[bpy.types.Object]:
306308
"""Draw a selection of faces.
307309
308310
Parameters
@@ -332,8 +334,8 @@ def draw_faces(self,
332334
return objects
333335

334336
def draw_edges(self,
335-
edges: Optional[List[Tuple[int]]] = None,
336-
color: Optional[str, Tuple, List, Dict] = None) -> List[bpy.types.Object]:
337+
edges: Optional[List[Tuple[int, int]]] = None,
338+
color: Optional[str, Color, List[Color], Dict[int, Color]] = None) -> List[bpy.types.Object]:
337339
"""Draw a selection of edges.
338340
339341
Parameters
@@ -369,8 +371,8 @@ def draw_edges(self,
369371

370372
def draw_vertexnormals(self,
371373
vertices: Optional[List[int]] = None,
372-
color: Optional[str, Tuple, List, Dict] = None,
373-
scale: Optional[float] = 1.0) -> List[bpy.types.Object]:
374+
color: Optional[str, Color, List[Color], Dict[int, Color]] = None,
375+
scale: float = 1.0) -> List[bpy.types.Object]:
374376
"""Draw the normals at the vertices of the mesh.
375377
376378
Parameters
@@ -408,8 +410,8 @@ def draw_vertexnormals(self,
408410

409411
def draw_facenormals(self,
410412
faces: Optional[List[List[int]]] = None,
411-
color: Optional[str, Tuple, List, Dict] = None,
412-
scale: Optional[float] = 1.0) -> List[bpy.types.Object]:
413+
color: Optional[str, Color, List[Color], Dict[int, Color]] = None,
414+
scale: float = 1.0) -> List[bpy.types.Object]:
413415
"""Draw the normals of the faces.
414416
415417
Parameters
@@ -453,7 +455,7 @@ def draw_facenormals(self,
453455

454456
def draw_vertexlabels(self,
455457
text: Optional[Dict[int, str]] = None,
456-
color: Optional[str, Tuple, List, Dict] = None) -> List[bpy.types.Object]:
458+
color: Optional[str, Color, List[Color], Dict[int, Color]] = None) -> List[bpy.types.Object]:
457459
"""Draw labels for a selection vertices.
458460
459461
Parameters
@@ -490,8 +492,8 @@ def draw_vertexlabels(self,
490492
return objects
491493

492494
def draw_edgelabels(self,
493-
text: Optional[Dict[Tuple[int], str]] = None,
494-
color: Optional[str, Tuple, List, Dict] = None) -> List[bpy.types.Object]:
495+
text: Optional[Dict[Tuple[int, int], str]] = None,
496+
color: Optional[str, Color, List[Color], Dict[int, Color]] = None) -> List[bpy.types.Object]:
495497
"""Draw labels for a selection of edges.
496498
497499
Parameters
@@ -528,7 +530,7 @@ def draw_edgelabels(self,
528530

529531
def draw_facelabels(self,
530532
text: Optional[Dict[int, str]] = None,
531-
color: Optional[str, Tuple, List, Dict] = None) -> List[bpy.types.Object]:
533+
color: Optional[str, Color, List[Color], Dict[int, Color]] = None) -> List[bpy.types.Object]:
532534
"""Draw labels for a selection of faces.
533535
534536
Parameters

src/compas_blender/artists/networkartist.py

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import List
44
from typing import Optional
55
from typing import Tuple
6+
from typing import Union
67

78
import bpy
89
from functools import partial
@@ -14,6 +15,7 @@
1415
from compas.utilities import color_to_colordict
1516

1617
colordict = partial(color_to_colordict, colorformat='rgb', normalize=True)
18+
Color = Union[Tuple[int, int, int], Tuple[float, float, float]]
1719

1820

1921
__all__ = [
@@ -44,12 +46,10 @@ def __init__(self, network: Network):
4446
super().__init__()
4547
self._nodecollection = None
4648
self._edgecollection = None
47-
self._pathcollection = None
4849
self._nodelabelcollection = None
4950
self._edgelabelcollection = None
5051
self._object_node = {}
5152
self._object_edge = {}
52-
self._object_path = {}
5353
self._object_nodelabel = {}
5454
self._object_edgelabel = {}
5555
self.color_nodes = (1.0, 1.0, 1.0)
@@ -74,13 +74,6 @@ def edgecollection(self) -> bpy.types.Collection:
7474
self._edgecollection = compas_blender.create_collections_from_path(path)[1]
7575
return self._edgecollection
7676

77-
@property
78-
def pathcollection(self) -> bpy.types.Collection:
79-
path = f"{self.network.name}::Paths"
80-
if not self._pathcollection:
81-
self._pathcollection = compas_blender.create_collections_from_path(path)[1]
82-
return self._pathcollection
83-
8477
@property
8578
def nodelabelcollection(self) -> bpy.types.Collection:
8679
path = f"{self.network.name}::VertexLabels"
@@ -115,16 +108,6 @@ def object_edge(self) -> Dict[bpy.types.Object, Tuple[int, int]]:
115108
def object_edge(self, values):
116109
self._object_edge = dict(values)
117110

118-
@property
119-
def object_path(self) -> Dict[bpy.types.Object, List[int]]: # !!! what is a path?
120-
if not self._object_path:
121-
self._object_path = {}
122-
return self._object_path
123-
124-
@object_path.setter
125-
def object_path(self, values):
126-
self._object_path = dict(values)
127-
128111
@property
129112
def object_nodelabel(self) -> Dict[bpy.types.Object, int]:
130113
"""Map between Blender object objects and node label identifiers."""
@@ -146,13 +129,11 @@ def object_edgelabel(self, values):
146129
def clear(self) -> None:
147130
objects = list(self.object_node)
148131
objects += list(self.object_edge)
149-
objects += list(self.object_path)
150132
objects += list(self.object_nodelabel)
151133
objects += list(self.object_edgelabel)
152134
compas_blender.delete_objects(objects, purge_data=True)
153135
self._object_node = {}
154136
self._object_edge = {}
155-
self._object_path = {}
156137
self._object_nodelabel = {}
157138
self._object_edgelabel = {}
158139

@@ -173,7 +154,7 @@ def draw(self) -> None:
173154

174155
def draw_nodes(self,
175156
nodes: Optional[List[int]] = None,
176-
color: Optional[str, Tuple, List, Dict] = None) -> List[bpy.types.Object]:
157+
color: Optional[str, Color, List[Color], Dict[int, Color]] = None) -> List[bpy.types.Object]:
177158
"""Draw a selection of nodes.
178159
179160
Parameters
@@ -203,8 +184,8 @@ def draw_nodes(self,
203184
return objects
204185

205186
def draw_edges(self,
206-
edges: Optional[Tuple[int]] = None,
207-
color: Optional[str, Tuple, List, Dict] = None) -> List[bpy.types.Object]:
187+
edges: Optional[Tuple[int, int]] = None,
188+
color: Optional[str, Color, List[Color], Dict[int, Color]] = None) -> List[bpy.types.Object]:
208189
"""Draw a selection of edges.
209190
210191
Parameters
@@ -236,7 +217,7 @@ def draw_edges(self,
236217

237218
def draw_nodelabels(self,
238219
text: Optional[Dict[int, str]] = None,
239-
color: Optional[str, Tuple, List, Dict] = None) -> List[bpy.types.Object]:
220+
color: Optional[str, Color, List[Color], Dict[int, Color]] = None) -> List[bpy.types.Object]:
240221
"""Draw labels for a selection nodes.
241222
242223
Parameters
@@ -273,8 +254,8 @@ def draw_nodelabels(self,
273254
return objects
274255

275256
def draw_edgelabels(self,
276-
text: Optional[Dict[Tuple[int], str]] = None,
277-
color: Optional[str, Tuple, List, Dict] = None) -> List[bpy.types.Object]:
257+
text: Optional[Dict[Tuple[int, int], str]] = None,
258+
color: Optional[str, Color, List[Color], Dict[int, Color]] = None) -> List[bpy.types.Object]:
278259
"""Draw labels for a selection of edges.
279260
280261
Parameters

src/compas_blender/artists/robotmodelartist.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ def collection(self, value: Union[str, bpy.types.Collection]):
4545
def transform(self, native_mesh: bpy.types.Object, transformation: Transformation) -> None:
4646
native_mesh.matrix_world = mathutils.Matrix(transformation.matrix) @ native_mesh.matrix_world
4747

48-
def create_geometry(self, geometry: Union[Mesh, Shape], name: str = None, color: Tuple = None) -> bpy.types.Object:
48+
def create_geometry(self,
49+
geometry: Union[Mesh, Shape],
50+
name: str = None,
51+
color: Union[Tuple[int, int, int, int], Tuple[float, float, float, float]] = None
52+
) -> bpy.types.Object:
4953
# Imported colors take priority over a the parameter color
5054
if 'mesh_color.diffuse' in geometry.attributes:
5155
color = geometry.attributes['mesh_color.diffuse']

0 commit comments

Comments
 (0)