Grasshopper

algorithmic modeling for Rhino

Functions in Sticky to Make them Available to other Python Components?

Hi. Is it "official & suggested way in Grasshopper" to store functions in sticky to make them available to other Python components?

Views: 2746

Replies to This Discussion

I use it all over the place for Ladybug and Honeybee to share the functions and classes. I don't know if it is "official & suggested way in Grasshopper". I would only make sure to select a unique name for the key not to overwrite what someone else already put there!

Hi Mostapha,

I wrote a small piece of code to undrstand what stickey is. I gather it's a dictionary that containes many of the classes, and a few class objects you created.

I am wondering why am I seeing only keys and values assigned by you. Is it because no other developer is using this method?

Is this dictionary a session specific? What I mean to ask is, is it created eveytime we start grasshopper?

Thanks,

Attachments:

These data are copied to sticky once you let the ladybug or honeybee fly. When you open Grasshopper for the first time it should be an empty dictionary.

Ok. Thanks Mostapha!

Hi Marcus

I would say this is as official as, generally, third-party libraries are. Not everything that is possible should generally be done. In fact, if you can avoid this, I would suggest to do so. There are reasons why this is interesting, though, and other reasons why this should be avoided.

The main reason for this, is a Grasshopper-only way to distribute "libraries". The main disadvantage I see is user confusion. What Mostapha is doing is interesting and has a meaning, but you should not count on the fact that users will always add this "parent" component first, so you should at least find a way to let them know that they need the additional component. Secondly, there is no way in Grasshopper to officially tell "first compute that lonely component", but my understanding is that Grasshopper will probably keep on solving in the order it is solving now.

I hope this helps,

Giulio

--

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

What I do is pretty simple. Ladybug_Ladybug component copies all the classes into sticky and then sets "ladybug_release" to True:

https://github.com/mostaphaRoudsari/ladybug/blob/master/src/ladybug...

So I can check this key and make sure ladybug is flying, otherwise I will ask the user to let it fly!

    
if sc.sticky.has_key('ladybug_release'):
        lb_preparation = sc.sticky["ladybug_Preparation"]()
        
    else:
        print "You should first let the Ladybug fly..."
        w = gh.GH_RuntimeMessageLevel.Warning
        ghenv.Component.AddRuntimeMessage(w, "You should first let the Ladybug fly...")
        return -1

https://github.com/mostaphaRoudsari/ladybug/blob/master/src/Ladybug...

The order of execution is not really straight forward. Check this discussion: (http://www.grasshopper3d.com/forum/topics/order-of-execution-for-un...). I assume there should be a solution to the ctrl+B from the code inside the component.

@Giulio,

Are non-connected components not activated in draw-order fashion? Those in back first, those in front last? Use ctrl+f or ctrl+b to move them.

Hi Mathias,

this is an old topic. Yes, now it looks like this is the case.

Thanks,

Giulio

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

If there are no connections at all, then the solve order equals the draw order. However as soon as there's a connection between two elements, the receiving one will ensure that the providing one is solved first. So if you have a file with three objects (in draw order) {A, B, C} and none of them are connected, then the solve order will be {A, B, C}.

If both B and C are connected to the outputs of A, then the solve order will still be {A, B, C}.

If A is connected to the output of C, then the solve order will be {A{C}, B}, where A is initially asked to solve itself, but from within its own solution code it first triggers C.

If I were you I wouldn't rely on the order of things being in a specific way, not only is the above behaviour not a guarantee we make, it is already possible to develop custom components that subvert the default order.


hacking services

WHO needs money??
need travel VISA??
PAYPAL AND BANK TRANSFER AVAILABLE
flight ticket available all destinations
ATM clone cards ready to ship all country
western union services back in the game
online shopping, ask me how it works
original FAKE or REAL id, dl, pp, skul docs available for all countries.

CONTACT ME NOW AT

watsap @0014242429194
icq @745215892
inbox @cleanhackdeals at gmail dot com

NB: dont waste your time to contact for fb, ig or twitter hack... few serious buyers needed

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service