File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
1010### Added
1111
12+ * Added ` compas.scene.Scene.find_by_name ` to find the first scene object with the given name.
13+ * Added ` compas.scene.Scene.find_by_itemtype ` to find the first scene object with a data item of the given type.
14+
1215### Changed
1316
1417### Removed
Original file line number Diff line number Diff line change 1+ import compas .data # noqa: F401
12import compas .datastructures # noqa: F401
23import compas .geometry # noqa: F401
34from compas .datastructures import Tree
@@ -211,3 +212,37 @@ def redraw(self):
211212
212213 self .clear (clear_scene = False , clear_context = True )
213214 self .draw ()
215+
216+ def find_by_name (self , name ):
217+ """Find the first scene object with the given name.
218+
219+ Parameters
220+ ----------
221+ name : str
222+ Name of the object.
223+
224+ Returns
225+ -------
226+ :class:`SceneObject`
227+
228+ """
229+ # type: (str) -> SceneObject
230+ return self .get_node_by_name (name = name )
231+
232+ def find_by_itemtype (self , itemtype ):
233+ """Find the first scene object with a data item of the given type.
234+
235+ Parameters
236+ ----------
237+ itemtype : :class:`compas.data.Data`
238+ The type of the data item associated with the scene object.
239+
240+ Returns
241+ -------
242+ :class:`SceneObject`
243+
244+ """
245+ # type: (Type[compas.data.Data]) -> SceneObject
246+ for obj in self .objects :
247+ if isinstance (obj .item , itemtype ):
248+ return obj
You can’t perform that action at this time.
0 commit comments