Visualize robot Rhino 8

Hello Compas,

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 ?

Thanks,
Marco

Hello Marco,

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.

Hello,

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

Thanks,
Marco