Skip to content

Commit

Permalink
item as kwarg
Browse files Browse the repository at this point in the history
  • Loading branch information
Licini committed May 13, 2024
1 parent 835f233 commit 42dcc41
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Changed imports of itertools to `compas.itertools` instead of `compas.utilities`.
* Updated `compas_rhino.conversions.point_to_compas` to allow for `Rhino.Geometry.Point` as input.
* Changed `compas.datastructures.Tree.print_hierarchy` to `compas.datastructures.Tree.__str__`.
* Changed `compas.scene.SceneObject.__init__` to accept `item` as kwarg.

### Removed

Expand Down
10 changes: 6 additions & 4 deletions src/compas/scene/sceneobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import compas.datastructures # noqa: F401
import compas.geometry # noqa: F401
from compas.colors import Color
from compas.data import Data
from compas.datastructures import TreeNode
from compas.geometry import Transformation

Expand Down Expand Up @@ -82,13 +83,14 @@ class SceneObject(TreeNode):

color = ColorAttribute()

def __new__(cls, item, **kwargs):
def __new__(cls, item=None, **kwargs):
sceneobject_cls = get_sceneobject_cls(item, **kwargs)
return super(SceneObject, cls).__new__(sceneobject_cls)

def __init__(self, item, name=None, color=None, opacity=1.0, show=True, frame=None, transformation=None, context=None, **kwargs): # fmt: skip
# type: (compas.geometry.Geometry | compas.datastructures.Datastructure, str | None, compas.colors.Color | None, float, bool, compas.geometry.Frame | None, compas.geometry.Transformation | None, str | None, dict) -> None
name = name or item.name
def __init__(self, item=None, name=None, color=None, opacity=1.0, show=True, frame=None, transformation=None, context=None, **kwargs): # fmt: skip
# type: (compas.data.Data | None, str | None, compas.colors.Color | None, float, bool, compas.geometry.Frame | None, compas.geometry.Transformation | None, str | None, dict) -> None
if isinstance(item, Data) and name is None:
name = item.name
super(SceneObject, self).__init__(name=name, **kwargs)
# the scene object needs to store the context
# because it has no access to the tree and/or the scene before it is added
Expand Down

0 comments on commit 42dcc41

Please sign in to comment.