algorithmic modeling for Rhino
Is it possible to find the number of inputs a script component has from within the component itself? Access to Me.Params is not allowed within script_instance. Ideally, if I could get to using Me.Params.Input.Count it would be very useful.
I'm trying to write something that collects data from a lot of other components (lists and single items), flattens all incoming data streams to remove tree depth, and then rebuilds a single tree assigning a new path to every input stream. And I need this to automatically take care of any new inputs that I add to the component (there's a lot of them!).
Manually adding these inputs is fine, but adding names, flattening, setting data access types (item/list/tree), and then writing code to manually run through each of the inputs in painful. So I wouldn't just need access to the inputCount, but also manage to collect their data without using their names.. yikes!
Thanks for any help!
Tags:
The owner field represents the actual Script component itself. You'll need to cast it to IGH_Component (or GH_Component) first though.
DirectCast(owner, IGH_Component).Params.blahblahblah
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks David.
That worked. But I'm not able to figure out how do I get to IGH_DataAccess.GetData() from within RunScript to automatically collect data?
You can't. IGH_DataAccess is only available as a parameter to the SolveInstance function, it's not a member of the component class or any other class. Since you can't get into the scope of SolveInstance(), you can never reach the IGH_DataAccess instance.
What do you need the IGH_DataAccess for? All relevant data is already provided via the RunScript arguments. If you want to have a look at all data stored in a parameter, you can use the cast->params approach.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Well, the intention is to be able to get to the incoming data without using the RunScript arguments because the number of arguments change very often, and there's several of them.
So in short, not having to rewrite the code every time a new input is added/removed but instead have the code smart enough to recognise it and deal with it.
I guess I could easily do it by making a custom component with variable inputs, but I just wanted to see if the same was possible from within a ScriptInstance component.
I will try out the casting to IGH_Params, but would that give me access to the geometric data coming through these params?
Thanks!
It does seem to be impossible via reflection as well. I can get at the names of the parameters, but not the values.
I think a compiled component is your best bet here.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Cool. Will just go ahead and compile a component then.
By the way, just wondering if the Referenced Assembly Manager we discussed here would be in a release soon? I checked, the local resolver doesn't work very reliably.. sometimes it finds it, sometimes it doesn't.
Thanks a bunch!
I'm not sure when. My first order of business is to create a database of compiled scripts, so that the same source only ever compiles once. Then I'll start thinking about the global referenced assemblies.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by