Loops while in compiled GH or Grasshopper Player

Hi guys,

Bit of a left field issue.

I’ve got a GH script with HumanUI front end that is compiled using the Rhino Script Compiler and installing into Rhino 7 as a plugin. (Amazing!)

Everything in the plugin has been working great, exactly as it runs in Grasshopper, except no GH canvas shown.

In the last week or so I added some new functions, using a combo of Octopus and Anemone components.

This all works fine running on the GH canvas, but once compiled the functions kind of ‘fail to start’.

It appears to be related to the issues of putting these type of components into clusters.

Once compiled these looping type components are only run once per solution, they are not allowed to ‘free wheel’ and keep working while the rest of the GH has finished.

Has anyone had any luck getting these types of components working say under GH Player (which I believe has same single pass then exit issue).

One other possible solution is to move these functions out to Rhino.Compute using HOPS, however does Compute/hops have same single pass and exit issue?

Any tips, tricks or suggestions welcome.

Cheers

DK

@AndyPayne - this is the thread I started on the actual issue I’d like to solve.

Cheers

DK

Ok. So, again without any code or samples, its still a bit tricky to debug here. However, I did want to mention a few things. The default behavior of the GrasshopperPlayer was to actually keep the file open (even after it’s run). This was a decision made specifically for definitions that were using things like Human UI. We did recently introduce a new boolean toggle in the Document Properties which allows you to be explicit about whether you want to keep the document open or closed when running the GrasshopperPlayer command. This was only added in the latest Rhino 8 WIP… but you might try your files in Rhino 8 WIP and see if there’s any difference there.
I’m honestly not sure if looping is supported in general when run as a command. I haven’t test this in hops, so if you have a simple looping example you could upload here, that would be helpful.
GH_Player

1 Like

Thanks @AndyPayne I’ll install wip 8 this weekend and see if that solves the issue.

Cheers

DK

@AndyPayne looks like I have sorted it!

Smallest of hacks too.

Currently I use a Python script to ‘pre launch’ Grasshopper headless before running my compiled GH command. It’s the only way I’ve been able to get this 6000+ component def to run as a plugin.

To get the loop components to work all I had to do was launch grasshopper normally after my command/plugin/UI loaded.

Nothing in the grasshopper window, and in fact can close it straight away. But as long as non headless grasshopper has been opened, my plugin functions just the same as on the canvas.

So very very STOKED!

Thanks for your help.

Cheers

DK

2 Likes

Very cool. I’m glad its working for you!

@AndyPayne this option to close the command is very useful. I’ve been trying and it just works fine running the file with grasshoper player, by other hand when running the GH file from a plug-in, it doesn’t seems to work anymore. Do you know if this information is overwriten when generating the RHP with RhinoScripCompiler?
Here using both V7 and V8wip, thank you!

To my knowledge, the only place that looks at the checkbox in the GH Document Properties dialog is when the Grasshopper file is trying to be run as a command (ie. GH Player). When you compile your plugin and then try to use it on another computer, does it try to use the GH Player? Or is it running it in some other mode?

The commands are running with Grasshopper player, the main difference I found is that after compiled the plugin, these commands just perform well on the first run, after the first run it shows: No contextual outputs on the definition, even they are there.
By other hand, running the commands straight with GH player the same definitions perform well over and over again.
That’s why I believe there is a different way the scrips are handled internally.
Any advice would be greatly apreciated!

1 Like

@mats_magnunson Is it possible to provide a simplified example for us to review?

Sure, I was hoping you ask for it. I’ve just emailed you and example file in order for you to review. Thank you for following-up.

@kiteboardshaper I was trying to do that with C# unsuccessfully, may you please share your python script?

Sure,

import rhinoscriptsyntax as rs

rs.Command(“NoEcho”)

rs.Command(“-Grasshopper B D W S _Enter”)

import Grasshopper as gh

gh.Instances.DocumentEditor.CollapseForm()
rs.Command(“-Grasshopper W H _Enter”)
gh.Instances.ShowRemotePanel()
rs.Command(“-DK_Karoro_Main _Enter”)

That last line calls my complied GH script, just replace with yours then compile this script as your launching command.

Cheers

DK

2 Likes

I did get your email. I am out of the office this week but will respond when I return.

1 Like

Hello @AndyPayne,
boolean button “keep open after command completes” there is only in Rhino 8 or Is there a way to get it in Rhino 7?
Thank you