algorithmic modeling for Rhino
This may be one for David.
I am retrieving a grasshopper component from the canvas. If the components are of the same type, say a point component for instance, how is it possible to determine the order of construction of each point component on the canvas? i.e. which point component was the most recently constructed?
Tags:
No. The only order is the Draw order, which can be changed by the user.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Solution and Drawing are not related processes. The order in which objects are solved has nothing to do with the order in which objects are drawn. Indeed, objects which are beyond the bounds of the canvas are never drawn but could be solved, and objects which haven not expired are never solved but can be drawn.
Generally, new objects are put at the top of the draw stack, so the older the object the more likely it is to be near the bottom of the list. However as soon as one of the items in the Arrange menu is used this order may be fractured.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Got it. Makes total sense.
So there is no way to understand the solution order. i.e. if we have five point components on the canvas say A B C D and E, where E is the lower most downstream component, how do I make sure I select E and not A through D?
You can certainly figure out which of all the point components is the leftmost one (or rather; "which are the leftmost ones" as components can be in parallel positions).
There's a FindAllDownstreamObjects() method on GH_Document which allows you to find all objects that rely on a starting object. There's no way to quickly find all upstream objects.
Another possibly fruitful line of inquiry would be CreateConnectivityDiagram() on GH_Document. It gives you a class which only represents the connections between objects, so it's easier to traverse and search it.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
David, thank you for the reply.
Hope this is not too tedious for you.
I understand what you are saying but I don't think it helps if these components are not connected to one another.
This may be a dumb question, but as I understand it, the position of the components on the canvas does not dictate the order in which calculations are completed when initializing a solution. It depends on the order in which the components were laid on the canvas. i.e. for point A B C and D on the canvas where the inputs are reference geometry selected in rhino and not up stream components, and rearranged on the canvas in this order top to bottom:
A
B
C
D Solution order is ABCD
if we arrange in top to bottom alignment
C
A
B
D Solution order is still ABCD
if we rearange to
A B C D Solution order is still ABCD
if we arrange to
D A B C Solution order is still ABCD
if we add a new component and move to start
E A B C D Solution order is A B C D E
I'm guessing may be the order of components in a solution is given by the index returned by FindObjects method? This would tell me which component on the canvas is first in a solution.
Steve
The order of components that are solved is highly unpredictable. Mostly because components can request other component be solved while they themselves are being solved. Basically, this is what happens:
To make things more complex, Grasshopper decides to solve certain types of objects first. This is a part of the program which is most likely going to change a lot as well in the near future.
If you are looking to find the point component that is furthest towards the right (highest X-coordinate) then it's fairly easy to do that. If you want to find a point component that is last in the data inheritance, that too is do-able, though somewhat more work. I'm not really sure if you are actually looking for these characteristics or if you want something else.
It is true that the x,y position of components on the canvas is utterly irrelevant when it comes to solve-order.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Welcome to
Grasshopper
© 2024 Created by Scott Davidson. Powered by