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

Test rhinoinside: first step with Python but

$
0
0

Hello
I try this to send and receive data between two components, it’s clear that the second component
responds to slider changes but the string always empty
What am I missing here?

import Rhino
import rhinoscriptsyntax as rs
import Grasshopper as gh
        
class Receiver:
        
    def __init__(self):
        self.comp = None
        self.registered = False
        self.str = ''
        
    def RunScript(self):
        self.Receive(ghenv.Component)
        self.Receive_str = self.str
        
    def Receive(self,component):
        if not self.registered:
            Rhino.Runtime.HostUtils.RegisterNamedCallback("Send_data", self.RiRhino)
            self.comp = component
            self.registered = True
                    
    def RiRhino(self, sender, args):
        if args.TryGetString("data"):
            self.str = args.TryGetString("data")[1]
        self.comp.ExpireSolution(True)
        

Receive_str = Receiver()

print Receive_str

16 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 4120

Trending Articles