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

MissingMemberException when trying to extend SceneObject #1273

Closed
chenkasirer opened this issue Jan 24, 2024 · 8 comments
Closed

MissingMemberException when trying to extend SceneObject #1273

chenkasirer opened this issue Jan 24, 2024 · 8 comments
Assignees
Labels

Comments

@chenkasirer
Copy link
Member

Been trying to create a new SceneObject implementation for something in COMPAS Timber and got this issue where it expects whatever item it wraps to have a name attribute.

I think the culprit is this line:

self.name = kwargs.get("name", item.name or item.__class__.__name__)

It seems it's supposed to take it from kwargs, from the instance or use the class name if the other two don't work. But really if the instance doesn't have name it always breaks.

Admittedly, I had to ask ChatGPT why this doesn't work cause for the life of me I couldn't figure it out, apparently the stuff around the or always gets evaluated..

@Licini maybe getattr(item, "name", item.__class__.__name__) instead?

To Reproduce
Steps to reproduce the behavior:

  1. Inherit from SceneObject
  2. Pass something that doesn't have attribute name as item.
Runtime error (MissingMemberException): 'FeatureApplicationError' object has no attribute 'name'

Traceback:
  line 25, in __init__, "C:\Users\ckasirer\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas_rhino\scene\sceneobject.py"
  line 73, in __init__, "C:\Users\ckasirer\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas\scene\sceneobject.py"
  line 15, in __init__, "C:\Users\ckasirer\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas_timber\rhino\scene\featureerrorobject.py"
  line 262, in add, "C:\Users\ckasirer\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas\scene\scene.py"
  line 11, in script

Expected behavior
Not assume name from item

Desktop (please complete the following information):

  • Rhino / GH
@tomvanmele
Copy link
Member

@chenkasirer if the item is a data class, how come it doesn't have a name attribute?

@chenkasirer
Copy link
Member Author

Does it have to be a Data? In my case I'm just trying to implement visualization of some custom errors for visual debugging in GH.

@tomvanmele
Copy link
Member

the entire setup is based on pairing compas.data.Data objects with compas.scene.SceneObject objects, so kind of :)

@tomvanmele
Copy link
Member

otherwise perhaps just use compas_rhino.conversions directly? this actually works well in GH...

@chenkasirer
Copy link
Member Author

Gotcha. Data it is then..

@chenkasirer
Copy link
Member Author

otherwise perhaps just use compas_rhino.conversions directly? this actually works well in GH...

it's a container for several (different) geometries and was thinking of a text label as well, but still figuring stuff out with the new Scene.

@tomvanmele
Copy link
Member

let me know if you need help...

@Licini
Copy link
Contributor

Licini commented Jan 26, 2024

If it's ok I'm closing this now, as our plan will be #1276

@Licini Licini closed this as completed Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants