Grasshopper

algorithmic modeling for Rhino

Hi all,

I have a question about using the GHPython library. I’m curious how to use the dynamic nature of the ZUI functionality in a script, such as automating a script to incorporate / disassociate input parameters as they are created / removed.

For example: "if either the CanInsertParameter or the CanRemoveParameter is called, then insert/remove appropriate arg and index"

Please let me know if I can clarify anything. Thanks in advance for looking into this with me.

Best,

/SPM

Views: 412

Replies to This Discussion

Hi Stephen

I think this should get you started:

#we can get to the current GH_ComponentParamServer,
#then get its inputs:
inputs = ghenv.Component.Params.Input
#we can use a for loop, or we could also get
#the amount using inputs.Count
for input in inputs:
  name = input.Name

  #eval() will let us "grab" the variable
  #from the environment
  value = eval(name)

  #we can then do stuff with it
  print(value)

Does it help? (I also attached here a definition with that code).

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Attachments:

This is great, Giulio. Much more straightforward than I initially thought. Thanks for leading me down the right path.

/SPM

Please only note that this type of dynamic input will not lend itself to being compiled. However, I do not think this is your goal here, so you should be fine.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service