algorithmic modeling for Rhino

Hey everyone, I'm hoping someone can help me out by looking at this simple curve exporter I've been working on. Hopefully someone can replicate what's happening on my end.

You input a curve, give it a file path, a file name, and click a boolean toggle to export. Pretty standard stuff.

But I'd like to use a button instead of a toggle (so you don't have to remember to uncheck the toggle, and you don't end up exporting 50 times on accident). The problem is, when I do Grasshopper freezes (I can pan and zoom, but cannot select anything).

The only exception to this is if I have already exported once with the boolean toggle as the trigger, then switch to the button. That works fine, but obviously doesn't make any sense in this workflow.

I've attached the file. Also, here is the code:

Private Sub RunScript(ByVal export As Boolean, ByVal crv As Curve, ByVal path As String, ByVal name As String, ByRef A As Object)
Dim scriptString As String = "-_Export " & path & "\" & name & " _Enter"

If export Then

If (Not System.IO.Directory.Exists(path)) Then
End If

Rhino.RhinoApp.RunScript("_SelNone", True)

Dim id As Guid = doc.Objects.AddCurve(crv)
doc.Objects.Select(id, True)

Rhino.RhinoApp.RunScript(scriptString, True)
Rhino.RhinoApp.RunScript("_delete", True)

End If

a = scriptString

End Sub

Views: 821


Replies to This Discussion


I can replicate that. This is really strange.

I think I got it working by adding export = False before the End if statement.

Can you test this out?



this wont work here. maybe this may be a clue - when I click the button second time, gh responses as usual.

EDIT : Well, seems that when I keep the button pressed for some time, everything goes fine. This will probably refer somehow to your clue Marios.

I am not saying that this is the fix for the faulty behaviour of the component. However if Brian definitely wants to use a button for this script, by adding a False value to the export statement each time the routine gets executed you ensure that this routine is not going to run for a second or an N-th time.

well it worked for me, without having tested the constant pressing of the button, but I think this should definitely get in line for 0.9.0053.

Thanks for trying this out Marios. 

Unfortunately Mateusz is right - even with the export = false before the end if statement, if you click the button fast enough it freezes up. You have to click it a second time for it to unlock. Or, hold the button down long enough in the first place.


Well then so even a button connected to a panel would cause the same 'freezing'. it's not about constantly running the loop rather than a totally weird behaviour of the component.

I just retested it,1 out of 6 it works for me.

I think we will have to wait for David to fix it cause you are right that the button component is really useful in similar cases like yours.



The button object itself is at fault. Sounds like the same thing I was experiencing here:

As mateuz notes, pressing the button a little longer than normal seems to cause it to behave normally. If you get stuck, pressing the button a second time seems to restore control to the canvas. 

I might be crazy, but it seems to me that as long as the button object itself shows its depressed state, it will return to normal as expected - but if you release before the button "press" shows, it will continue to hog all mouse events. Hope David's listening - this can be a major pain!

Thanks for checking this out guys - just wanted to see if I was doing something incorrectly.

I saw David's quip about waiting until next year to fix this (which he posted on Dec 31st). Had a good chuckle.







  • Add Photos
  • View All


  • Add Videos
  • View All

© 2021   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service