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

Get the runtime message of a component using ghpython

$
0
0

Hi I have a question I’m hoping someone has an answer to. Using ghpython I’m trying to get a list of runtime messages of a component(the warnings and errors in the bubble the top right of component).
image

What I’m essentially trying to do is to collect all the runtime warnings within a cluster and display it on the cluster itself. I’ve tried using “.RuntimeMessages” method but this returns me the “<built-in method RuntimeMessages of XXX object at= XXX” and not the actual warning text. Does anyone know how I might be able to retrieve the information?

Any suggestions are greatly appreciated. Thank you in advance!

the code I have currently looks like below:

import Grasshopper
mainDoc = ghenv.Component.OnPingDocument()
for obj in mainDoc.Objects:
    if type(obj)== Grasshopper.Kernel.Special.GH_Cluster:
        messages = []
        levels = []
        for c_obj in obj.Document("").Objects:
            a= c_obj.NickName
            level =  c_obj.RuntimeMessageLevel
            levels.append(level)
            message = c_obj.RuntimeMessages
            messages.append(message)
            print message
        for i in range(len(messages)):
            obj.AddRuntimeMessage(levels[i],str(messages[i]))


5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles