Rhino 8 Feature: RhinoCode (CPython, CSharp)

Hi Ehsan,

I am trying out the new rhinocode with some old scripts and found that the propertylistbox code that worked fine in the R7 ironpython environment does not work in rhinocode:

Also this is at the top:
import rhinoscriptsyntax as rs

I hope this is the right place to report bugs. I’m on Windows 10.

It does not need an Scripting enviroment. It uses Visual Studio. Which is much better.

I’m getting a strange error trying to run a display conduit example from the developer samples:

  • Script:
import rhinoscriptsyntax as rs
from scriptcontext import doc
import Rhino
import System
import System.Drawing

class DrawBlueMeshConduit(Rhino.Display.DisplayConduit):
    def __init__(self, mesh):
        self.mesh = mesh
        self.color = System.Drawing.Color.Blue
        self.material = Rhino.Display.DisplayMaterial()
        self.material.Diffuse = self.color
        if mesh != None and mesh.IsValid:
            self.bbox = mesh.GetBoundingBox(True)

    def CalculateBoundingBox(self, calculateBoundingBoxEventArgs):
        #super.CalculateBoundingBox(calculateBoundingBoxEventArgs)
        calculateBoundingBoxEventArgs.BoundingBox.Union(self.bbox)

    def PreDrawObjects(self, drawEventArgs):
        #base.PreDrawObjects(rawEventArgs)
        gvp = drawEventArgs.Display.Viewport
        if gvp.DisplayMode.EnglishName.ToLower() == "wireframe":
            drawEventArgs.Display.DrawMeshWires(self.mesh, self.color)
        else:
            drawEventArgs.Display.DrawMeshShaded(self.mesh, self.material)

def RunCommand():
    gs = Rhino.Input.Custom.GetObject()
    gs.SetCommandPrompt("select sphere")
    gs.GeometryFilter = Rhino.DocObjects.ObjectType.Surface
    gs.DisablePreSelect()
    gs.SubObjectSelect = False
    gs.Get()
    if gs.CommandResult() != Rhino.Commands.Result.Success:
        return gs.CommandResult()

    b, sphere = gs.Object(0).Surface().TryGetSphere()
    if sphere.IsValid:
        mesh = Rhino.Geometry.Mesh.CreateFromSphere(sphere, 10, 10)
        if mesh == None:
            return Rhino.Commands.Result.Failure

        conduit = DrawBlueMeshConduit(mesh)
        conduit.Enabled = True
        doc.Views.Redraw()

        inStr = rs.GetString("press <Enter> to continue")

        conduit.Enabled = False
        doc.Views.Redraw()
        return Rhino.Commands.Result.Success
    else:
        return Rhino.Commands.Result.Failure

if __name__ == "__main__":
    RunCommand()
  • error:
cannot instantiate abstract class
  File "/var/folders/gj/j81x27gd40914bh_ws48x_bc0000gp/T/tmpQcXQuc.tmp", line 44, in RunCommand
    conduit = DrawBlueMeshConduit(mesh)
  File "/var/folders/gj/j81x27gd40914bh_ws48x_bc0000gp/T/tmpQcXQuc.tmp", line 59, in <module>
    RunCommand()
   at Python.Runtime.PythonException.ThrowLastAsClrException() in /Users/bozo/TeamCity/buildAgent/work/96e64af5b81c6f85/src4/rhino4/Plug-ins/RhinoCodePlugins/src/lib/McNeel.PythonNet/src/runtime/pythonexception.cs:line 49
   at Python.Runtime.PythonException.ThrowIfIsNull(NewReference& ob) in /Users/bozo/TeamCity/buildAgent/work/96e64af5b81c6f85/src4/rhino4/Plug-ins/RhinoCodePlugins/src/lib/McNeel.PythonNet/src/runtime/pythonexception.cs:line 456
   at Python.Runtime.PyModule.Execute(PyObject script, PyDict locals) in /Users/bozo/TeamCity/buildAgent/work/96e64af5b81c6f85/src4/rhino4/Plug-ins/RhinoCodePlugins/src/lib/McNeel.PythonNet/src/runtime/module.cs:line 235
   at Python.Runtime.RhinoCodePythonEngine.RunScope(String scopeName, String pythonFile, String bootstrapScript, Boolean tempFile, Boolean useCache) in /Users/bozo/TeamCity/buildAgent/work/96e64af5b81c6f85/src4/rhino4/Plug-ins/RhinoCodePlugins/src/lib/McNeel.PythonNet/src/runtime/McNeel.PythonEngine.cs:line 422

I’m not sure where /Users/bozo/ is coming from, definitely not a path on my computer, maybe this is the reason for the error?
Are sub-classes defined differently in pythonnet?
Is it too early to hope for display conduit functionality in rhinocode?
I’m running 8.0.22095.09346

Best,
Tristan

Hi guys,

Will RhinoCode allow the use of common Python GUI tools for development of cross platform user interfaces?

Has anyone got any samples they have done already?

I find the learning curve on ETO a little too steep to be productive.

Cheers

DK

Can you please explain, how did you import numpy in rhinocode?

Right On! Very excited to see more!!!

1 Like

Hi @eirannejad !
How is the development going?

1 Like

Is it possible to view the namespaces adjacent/within the editor yet? Or am I missing something?

1 Like

Pretty good. Getting ready to release a series of improvements soon.

4 Likes

Not yet. There is a help panel in the new editor (just like the old one) that will show help content. I’ll build that out during the “face lift” phase :smiley: )

Hmm, when will it available on a mac version?

It already is. This project is developed on both at the same time.

Hi Ehsan, this is an awesome development for Rhino, thank you. I’m trying to get into the code editor but my python starter files seem to be greyed out? The Python runtime initialize successfully, but the files are still greyed out.

Ok. Sorry for the bug. Open the Tools menu and from there open the logger window. I appreciate if you can share the log so I can see where is the problem

202206014_RhinoCodeLogger.txt (5.4 KB)
Ehsan, I attached the logger window report. Thank you so much for looking into this for me.

Seems like your system has SSL connection issue with the python package server. Might be a security setting on your machine. Try deleting the ~/.rhinocode (C:\Users\KadimA\.rhinocode\ on your machine) folder. Then disconnect your internet, start Rhino and RhinoCode and let python init itself from it’s embedded packages.

That should go thru smoothly. :crossed_fingers:


hello, guys!
a tried opened de rhincode, but don’t work. What can be?
my python version is 3.9.10
i tried connect vs code and rhino throught extension plugin, but don’t work too

@Raul_Simelmann
Seems like you tried to open a workspace with some codes in it? The error says that it can’t open the temporary files the codes were stored it. What do you specifically do when this error happens? Do you see that when opening a script from a path?

For the vscode issue, give me a bit more detail please.

Yes it does. You simply do not need to use it.

@mi_sprinzl
I’m sorry I have a hard time following this. Is this a reply to someone? Do not use what?