Toggle RhinoCAM on/off - scripts run 10-20x slower

Hi all, and thanks for those who responded to my previous script performance post.

Have finally gotten to the bottom of why scripts that should run in seconds were taking 30-60 seconds which I tried uninstalling RhinoCAM.

I queried RhinoCAM and received the following information. I’d hoped they might advised some specifics as I’m sure I’m not the first, but I’m going down the path they have suggested.

Is there a way to Load/Unload the RhinoCAM plugin on the fly, so that Rhino doesn’t have to be restarted? Like most people I often have multiple sessions open, which makes restarting quite a hassle!

Thanks,

Adrian

FROM MECSOFT

RhinoCAM, when loaded and active, resolves its internal database whenever new objects are created in Rhino. So if your script is creating objects constantly it is triggering RhinoCAM to reconstruct its database also. What I would suggest is to turn off RhinoCAM when the script is running and only make RhinoCAM active when it is needed - sort of a on-demand load of RhinoCAM. This could be managed in the Rhino script itself I would think. Rhino support will be able to help with the API calls needed to load and unload plug-ins, which can be used in your cabinet design script.

Hi Adrian -

I’m afraid not, no.

Also see:

-wim

@agmckenna - I’m happy to give you a trial license to KaroroCAM:

https://www.food4rhino.com/en/app/karorocam-cnc-gcode-cam-plugin-rhino-8

To see if this is suitable for your workflow and I’m almost 100% certain you will not have this issue you are seeing with RhinoCAM.

Let me know if/when you’d like to proceed.

Cheers

David Kay

I was curious about this so I ran a few quick tests here. First I created a script to make an array of boxes, add them to the document and time the result in Python/Rhinocommon. This was done in wireframe to avoid generating meshe. The script below adds 2500 boxes, but you can change that. I ran it first via EditScript (Py2) then in ScriptEditor (PY2 and PY3) as well as via a new toolbar button both PY2 and PY3; these with RhinoCAM 2025 enabled and disabled. Of course for Python 3 the line #! python 2 was changed to #! python 3 and the code was added to a blank new script for each version. I ran all this on my aging Lenovo P52 laptop.

#! python 2

import scriptcontext as sc
import Rhino, time

def MakeBox(plane,x, y, z):
    xi=Rhino.Geometry.Interval(0,x)
    yi=Rhino.Geometry.Interval(0,y)
    zi=Rhino.Geometry.Interval(0,z)
    return Rhino.Geometry.Box(plane,xi,yi,zi)

def CheckRCAddObjTime():
    boxes=[]
    xrange=50
    yrange=50
    xsize=10.0
    ysize=5.0
    zsize=2.0
    space=1.0
    plane=Rhino.Geometry.Plane.WorldXY
    st=time.time()
    for i in range(xrange):
        for j in range(yrange):
            plane.Origin=Rhino.Geometry.Point3d(i*(xsize+space),j*(ysize+space),0)
            boxes.append(MakeBox(plane,xsize,ysize,zsize))
    box_ids=[sc.doc.Objects.AddBox(box) for box in boxes]
    sc.doc.Views.Redraw()
    print("Elapsed time = {}".format(time.time()-st))
CheckRCAddObjTime()

The results were interesting.

Rhino with RhinoCAM disabled:

EditScript (P2): 0.095 sec avg.
ScriptEditor, P2: 0.1 sec avg.
ScriptEditor, P3: 0.25 sec avg.
Toolbar button P2: 0.08 sec avg.
Toolbar button P3: 0.08 sec avg.

Rhino with RhinoCAM enabled:

EditScript (P2): 0.12 sec avg.
ScriptEditor, P2: 1.0 sec avg.
ScriptEditor, P3: 1.1 sec avg.
Toolbar button P2: 0.08 sec avg.
Toolbar button P3: 0.08 sec avg.

So clearly for me the results point to a slowdown running the code from the ScriptEditor with RhinoCAM enabled. Even without RhinoCAM being enabled though, it is significantly slower than EditScript here either with Py2 or PY3. Maybe someone else can confirm. Running from a toolbar button no slowdown was observed.

I would expect this has to do with the script throwing events that RhinoCAM is watching for. So each time the database is updated RhinoCAm needs to do something.

Does turning off display update during the script may also help?

import rhinoscriptsyntax as rs
rs.EnableRedraw(False)

@scottd - that doesn’t correspond with my results above, but I don’t know what types of objects are being added by @agmckenna 's script that might trigger an event or something.

Yeah, for instance if the objects happen to have RhinoCam plugin data on them? Then does Rhinocam need to update that data each time there is a commit to the object table?

Thanks David @kiteboardshaper

Do you have any more screenshots or specificiations of this plugin?

I’m needing something that is compatible with Drill banks if that is something it offers?

RhinoCAM have offered to run my scripts and see if they can resolve whatever it going on, but ultimately we are after simplicity and a good flow. Plus getting the workflow right from nesting, toolpathing, labelling, etc.

Regards,

Adrian

Hi @agmckenna

For a demo you can download the full application via the Rhino Package Manager:

The only thing that requires a license key is the final G-code export.

For how to’s and real life applications you can check out the YouTube Channel:

What make and model are you CNC machines? I’ve got a range of built-in POSTs for different machines but can quickly custom write when required.

KaroroCAM does support drilling operations, I’ve not been asked for gang drilling support before but again, added this would not take long if required.

Also, on my future road map for KaroroCAM is Grasshopper components to allow custom GH work flows to directly create G-Code. I suspect this may be something that interests you and your application.

Also my design agency develops custom Rhino plugins, mostly in the translation of digital designs to machine control - KaroroCAM is an offshoot of this work. Maybe we could look at your current scripts and develop a complete application to solve your workflow.

Best regards,

David Kay
Rad Sky Development

Thanks David @kiteboardshaper ,

We have a Woodtron machine. 3600x1800 with auto loading, labelling and a gang drill.

Are you based in New Zealand? Watching a couple of clips and noted the accent.
We are in Tasmania across the waters.

So far our development is Python only and no grasshopper at this point. Because the tools being created are going to be used by multiple people in our team, most will just want to click on a button rather than need to set up anything in grasshopper, but it is still an avenue I may pursue if I can package it up so my staff don’t need to actually touch grasshopper.

I have been talking with another guy about possible involvement from the layout, nesting, CNC side of things, but potentially reviewing some of our earlier work. The current developer I’m working with doesn’t have any experience in those areas, so he would welcome the assistance I’m sure. It will be about finding the right fit, so yes, will be happy to chat.

As a kitchen manufacturer we need to script the handling of 200-300 parts (typical kitchen) separating out by materials, setting up for labelling, and using the gang drill. Woodtron do have a G-Code manual and we have years worth of sample code to draw on.

I haven’t yet given up on RhinoCAM as they are offering to review our scripts and possible workarounds to the need for the software to update libraries continually while our script is running. But ultimately it will be about the best workflow.

I’ll be happy to provide a bit more information in the coming week.

Regards,

Adrian

Hi Adrian,

Yes, I am a kiwi - nice spotting of my accent - tho I am now based in Cape Town.

For a bit of history, the first CNC I ever owned I paid for by contract cutting kitchens for the local kitchen shop in between shaping kitesurf boards - I’m more than familiar with your work flows.

KaroroCAM is actually written in Grasshopper, with some custom Python, mostly for the GUI and is compiled to a plugin using the Rhino Script Complier. My other clients all get ready to install YAK files with complete GUI’s - no Grasshopper wiring to be seen.

For reference, one of these current clients is Shapewave, a Dutch startup doing free-form 3D inflated structures:

They have built a custom ‘3D welding’ machine with 6 axis of control. I’ve written the complete software stack to take a Rhino 3D model, add the taping, flatten the skins and create/export the custom 6 axis G-code.

If you manage to come right with RhinoCAM - all GOOD! However more than happy to discuss you project and how I could help you achieve your goals.

You can email me on karorocam@gmail.com

Cheers,

DK