Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

item as kwarg #1353

Merged
merged 18 commits into from
Jun 11, 2024
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
Licini marked this conversation as resolved.
Show resolved Hide resolved
# 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
Loading