it seems I can’t have this basic example file to run in Rhino 8. I only tested Version 8 SR9 (8.9.24194.18121, 2024-07-12).
Here a list of the exceptions I get for the different installations of compas_fab:
IronPython, installed via conda-forge.
Message: init() takes exactly 2 arguments (4 given)
Traceback:
line 107, in add, “C:\Users\xyz\anaconda3\envs\compas-dev\Lib\site-packages\compas\scene\scene.py”
line 16, in , “C:\Users\xyz\AppData\Local\Temp\TempScript.py”
Cpython, installed with pip from ./rhinocode/py39-rh8
Traceback (most recent call last):
File “file:///C:/Users/xyz/.rhinocode/stage/eo44qpbf.lzk”, line 16, in
File “C:\Users\xyz.rhinocode\py39-rh8\lib\site-packages\compas\scene\scene.py”, line 107, in add
sceneobject = SceneObject(item=item, context=self.context, **kwargs) # type: ignore
File “C:\Users\xyz.rhinocode\py39-rh8\lib\site-packages\compas\scene\sceneobject.py”, line 88, in new
sceneobject_cls = get_sceneobject_cls(item, **kwargs)
File “C:\Users\xyz.rhinocode\py39-rh8\lib\site-packages\compas\scene\context.py”, line 152, in get_sceneobject_cls
cls = _get_sceneobject_cls(item, **kwargs)
File “C:\Users\xyz.rhinocode\py39-rh8\lib\site-packages\compas\scene\context.py”, line 140, in _get_sceneobject_cls
raise SceneObjectNotRegisteredError(“No scene object is registered for this data type: {} in this context: {}”.format(dtype, context_name))
SceneObjectNotRegisteredError: No scene object is registered for this data type: <class ‘compas_robots.model.robot.RobotModel’> in this context: Rhino
Cpython, installed via conda-forge
ImportError: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python interpreter from there.
Any suggestion on how to approach this?
Or am I missing other official methods for visualizing a .urdf in Rhino8 ?
I can reproduce your problem.
I believe there is a bug in compas_robot, but first, I need to confirm with Gonzalo.
In the meantime, if you want to give it a try. go to the compas_robot installation folder, open the following file : src\compas_robots\rhino\scene\robotmodelobject.py In line 34, it should be super(RobotModelObject, self).__init__(model=model, **kwargs)
change that to super(RobotModelObject, self).__init__(item=model, **kwargs)
Then run the demo file in Rhino (Tools → PythonScript → Edit). This worked for me. The second execution method of running the file in cpython outside Rhino will not work if your intention is to visualize that in Rhino.
that still produces the following error, from both RhinoScript editor and from Grasshopper Python editor:
Traceback (most recent call last):
File “file:///C:/Users/frist/Desktop/test.py”, line 16, in
File “C:\Users\frist.rhinocode\py39-rh8\lib\site-packages\compas\scene\scene.py”, line 115, in add
sceneobject = SceneObject(item=item, context=self.context, **kwargs) # type: ignore
File “C:\Users\frist.rhinocode\py39-rh8\lib\site-packages\compas\scene\sceneobject.py”, line 88, in new
sceneobject_cls = get_sceneobject_cls(item, **kwargs)
File “C:\Users\frist.rhinocode\py39-rh8\lib\site-packages\compas\scene\context.py”, line 152, in get_sceneobject_cls
cls = _get_sceneobject_cls(item, **kwargs)
File “C:\Users\frist.rhinocode\py39-rh8\lib\site-packages\compas\scene\context.py”, line 140, in _get_sceneobject_cls
raise SceneObjectNotRegisteredError(“No scene object is registered for this data type: {} in this context: {}”.format(dtype, context_name))
SceneObjectNotRegisteredError: No scene object is registered for this data type: <class ‘compas_robots.model.robot.RobotModel’> in this context: Rhino
Hi!
I am having the same issue (error messages, etc.) with Rhino 7. The fix you, @yck011522, provided unfortunately didn’t resolve it either and I still get the same error messages. Is there anything else I could try to fix it or is there maybe coming an update soon?
Any help would be appreciated!
Hi Alicia, do you mind provide me with a more detailed description of your system config so I can reproduce your problem? Below is a template, see if you can provide me with whatever is relevant for you:
Describe the bug
Add a clear and concise description of what the bug is.
Thanks for the reply! I am using Rhino 7 on windows 11 and if I try tor run eg. this script in Rhino (Rhino Python Editor) which I found in the compas_fab documentation:
from compas_fab.backends import RosClient
from compas.scene import Scene
with RosClient() as ros:
# Load complete model from ROS
robot = ros.load_robot(load_geometry=True, precision=12)
# Visualize robot
scene = Scene()
scene_object = scene.add(robot.model)
scene.draw()
Traceback:
line 116, in add, “C:\Users\alici\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas\scene\scene.py”
line 10, in , “C:\Users\alici\AppData\Local\Temp\TempScript.py”
I am guessing there is some issue with the robotmodelobject, because the add function in the scene class doesn’t work with the robot.model. I tried with eg. a box and the visualization worked, just not with the robot.
Also thank you @Marco_Palma, I tried with the compas_fab version 0.27.0 and the visualization worked!
If you, @yck011522 need any more info, please let me know.
Traceback (most recent call last):
File "file:///C:/Users/frist/.rhinocode/stage/newwjb1i.yqv", line 16, in <module>
File "C:\Users\frist\.rhinocode\py39-rh8\lib\site-packages\compas\scene\scene.py", line 115, in add
sceneobject = SceneObject(item=item, context=self.context, **kwargs) # type: ignore
File "C:\Users\frist\.rhinocode\py39-rh8\lib\site-packages\compas\scene\sceneobject.py", line 88, in __new__
sceneobject_cls = get_sceneobject_cls(item, **kwargs)
File "C:\Users\frist\.rhinocode\py39-rh8\lib\site-packages\compas\scene\context.py", line 152, in get_sceneobject_cls
cls = _get_sceneobject_cls(item, **kwargs)
File "C:\Users\frist\.rhinocode\py39-rh8\lib\site-packages\compas\scene\context.py", line 140, in _get_sceneobject_cls
raise SceneObjectNotRegisteredError("No scene object is registered for this data type: {} in this context: {}".format(dtype, context_name))
SceneObjectNotRegisteredError: No scene object is registered for this data type: <class 'compas_robots.model.robot.RobotModel'> in this context: Rhino
GH Robot Object registered.
Expected behavior
Visualize a RobotModel in Rhino 8.
Note
The same error triggers when replacing line 34 in src\compas_robots\rhino\scene\robotmodelobject.py, as per your above suggestion.
Thanks for your description. Regarding the problem of adding RobotModel to the scene, it is related to a recent change in the Scene, I’m not fully aware of the change but it appears to me that some parameter names may have been changed.
I’m afraid we need to wait a few more days before this gets resolved. If the older version worked for you, that is great for now. I only have Rhino 7 on my computer, and we need to wait for another developer who can test things on Rhino 8. However, I think this problem is not specific to the Rhino version.
I did some more investigation. The errors the two of you are seeing comes from a different origin. I’ve identified the problem for the Rhino 7 case and submitted a PR for it here:
The problem with Rhino 8 seems to be related to some failure in registering the RobotModelObject as a SceneObject for the Rhino context. This problem appears to be only affecting Rhino 8. I’ll wait for this PR to be merged first before starting that issue. I’m not familiar with the plugin system for registering scene objects.
I could successfully visualize a RobotModel in Rhino 8 with Compas v. 0.27.
That confirms your findings that is not a Rhino 8 issue, but of latest Compas versions (the ones which introduced the Scene class).