Offline 'Shapediver' style service/packaging/app

Hi Guys,

Just throwing this out there for discussion/possible solution.

I have a few people using my kite design software online via Shapediver:

https://www.karorocad.online/

I would like to be able to offer an ‘offline’ solution to my users, but don’t want to just give away my Grasshopper source code.

Has anyone looked at or built a local front end for headless Rhino/GH that would allow some sort of secure encapsulation of the GH source while giving the user access to the controls?

Honestly I wouldn’t mind in the slightest if I needed to buy a Rhino license for every offline user of my code as long as I could package it all up in a secure way.

Or am I just best to create one big password protected cluster and hope that service and support will keep people happy enough to deal with me.

Cheers

DK

(@DavidRutten - can you create a ‘Grasshopper Complier’ if I ask really nicely - PLEASE?)

OK, looks like this is a one sided conversation, but I’ll keep it going with my thoughts and musings.

So, spent most of this weekend with my head in Rhino7 looking at different ways of delivery of Rhino/Grasshopper solutions to end users.

History of my project is, several years ago I got the idea to build a parametric engine to design kitesurfing kites in Grasshopper. I actually started the project firmly thinking it wouldn’t be possible and I’d give up at some point. To my shock it actually worked and is now developed to be somewhat comparable to the industry leading design software.

A bit over a year ago I looked into porting the code over to Shapediver, which again to my surprise was successful.

www.karoroCAD.online

Tho Shapediver is an amazing service it does have limitations on computation time and plugin/components that do mean I’m not able to offer a fully featured version of my system to others.

So, looking towards offline solutions and basing my needs somewhat around the Shapediver service my ideal solution has:

Code Protection

This doesn’t need to be Fort Knox quality security, just better than GH’s, ‘here’s the source code’. The RhinoScript Compiler seems to do this well enough, with the Python code encoded in the .rhi file and decoded at run time.

User Interface

Human UI is fine for this, WebUI might be second option in the future, ETO would be acceptable.

Grasshopper player misses the mark here as it will launch a GH definition with Human UI, but only runs a single pass before closing the definition.

RhinoInside shows some promise with @stevebaer teasing some ETO and WPF user interfaces. I’ve got to the point where I can launch Rhino and GH headless, and run a GH definition, however same issue as GH player, no HumanUI and only a single pass thru the definition.

I might add a few nice things like Package Manager/Yak support, Rhino UI icons/tool bars and license management thru Zoo.

So if I had my ideal setup right now it would like something like:

Write a short/simple RhinoPython script that would include a reference to my GH definition.

This Python Script would launch Grasshopper in a headless mode that runs 100% as per a normal GH session (not single pass then exit like GH Player).

Allow normal display of HumanUI/WebUI/ETO as user interface. (Maybe some sort of ‘on exit’ control would be needed on closing of the UI)

Allow Rhino Script complier to package/encode the Python and GH into a single rhi/yak package.

It feels to me right now that all the parts are ‘almost there’, if these were just pushed in the right way a new and very productive way of creating useful and distributable Rhino plugins would become available.

Cheers

DK

(please excuse typos and spelling, writing this on my phone late on a Sunday night.)

2 Likes

Just ran into the thread about RCP being updated, that too is also a viable option for the UI.

OK, very interesting development this morning.

Went and watched this video about RCP

Noticed that the presenter CLOSED THE GRASSHOPPER WINDOW but the GH definition and RCP controls remained active. With HumanUI controls if you close the GH window the definition stops.

So, I thought what would happen if I just added a single item to the RCP to a definition with a HumanUI.

Turns out you can close the GH window and the definition AND HumanUI controls remain active.

Next experiment was then putting same RCP/HumanUI definition thru the Grasshopper player…

OMG it just WORKS!

No GH Window/No GH definition shown (not even present if you open Grasshopper)

HumanUI controls work

Same GH display in Rhino Window as if you were running from GH.

Such a simple step and it was just sitting there.

NOW,

Need to work out save/open controls for my documents

Also how to actually close the definition

Cheers

DK

1 Like

OK - its not quite as simple as i mentioned above - you need to script a couple of things before you hit the GHPlayer.

Details soon…

DK

That’s good to know about it remaining active because of RCP.

RCP itself is pretty neat, but has some serious limitations. The main ones for us:

  • no support for dropdowns
  • no text entry
  • buttons that trigger scripts that do something outside of Grasshopper, like open a file dialogue, have the same bug as in Grasshopper where it can easily happen that all UI elements are not clickable only the button, because it gets “stuck”.
  • Panels don’t adapt in size

For the problem of hiding the Grasshopper file contents:

  1. you could turn the main part of your file into a plugin. Not sure how easy that is though.
  2. have you looked into Hops? Maybe there is some way to protect the file that is being loaded

Do keep us in the loop if and when you find a solution.

You went from “how to protect my definition?” to “i’m going to make my own code/wrapper!”. :rofl:
Did your goal change?
“If you want to protect your definition from programmers, you are in the wrong universe” cit David Rutten


If i were you…
If buying a whole licence for each client is suitable for you, i would set up some cloud/ftp storage service to send/receive a .txt containing all the parameters and your local server/computer 24/7 that see the .txt , create the geometries and export them on the cloud/ftp.
The client .gh definition just create the .txt and load the .stl/ .3dm once they appear…
This way your code never leaves your machine.

1 Like

OK - turns out this worked due to some command line pushing around of the Grasshopper launch process.

Here is it all tied up in a Python Script:

import rhinoscriptsyntax as rs

#Load Grasshopper with no banner and no editor shown

rs.Command("-Grasshopper B D W L _Enter")

#Add the RCP to the current GH/RHino

import Grasshopper as gh
gh.Instances.ShowRemotePanel()

#Launch the Grasshopper Script Headless with GH Player

rs.Command("-GrasshopperPlayer TEST_rcp.gh _Enter")

The gh file needs to be in the same folder as the python script.

Still a bunch of issues to sort out:

File load/save
How to exit the def
HumanUI buttons are not so stable/usable
Needs some sort of hook on the closing of the HumanUI so you don’t lose your controls/option to save

Just looking. Nice thread.

2 Likes

OK - so this is now something - I’ve managed to use the Rhino Script Complier to create an .RHP install package for a command that launches the a GH with HumanUI.

The thing here is both the launch script and the GH are contained in the ‘Complied’ RHP - this solves the code protection and package distribution in one hit!

DK_GH_Test.rhp (29.5 KB)

If you drop this RHP onto an open copy of Rhino 7 it will create a new command ‘DK_Launch’

3 Likes

Weird. It’s giving me an error saying the file is blocked, even though I unlocked it!? :thinking:

could it be that it is extracting the .gh file out of it, but that in turn is blocked or something?

Did you find a good solution? I have exactly the same problem as you

So, some progress here.

I have a complete Human UI controlled GH script that is compiled by Rhino Script Compiler into a .rhp and .yak package:

Image 20210828004

This launches from the Rhino command line with ‘KaroroCAD’, launch is a bit slow, I need to look at some sort of loading screen to indicate this is all going OK.

Once launched, all the controls I need work thru the HumanUI interface. I use text boxes with confirm buttons as the main control - the confirm buttons are not so obvious, but OK once you get into the flow.

I do input data checking on every input to make sure it matches the type and range needed.

For Save/Load I’ve used some Human controls to read the parameters into a XML format and save as a text file. Loading grabs the parameters from the XML file and drops them into the HumanUI controls. This was sort of both easier and harder than expected.

For close down I just give the user the option to exit the Rhino session completely.

Image 20210828007

I think that is about it for now - I need to get a copy off to one of my test users and see if they can break it.

Cheers

DK

1 Like

And - OMG - I can’t believe this actually works!

3 Likes

Latest progress with this:

  • added a ‘Is loading, please wait’ dialog to the Python loader as my GH def takes about 15 secs to load up. Used a ETO mode less form as which is closed by the Python loader once everything is running.

  • Have added some license control with a online paid license control provider. Right now just limits exports of the mfg files to Rhino but lots of options to add levels of capability. I can enable/disable features from the service providers site.

I’ll be getting a couple of testers onto it this week.

Cheers

DK

@kiteboardshaper

I wouldn’t trust that its super secure to store gh files into a rhp. Basically the rhp ships the information on how to extract the gh. But basically for most people it will be a challenge. So I bet its better than pw protected clusters…

Hi Tom,

Yes - I’m well aware of that - and it is not fort-knox level security - but still better than a password protected cluster.

As David R says - if you want software protection you are living in the wrong universe.

I’ve personally reverse engineered more than a few embedded micro controller applications from Intel 80C51 machine code so know that better than most.

Even C# plugins are fairly low hanging fruit for an experienced developer to gain ‘source level’ access to.

I’m more than happy with this current solution.

Cheers

DK

Ok, didn’t know you know so much about this topic. When I was reading this thread, I assumed you feel it’s pretty safe. I was just trying to see if it’s really that secure, and because I like these sorts of puzzles.

Took me less than 20 minutes to figure out how to retrieve the .gh file. Basically because any level of obfuscation was missing with this approach.

I totally agree that there is no real protection, but of course there are different levels of work to put into. I believe obfuscation and fooling is much more powerful protection, because of this.

Anyway, still a neat solution!

Prost, Tom