Grasshopper

algorithmic modeling for Rhino

hello,
my problem is that I have an event to draw on the canvas, something like this

Private Sub PaintHandler(ByVal sender As Grasshopper.GUI.Canvas.GH_Canvas)

(...) 

Dim ... as Double = ... * X

(...)

End sub

Where X is a value of a slider parameter.

If prior to event I write this:
Public X as double

The value of X is the value when the event is triggered. But if I change the value of the slider, no change is produced.

My question is whether we can have an active parameter within an event, calling it somehow. Perhaps another option would be to recompute the event when the X parameter changes.

No documentation on this and far as I know there are only this discussion unresolved in the forum.

Could anyone tell me how I call the parameter within the event or how could I do?

Thanks in advance.

Views: 353

Replies to This Discussion

Is this a difficult subject?
Or is it just not possible?

Private Sub PaintHandler(ByVal sender As Grasshopper.GUI.Canvas.GH_Canvas)

  Try

    Dim obj As IGH_DocumentObject = sender.Document.FindObject(sliderID, True)

    Dim sld As GH_NumberSlider = DirectCast(obj, GH_NumberSlider)

    Dim x As Double = sld.Slider.Value

    .....

    .....

  Catch ex As Exception

    ' Either the canvas contains no document, or the document doesn't contain the object with the given id, or the object with the given id is not a slider, or.... You should probably not use a try...catch block but instead make sure all your values are correct before proceeding.

  End Try

End sub

Thanks for the reply David. But this road requires me to use a GUID component... Because as I read in the forum, is not possible get the guid of a component within the script, right? 
If so, this road does not serve for me :/

Perhaps you should explain exactly what it is you're trying to do. What is this slider doing on every redraw?

It is the width of a Graphics.DrawRectangle. I'm doing the transparent canvas, and the slider at 0.5 does half the canvas and 1.0 does all transparent. Yesterday I sent you the script to your email, I just sent it updated. Play with it if you want!
The idea is to make a gha for milkbox.
It would be much cooler if could move the rectangle onthe canvas as a winform border, but this is too much for me ...

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service