Grasshopper

algorithmic modeling for Rhino

Does Anyone know to test is  a component's ByRef variable is Defined/declared - i.e an Output variable? 

and as a bonus, declare one from within the component?

I am using the VB script component. 

Thanks,

 Guy

Views: 724

Replies to This Discussion

I don't get it. You mean the RunScript ByRef arguments that map to output parameters?

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Yes, those. Sorry, I didn't know how to describe them  correctly. 

They are always null. I declare them just before calling RunScript, and afterwards I convert them into the appropriate type if you assigned anything.

Of course within a single RunScript call you can always test whether or not you've already assigned something to those variables, but that's not what you're asking right?

If you want to test whether an output parameter already has some data assigned to it, you need to actually look at the parameter itself. Which means casting the owner variable to a GH_Component (see attached).

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

Thanks David, but that's not what I am after. 

I am trying to build a custom Gate component that reads a string parameter to interpret which output parameter to send the data stream based on a string key. So if the parameter is "[" and the String read [=A, then  A = data. 

Say my component is setup with outputs A-D. 

I want ask if a RunScript outparameter exists. So if my string wants to send data out of the output "E" but component doesn't have an output parameter "E", then either 1) don't try 2) make output E? 

When I try asking if "E" is Nothing (or even mention E) I throw an error because E doesn't exist. 

Would I use an ____.onError catch type of thing? I am sure how those work. 

I hope this explains what I am trying to do. 

 Guy

If I understand you this time, then it's quite a tricky problem. I can get 50% of the way there using Reflection, but I'm stuck at assigning data to a ParameterInfo instance. I posted the question on StackOverflow so whenever someone answers I can try and get one step further.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Bad news, seems like it's not possible to assign values to method parameters via Reflection. If you have access to Visual Studio you can try doing this as a GHA project, there it will be possible to assign data using indexed parameters.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Bummer. Thanks for looking into this. I have been meaning to try a GHA project anyway.  I have some older GHA project tutorials like Ben Sitler's manual and stuff from Gulio, but those are all based on version 0.6.X. Any major differences I should be aware of when coding for 0.8.X? Are you aware of any updated tutorials?  

Thanks again. 

 Guy

No major differences really. The last really major thing that changed was the List/Tree storage, which happened way back. Otherwise there have been minor breaks, but no conceptual changes.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service