Grasshopper

algorithmic modeling for Rhino

Hi Giulio/Steve,

Recently noticed a small "bug" in the GHPython component (also present in the Rhino 6 WIP version): If you have a slider wired up to an input param, change the slider and then undo, this will cause the input param variable to temporarily not exist within the scope of the script (throwing an error if you're calling this variable). An obvious workaround (and good practice in general) is to check that the variable exists in the first place before calling it, but I'm thinking that this does seems like a bug and is not be design. It only seems to happens with sliders (i.e. panels, value lists etc seem to undo okay). The C# script editor does not appear to have similar issues with undoing.

Attached a simple example which demonstrates the behaviour.

Cheers,

Anders

Views: 114

Attachments:

Reply to This

Replies to This Discussion

Hi Anders,

this is not a GhPython bug.

You have been bitten by 'everything is an object in Python', while 'most built-in types are stucts in C# (except object and string)'. You see, double in C# cannot be null. This means that, when converting Null from undoing (this appears to be a Grasshopper bug), the value will be represented as 0.

The same error happens in the GhPython component, but is not masked by the conversion to float. You can get the GhPython component to work in the same way by checking against None, as that variable is being passed as None.

Does it make sense?

To demonstrate this, I am showing a C# component that will cast the input value directly to double. You will see that this will not work with nulls, as well.

David may be able to help pinpointing the cause of the null when undoing. I am unsure why it happen.

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

Attachments:

That does indeed make sense, cheers Giulio. I do tend to always check that input params are valid before calling them (which is why I hadn't noticed this behaviour before). It just seemed (seems) a bit odd that undoing a slider would cause the described behaviour (and not say, undoing a value list change), but yes, can't hardly blame GHPython for that :)

RSS

Translate

Search Grasshopper

Photos

  • Add Photos
  • View All

© 2017   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service