Skip to content

Commit 0682665

Browse files
authored
Merge pull request #788 from compas-dev/rhino-scene-objects
Fix bugs in Rhino scene objets
2 parents 3be3fc1 + fca0407 commit 0682665

File tree

11 files changed

+262
-68
lines changed

11 files changed

+262
-68
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
* Fixed bug where `compas_rhino.BaseArtist.redraw` did not trigger a redraw.
2525
* Fixed minor bugs in `compas.geometry.Polyline` and `compas.geometry.Polygon`.
2626
* Fixed very minor bugs in `compas.geometry.Frame` and `compas.geometry.Quaternion`.
27+
* Fixed bug in `compas_rhino.objects.MeshObject.modify`.
28+
* Fixed bug in `compas_rhino.objects.MeshObject.modify_vertices`.
29+
* Fixed bug in `compas_rhino.objects.MeshObject.modify_edges`.
30+
* Fixed bug in `compas_rhino.objects.MeshObject.modify_faces`.
31+
* Fixed bug in `compas_rhino.objects.VolMeshObject.modify`.
32+
* Fixed bug in `compas_rhino.objects.VolMeshObject.modify_vertices`.
33+
* Fixed bug in `compas_rhino.objects.VolMeshObject.modify_edges`.
34+
* Fixed bug in `compas_rhino.objects.VolMeshObject.modify_faces`.
35+
* Fixed bug in `compas_rhino.objects.NetworkObject.modify`.
36+
* Fixed bug in `compas_rhino.objects.NetworkObject.modify_vertices`.
37+
* Fixed bug in `compas_rhino.objects.NetworkObject.modify_edges`.
38+
* Changed `compas_rhino.objects.inspect` to `compas_rhino.objects.inspectors`.
39+
* Changed `compas_rhino.objects.select` to `compas_rhino.objects._select`.
40+
* Changed `compas_rhino.objects.modify` to `compas_rhino.objects._modify`.
2741

2842
### Removed
2943

src/compas_rhino/objects/__init__.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,32 @@
5353
"""
5454
from __future__ import absolute_import
5555

56-
from .select import * # noqa : F401 F403
57-
from .modify import * # noqa : F401 F403
58-
from .inspect import * # noqa : F401 F403
56+
from ._select import ( # noqa : F401 F403
57+
mesh_select_vertex,
58+
mesh_select_vertices,
59+
mesh_select_face,
60+
mesh_select_faces,
61+
mesh_select_edge,
62+
mesh_select_edges,
63+
network_select_node,
64+
network_select_nodes,
65+
network_select_edge,
66+
network_select_edges
67+
)
68+
from ._modify import ( # noqa : F401 F403
69+
network_update_attributes,
70+
network_update_node_attributes,
71+
network_update_edge_attributes,
72+
network_move_node,
73+
mesh_update_attributes,
74+
mesh_update_vertex_attributes,
75+
mesh_update_face_attributes,
76+
mesh_update_edge_attributes,
77+
mesh_move_vertex,
78+
mesh_move_vertices,
79+
mesh_move_face
80+
)
81+
from .inspectors import MeshVertexInspector # noqa : F401 F403
5982

6083
from ._object import BaseObject
6184
from .meshobject import MeshObject

src/compas_rhino/objects/modify/datastructures.py renamed to src/compas_rhino/objects/_modify.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from __future__ import division
44

55
import ast
6-
76
import compas_rhino
87

98
from compas.geometry import add_vectors

src/compas_rhino/objects/meshobject.py

Lines changed: 81 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
from compas.geometry import subtract_vectors
1414
from compas.geometry import add_vectors
1515
from compas.geometry import scale_vector
16-
from compas_rhino.objects._object import BaseObject
17-
from compas_rhino.objects.modify import mesh_update_attributes
18-
from compas_rhino.objects.modify import mesh_update_vertex_attributes
19-
from compas_rhino.objects.modify import mesh_update_face_attributes
20-
from compas_rhino.objects.modify import mesh_update_edge_attributes
21-
from compas_rhino.objects.modify import mesh_move_vertex
22-
from compas_rhino.objects.modify import mesh_move_vertices
23-
from compas_rhino.objects.modify import mesh_move_face
16+
17+
from ._modify import mesh_update_attributes
18+
from ._modify import mesh_update_vertex_attributes
19+
from ._modify import mesh_update_face_attributes
20+
from ._modify import mesh_update_edge_attributes
21+
from ._modify import mesh_move_vertex
22+
from ._modify import mesh_move_vertices
23+
from ._modify import mesh_move_face
24+
25+
from ._object import BaseObject
2426

2527

2628
__all__ = ['MeshObject']
@@ -62,11 +64,6 @@ class MeshObject(BaseObject):
6264
'show.facenormals': False,
6365
}
6466

65-
modify = mesh_update_attributes
66-
modify_vertices = mesh_update_vertex_attributes
67-
modify_faces = mesh_update_face_attributes
68-
modify_edges = mesh_update_edge_attributes
69-
7067
def __init__(self, mesh, scene=None, name=None, layer=None, visible=True, settings=None):
7168
super(MeshObject, self).__init__(mesh, scene, name, layer, visible)
7269
self._guids = []
@@ -103,12 +100,6 @@ def mesh(self, mesh):
103100
self._guid_edgelabel = {}
104101
self._guid_facelabel = {}
105102

106-
# def __getstate__(self):
107-
# pass
108-
109-
# def __setstate__(self, state):
110-
# pass
111-
112103
@property
113104
def anchor(self):
114105
"""The vertex of the mesh that is anchored to the location of the object."""
@@ -395,6 +386,77 @@ def select_edges(self, message="Select edges."):
395386
edges = [self.guid_edge[guid] for guid in guids if guid in self.guid_edge]
396387
return edges
397388

389+
def modify(self):
390+
"""Update the attributes of the mesh.
391+
392+
Returns
393+
-------
394+
bool
395+
``True`` if the update was successful.
396+
``False`` otherwise.
397+
"""
398+
return mesh_update_attributes(self.mesh)
399+
400+
def modify_vertices(self, vertices, names=None):
401+
"""Update the attributes of selected vertices.
402+
403+
Parameters
404+
----------
405+
vertices : list
406+
The vertices of the vertices of which the attributes should be updated.
407+
names : list, optional
408+
The names of the attributes that should be updated.
409+
Default is to update all available attributes.
410+
411+
Returns
412+
-------
413+
bool
414+
True if the attributes were successfully updated.
415+
False otherwise.
416+
417+
"""
418+
return mesh_update_vertex_attributes(self.mesh, vertices, names=names)
419+
420+
def modify_edges(self, edges, names=None):
421+
"""Update the attributes of the edges.
422+
423+
Parameters
424+
----------
425+
edges : list
426+
The edges to update.
427+
names : list, optional
428+
The names of the atrtibutes to update.
429+
Default is to update all attributes.
430+
431+
Returns
432+
-------
433+
bool
434+
``True`` if the update was successful.
435+
``False`` otherwise.
436+
437+
"""
438+
return mesh_update_edge_attributes(self.mesh, edges, names=names)
439+
440+
def modify_faces(self, faces, names=None):
441+
"""Update the attributes of selected faces.
442+
443+
Parameters
444+
----------
445+
vertices : list
446+
The vertices of the vertices of which the attributes should be updated.
447+
names : list, optional
448+
The names of the attributes that should be updated.
449+
Default is to update all available attributes.
450+
451+
Returns
452+
-------
453+
bool
454+
True if the attributes were successfully updated.
455+
False otherwise.
456+
457+
"""
458+
return mesh_update_face_attributes(self.mesh, faces, names=names)
459+
398460
# not clear if this is now about the location or the data
399461
def move(self):
400462
"""Move the entire mesh object to a different location."""

src/compas_rhino/objects/modify/__init__.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/compas_rhino/objects/networkobject.py

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
from compas.geometry import Scale
88
from compas.geometry import Translation
99
from compas.geometry import Rotation
10-
from compas_rhino.objects._object import BaseObject
11-
from compas_rhino.objects.modify import network_update_attributes
12-
from compas_rhino.objects.modify import network_update_node_attributes
13-
from compas_rhino.objects.modify import network_update_edge_attributes
14-
from compas_rhino.objects.modify import network_move_node
10+
11+
from ._modify import network_update_attributes
12+
from ._modify import network_update_node_attributes
13+
from ._modify import network_update_edge_attributes
14+
from ._modify import network_move_node
15+
16+
from ._object import BaseObject
1517

1618

1719
__all__ = ['NetworkObject']
@@ -46,10 +48,6 @@ class NetworkObject(BaseObject):
4648
'show.edgelabels': False,
4749
}
4850

49-
modify = network_update_attributes
50-
modify_nodes = network_update_node_attributes
51-
modify_edges = network_update_edge_attributes
52-
5351
def __init__(self, network, scene=None, name=None, layer=None, visible=True, settings=None):
5452
super(NetworkObject, self).__init__(network, scene, name, layer, visible)
5553
self._guid_node = {}
@@ -77,12 +75,6 @@ def network(self, network):
7775
self._guid_nodelabel = {}
7876
self._guid_edgelabel = {}
7977

80-
# def __getstate__(self):
81-
# pass
82-
83-
# def __setstate__(self, state):
84-
# pass
85-
8678
@property
8779
def anchor(self):
8880
"""The node of the network that is anchored to the location of the object."""
@@ -274,6 +266,56 @@ def select_edges(self):
274266
edges = [self.guid_edge[guid] for guid in guids if guid in self.guid_edge]
275267
return edges
276268

269+
def modify(self):
270+
"""Update the attributes of the network.
271+
272+
Returns
273+
-------
274+
bool
275+
``True`` if the update was successful.
276+
``False`` otherwise.
277+
"""
278+
return network_update_attributes(self.network)
279+
280+
def modify_nodes(self, nodes, names=None):
281+
"""Update the attributes of the nodes.
282+
283+
Parameters
284+
----------
285+
nodes : list
286+
The identifiers of the nodes to update.
287+
names : list, optional
288+
The names of the atrtibutes to update.
289+
Default is to update all attributes.
290+
291+
Returns
292+
-------
293+
bool
294+
``True`` if the update was successful.
295+
``False`` otherwise.
296+
297+
"""
298+
return network_update_node_attributes(self.network, nodes, names=names)
299+
300+
def modify_edges(self, edges, names=None):
301+
"""Update the attributes of the edges.
302+
303+
Parameters
304+
----------
305+
edges : list
306+
The identifiers of the edges to update.
307+
names : list, optional
308+
The names of the atrtibutes to update.
309+
Default is to update all attributes.
310+
311+
Returns
312+
-------
313+
bool
314+
``True`` if the update was successful.
315+
``False`` otherwise.
316+
"""
317+
return network_update_edge_attributes(self.network, edges, names=names)
318+
277319
def move(self):
278320
"""Move the entire mesh object to a different location."""
279321
raise NotImplementedError

src/compas_rhino/objects/select/__init__.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)