Retrieving class object returns NullReferenceExeption

Hello,

I have been trying for quite some time to replicate a closed venation algorithm in grasshopper and/or in python and have failed so far. I would like to experiment with closed networks as topic for my master’s thesis in architecture.

This is the code I am trying to port to Rhino:

More specifically the .js files in the “core” folder.

I have attached several files, my simple open venation definition (which works great) together with my attempt at closed venation in GH only(which failed). Secondly the core folder rewritten to work in Rhino (executed with atom editor, fairly complete but also does not work properly) and lastly my attempt to circumnavigate my problems in python by implementing the code in python components!

This is where I am at and I do not understand why this error is raised. I think because the several python components are not referenced properly to each other, I also thought maybe the classes have to be Global somehow or something with " _ _ main _ _" or the ghdoc/RhinoDoc environment, but then again the items are listed as System object ?!? My python experience is yet quite limited, I have tried all sorts of things but I can not find the error.

In the component that fails, if instead of outputting I just print the variable, the script runs fine and returns the guids of _Attractor.position

I would be very happy for any help, I am trying to implement this for almost 3 weeks now…

Thanks, greetings from Austria

Martin

venation_open_closed.gh (43.4 KB)
core.zip (22.5 KB)
current_dilema.gh (18.7 KB)

If someone can get this to work - the reward is a original austrian sacher cake - as a thank you :slight_smile:

Well … if you could consider a Titanium Akrapovič for my Panigale V4S I would be tempted.

I have a vast variety of things like this (in 3d) but I don’t like P (at all) so if you think that you can translate C# to P drop a word (and send the wonder Acra thingy to: The Lord, Discrict 9, North Pole).

Using a Graph (any valid graph that yields a V List + VV conn):

Using Prox on rnd Pts on any BrepFace (or inside a Brep/Mesh) - shown Rect pts for clarity (3 Methods available + a cross Lines [or not] option):


PS: This is a classic very simple Recursive problem. You don’t need classes (why kill a mosquito with a bazooka?).

Hey Peter,

Thank you for your reply :slight_smile: That looks super interesting!

I have tried without first but eventually I switched to python because of the loops and as I did not exactly know how the details work (especially the relative neighborhood and and the RTree) I started converting the .js files and thats where the classes are from, I thought It might be a good exercise since I have mostly avoided to use classes in the past.

Very nice choice on the titanium exhaust! Actually, I can just about afford the cake, but I would be very happy to send it in exchange :innocent: I wouldn’t mind the C#, I have little experience in both :sweat_smile:

That’s rather unfortunate (Note: if you become a zillionaire some day drop a PM - we are talking FULL Ti Acra obviously [and no cat]).

Anyway … here’s the deal:

IF Lewis wins today in Brazil (and Max gets a DNF - cross fingers) I’ll post here the most usefull variant (i.e. get a Graph and do things). That said you can use a Mesh to get your Graph (mild, medium, wild etc etc). You can even turn an Akra into a Mesh (then Graph) and do proper Akra related things.

Shown a 3d Blob (TSplines) > Mesh > Recursion > …

BTW: Given any Mesh you know how to get the V List AND the VV connectivity? (that could cost you more - for instance a MoTeC proper ECU and the likes).

Its not that bad, i’m doing ok

Well suddenly I see Perez touching Verstappen in the first corner :rofl:
We are hoping for the same scenario, crossing fingers now for 2 reasons
Yesterday he finished 5th… and that was a short race

Let me get back to you in a few days with that. I’m on it. I think :thinking:

Well … since you a man with a clear view on things (Lewis related) let’s minimize the days (can you find how to do the rest 3 conn Trees?).

Mesh_connectivityTrees_Public_V1A.gh (216.5 KB)

Note that since chances are that in real life we deal with Lists … this means conn Trees with 2 dims.

Looking good 4 Lewis :slight_smile: I tried to complete your definiton, I’m sure it is absolutely wrong but here is a try:

Mesh_connectivityTrees_Public_V1A_Tryout.gh (105.9 KB)

P.S.: if it makes sense at all, the edge that is searched from is probably counted twice. Thats because i broke down the edge in two vertices and then checked the connected edges to these 2 original vertices. Its easy to fix but not 4 me in C#

YES, YES, YES > the greatest ever did the thing. You’ll receive the hot cake as promished (after celebrations).

What a race, Totos face after he overtook :laughing: Woohoooo

WHAT A RACE indeed.

Recursion_GrowOnMeshVertex_V1.gh (323.1 KB)

Note to stewards (and FIA) : fellas appear that Bed Bull had seriously invested on you (I guess millions under the table) … but ^@*!^! happened - I’m so sorry. But just for the record (of corruption), how you explain this?

1 Like

25 grid place penalty and still finishing first - amazing.

1 Like

Thank you for sharing this Peter, that’s a great definition :star_struck: But if I am not mistaken this is also an open venation pattern, I was actually more looking for something like this:

Screenshot 2021-11-14 203838
so i am trying to get to your first picture:

does it depend on the input network, or why is one open and the other a closed network ?

Thanks :slight_smile:

No mods required: IF you have a Graph (any Graph) you use that (instead of a Mesh derived one) and you get the V List and the VV conn Tree and … blah, blah (unless you want to bridge visited nodes - I’ll add an option for that tomorrow - if it makes any sense).

And that brings us to the next question: given a Graph (not out of a Mesh) do you know how to get the V/VV things ?

If on the other hand you want a result like this without a Graph … well … that’s another animal (but I can’t post stuff on that matter: strictly internal stuff).

Oh I see, fantastic! I need to play around with this a little more :slight_smile:

Well I haven’t done it in code, what I did in GH was i created an urqurhard graph from the points and then hooked it up to a network topology component that gave me the the connected vertices.
Screenshot 2021-11-14 213500
From there on I performed closest point calculations and then referencing the influenced nodes indeces to the V list.

hehe, all good I’m already super happy about all the help :pray:

I am not sure if bridging visited nodes would have the same effect as in this logic (I was following):

  • Associate each attractor with all of the nodes that are both within a pre-defined attraction distance and within the attractor’s relative neighborhood.
  • For each node that is associated with at least one attractor, calculate the average direction towards them as a normalized vector and generate a new node that extends in that direction at a pre-defined segment length (by scaling the normalized direction vector by that length).
  • Remove any attractors that have been reached by all of their associated nodes.

But If it makes sense it would for sure be Interesting!

That is not nuclear science to implement (and … well … as a tutorial … there’s a case for a class [of type Node] for doing some LINQ things). In fact I have “similar” things done a million years ago … but I can’t recall where they are (if are not removed - as irrelevant junk etc etc).

BTW: Here’s a challenge for the brave: Get this, modify it accordingly (and maybe add a ccx check option - see comments in C#) use attractors, cats, dogs, aliens etc etc … and create some tree like graph (in 2/3d) that goes from some start to some multiple end(s).

Recursion_2dGrow_V1.gh (119.1 KB)

I hear you: but that’s a bit pointless. Well … indeed it is.

BTW: What TOTAL corruption (FIA and the rest of the gang) means - 24 hours required for the money transfer I guess.

I’ll have a go at it thanks for your help :slight_smile:

What this means exactly?

them refers to all attractors or the attractors that satisfy 1?

In what sense?

And what about the classic attractor(s) influence mode? (push/pull, that is)

Sorry the quote was out of context.
Here is the original algorythm description as well as the code itself in .js
Here is a detailed description that should answer all the questions more precisely as I could.

Space colonization is a process for iteratively growing networks of branching lines based on the distribution of growth hormone sources (called “auxin” sources) to which the lines are attracted. Originally described (PDF) by Adam Runions and collaborators at the Algorithmic Botany group at the University of Calgary, this system can be used to simulate the growth of leaf venation patterns and tree-like structures, as well as many other vein-like systems like Gorgonian sea fans, circulatory systems, root systems, and more.

The original algorithm describes methods for generating both “open” (as seen in the example GIF) and “closed” venation networks, referring to whether or not secondary or tertiary branches connect together to form loops (or anastomoses).

Algorithm at a glance:

For both the open and closed variants of this algorithm, begin by placing a set of points on the canvas representing sources of either the auxin growth hormone (as in leaves) or ambient nutrients (as in trees).

Open venation:

  • Associate each attractor with the single closest node within a pre-defined attraction distance.
  • For each node that is associated with at least one attractor, calculate the average direction towards them as a normalized vector and generate a new node that extends in that direction at a pre-defined segment length (by scaling the normalized direction vector by that length).
  • Remove any attractors that have nodes within a pre-defined kill distance around it.

Closed venation:

  • Associate each attractor with all of the nodes that are both within a pre-defined attraction distance and within the attractor’s relative neighborhood.
  • For each node that is associated with at least one attractor, calculate the average direction towards them as a normalized vector and generate a new node that extends in that direction at a pre-defined segment length (by scaling the normalized direction vector by that length).
  • Remove any attractors that have been reached by all of their associated nodes.

Auxin flux canalization:

This is a process by which veins become thicker as they grow longer. The longer a vein gets, the more auxin flows through it (“flux”), causing veins to progressively thicken from their tips to their roots. “Canalization” references the process by which “canals” of water form.

  • Give each branch segment a uniform default thickness to start with.
  • Beginning at each terminal node (that is, segments with no child segments), traverse “upwards” through each parent node, adding their child node thickness to their own until you reach a root node (a segment with no parent segment).

Well … is very hard for me to justify any reason to mimic nature (humans are good only to destroy the planet and kill the eco-system).

But theoretically speaking this requires “shapes” (that mimic nature) and guide curves on them in order to guide the recursion (in some sort of ordered “network” of paths) that if left free … well … does this:

Or - maybe - a modified PMST could(?) cut(?) the mustard (MinSpanTree, that is)…

Porting the js to C# is rather easy … the only issue is that the whole thingy is slightly disgusting (sorry nature, we’ll meet again in some other life).