Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Interacting with IGH_DocumentObject from Python (Rhino8)

$
0
0

Hi, I’m trying to set the value of a Number Slider using Rhino 8 in Grasshopper. I can do this successfully using a script component running Python2, but Python3 fails running the same code. It appears the underlying C# interface is different between these two scripting environments.

Here is the discrepency, calling this returns lists of two different types:
ghenv.Component.OnPingDocument().Objects

In IronPython2 returns a list of direct usable component types like: GH_NumberSlider
In Python3 returns a list of IGH_DocumentObject interfaces

So in IronPython2 this call works:
obj.Slider.Value

but in Python3 the same call fails with:
‘IGH_DocumentObject’ has no attribute ‘Slider’

Is there some way to cast the object in the Python 3 code so that obj is a reference to a usable: GH_NumberSlider?

See example here:
231107_slider_experiment.gh (13.4 KB)

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles