Grasshopper

algorithmic modeling for Rhino

Hi!

Is there a way to set value of number slider from a script? Something similar to AssignDataToParameter? Or do I need to change sliders to Num inputs (this looks to be working)?

Anyway, can I have both sliders (for users working with GH directly) and some other numerical inputs (for using GH from commandline) feeding data to the same input param of other node (now the one I connect cuts the previous link)?

To make myself more clear: I'd love to retain the range limitation of sliders (thus avoid wrong input) and still be able to set it from parsed external file via script...

Regards,

Boris

Views: 4145

Attachments:

Replies to This Discussion

Hi Boris,

here is an example for manipulating the slider from an external script. All Sliders you want to modify need to be connected to the slider input:

Hope this helps,

FF

Attachments:

Hi Florian!

Thanks for the example, David has updated RhinoScript interface, so now I can do it easily :). But your example shows me huge possibilities of script components, definitely need to take a look at some tutorials!

Best regards,

Boris

Hi Boris,

sliders are special because their data is extracted from another type of slider object inside of them. I just added two new methods to the RhinoScript interface:

  • SetSliderValue(sliderID, value)
  • SetSliderRangeAndValue(sliderID, value, minimum, maximum)

They will be available in 0.9.0055

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Hi David!

Wow, the best support ever, thank you! :)

Best regards,

Boris

Hi Boris,

you wouldn't be interested* in becoming the new owner of a young cat would you? About 1 year old, female, litterbox trained, sterilised, vaccinated, full medical history. Very social and playful but needs someone who won't shy away from smacking her over the head if she does something naughty.

We'll happily drive her to Kosice or any other ~1 hour radius from Poprad if it means getting a good home for her.

* or know someone who'd be interested.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Hi David and Boris,

This is interesting and i gave it a quick look at 0.9.0055. Couldn't get it to run (no error but not working). It may be the id. Which ID does the sliderID require. InstanceGuid? Nickname? or whatever?

Call Main()
Sub Main()
Dim GH : Set GH = Rhino.GetPluginObject("Grasshopper")
'GH.OpenDocument("C:\Users\ffr\Downloads\SliderManipulate.gh")
GH.SetSliderValue "536ded81-781e-4a21-b60e-2ac50e69a04d", 0.2
Set GH = Nothing
End Sub

Thanks,

FF

Attachments:

Hi Florian,

I've tested it right now and it works for me:

Call GH.SetSliderValue("6b8c646f-0b15-4951-bbbd-db02a15efbf0", 5)

where guid is taken from Container/InstanceGUID when following this topic http://www.grasshopper3d.com/forum/topics/gh-assigndatatoparameter

<chunk name="Container">
<items count="6">
...
<item name="InstanceGuid" type_name="gh_guid" type_code="9">6b8c646f-0b15-4951-bbbd-db02a15efbf0</item>

...
</items>

Regards,

Boris

Ah i see,

It only works with sliders not digit scroller as in my example from before....but you can use the c# script for the instance guid instead of searching the xml code...it's more comfortable i think ;-)

It works quite well, but it has some problems with refreshing the data. It only updates on focusing the GH window and then hit play again. But the concept is great.

Thanks,

FF

I specifically don't update the solution when you set a slider. I assume that you may want to set more than one so running solutions in between would be annoying. You have to call GH.RunSolver(False) to make sure the new slider values are used.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

This makes sense. Good solution. I just found some of the available RhinoScript Interface commands for grasshopper in the SDK (GH_RhinoScriptInterface clas). Is this list complete?

  • IsEditorLoaded()
  • IsEditorVisible()
  • LoadEditor()
  • ShowEditor()
  • HideEditor()
  • EnableBanner()
  • DisableBanner()
  • IsSolverEnabled()
  • EnableSolver()
  • DisableSolver()
  • RunSolver(expireAll As Boolean)
  • OpenDocument(fileName As String)
  • CloseDocument()
  • CloseAllDocuments()
  • SaveDocument()
  • SaveDocumentAs(fileName As String)
  • AssignDataToParameter(parameterID As String, data As Object)
  • BakeDataInObject(objectID As String)

New:

  • SetSliderValue(sliderID, value)
  • SetSliderRangeAndValue(sliderID, value, minimum, maximum)

Thanks David and good luck with finding a nice place for your kitty.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service