GHPython: Slider Undo Causes Input Param to Temporarily Not Exist - Grasshopper2024-03-28T23:55:07Zhttps://www.grasshopper3d.com/forum/topics/ghpython-slider-undo-causes-input-param-to-temporarily-not-exist?feed=yes&xn_auth=noThat does indeed make sense,…tag:www.grasshopper3d.com,2016-09-05:2985220:Comment:15943122016-09-05T14:51:42.291ZAnders Holden Deleuranhttps://www.grasshopper3d.com/profile/AndersHoldenDeleuran
<p>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 :)</p>
<p>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 :)</p> Hi Anders,
this is not a GhPy…tag:www.grasshopper3d.com,2016-09-05:2985220:Comment:15941322016-09-05T14:38:08.175ZGiulio Piacentinohttps://www.grasshopper3d.com/profile/GiulioPiacentino
<p>Hi Anders,</p>
<p><span>this is not a GhPython bug.</span></p>
<p><span>You have been bitten by '<em>everything is an object in Python</em>', while '<em>most built-in types are stucts in C# (except object and string)</em>'. 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.</span></p>
<p><span>The same error happens in the GhPython component, but is not masked by the conversion…</span></p>
<p>Hi Anders,</p>
<p><span>this is not a GhPython bug.</span></p>
<p><span>You have been bitten by '<em>everything is an object in Python</em>', while '<em>most built-in types are stucts in C# (except object and string)</em>'. 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.</span></p>
<p><span>The same error happens in the GhPython component, but is not masked by the conversion to <em>float</em>. You can get the GhPython component to work in the same way by checking against None, as that variable is being passed as None.</span></p>
<p>Does it make sense?</p>
<p></p>
<p>To demonstrate this, I am showing a C# component that will cast the input value directly to <em>double.</em> You will see that this will not work with nulls, as well.</p>
<p></p>
<p>David may be able to help pinpointing the cause of the null when undoing. I am unsure why it happen.</p>
<p></p>
<p>Giulio<br/>--<br/>Giulio Piacentino<br/>for Robert McNeel & Associates<br/>giulio@mcneel.com</p>