Forum

#1 2017-03-17 20:50:43

ChienLoutre
Member

Macro Output Not Working

Hi !

I am building a script that creates a Macro and puts a list of tags in it, but i can't make it work.

The output doesn't seem to work... I must forget something, a connection, i am really stuck on this haha !

Code:

from guerilla import Document, Modifier, pynode, Node
doc = Document()
rGraph = []

for rendergraph in doc.children (type="RenderGraph", recursive=True):
    rGraph.append(rendergraph)

rGraph = rGraph[0]

nodes = ['foo', 'bar', 'baz', 'chien', 'loutre']
tags = []


with Modifier() as mod:

    rMacro = guerilla.RenderGraphMacro.create('CHARS',type='RenderGraphMacro', parent=rGraph)
    outp = rMacro.createoutput()
    print rMacro.getoutputclassname()

    mOutput = mod.createnode('Output', type='RenderGraphMacroOutput', parent=rMacro)
    inp = mOutput.createinput()
    inp.PlugName.set('Output')

    op_in_b = None
    op_out =None
    xpos = 0
    ypos = 0


    for each in nodes:
        tag = rGraph.loadfile('$(LIBRARY)/rendergraph/tag.gnode')
        tag = tag[0]
        tag.move(rMacro)
        mod.renamenode(tag, each)
        tag.Tag.set(each)
        tag_out = tag.getoutputs()[0].Plug

        if list(reversed(nodes)).index(each) == 0:
            #last item
            op_in_b.connect(tag_out)
            tag.NodePos.set([xpos,ypos])
            inp.Plug.connect(op_out)


        elif nodes.index(each) == 0:
            #first item
            op = rGraph.loadfile('$(LIBRARY)/rendergraph/binop.gnode')
            op = op[0]
            op.move(rMacro)

            op_in_a = op.getinputs()[0].Plug
            op_in_b = op.getinputs()[1].Plug
            op_out = op.getoutputs()[0].Plug

            op_in_a.connect(tag_out)
            tag.NodePos.set([xpos,ypos])
            op.NodePos.set([xpos+100,ypos+50])
            ypos += 100

        else:

            op_in_b.connect(tag_out)


            op = rGraph.loadfile('$(LIBRARY)/rendergraph/binop.gnode')
            op = op[0]
            op.move(rMacro)

            op_in_a = op.getinputs()[0].Plug

            op_in_a.connect(op_out)

            op_in_b = op.getinputs()[1].Plug
            op_out = op.getoutputs()[0].Plug

            tag.NodePos.set([xpos,ypos])

            xpos += 100
            op.NodePos.set([xpos+100,ypos+50])
            ypos += 100

If someone has a solution ?
Thanks smile


Maurin, MoPA student

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB