[Bf-committers] PyNode in Cycles, some issues with Vector Socket ?

Lukas Tönne lukas.toenne at gmail.com
Tue Nov 18 10:10:32 CET 2014


If you connect the vector to a color input (assuming this is the case) you
can see an error message:

Traceback (most recent call last):
  File "/home/guest/test/test_node2.blend/test_node.py", line 35, in update
ValueError: bpy_struct: item.attr = val: sequences of dimension 0 should
contain 4 items, not 3

This means the color value needs 4 (RGBA) values instead of 3 (XYZ). For
testing, change the line like so (appends a 0.0 value to make it a 4 tuple):

o.to_socket.node.inputs[o.to_socket.name].default_value =
self.outputs["Position"].default_value[0:3] + (0.0,)

Also note that with this approach you can somewhat control cycles inputs,
but you won't get nice updates when objects move (or on other changes). For
this you'd need some more elaborate tricks to hook into the depsgraph, e.g.
using drivers. For simpler hacking you could also just do updates
constantly with a scene handler or so, but this could have unwanted side
effects.


On Mon, Nov 17, 2014 at 11:53 AM, Julien Duroure <julien.duroure at gmail.com>
wrote:

> Hi Thomas,
>
>
> Thanks for your feedback.
> In that case, this is quite strange that this is working for color.
>
> Anyway, is it planned to be possible in the future (far away ?)
>
> Julien
>
> On Mon, Nov 17, 2014 at 11:48 AM, Thomas Dinges <blender at dingto.org>
> wrote:
>
> > Hi,
> > this will not work.
> >
> > Cycles nodes are implemented as C++ /  OSL. Blenders UI knows your node,
> > but Cycles doesn’t.
> > You can not extend Cycles’ node systems with pynodes atm.
> >
> > Thomas
> >
> > Am 17.11.2014 um 11:44 schrieb Julien Duroure <julien.duroure at gmail.com
> >:
> >
> > > Hi all,
> > >
> > > I'm trying to implement some pynode in Cycles.
> > > I got some working nodes, and some issues.
> > >
> > > Bases on blend file provided [1] :
> > >
> > > - open .blend
> > > - run script
> > > - with cube selected, and "color" material choosen.
> > > - Algo in pynode "Object Attribute" is : if sphere is selected, color
> is
> > > red, else, color is green
> > >
> > > This works correctly.
> > > Now, change material to "position" material.
> > >
> > > - In my "Object Attribute" node, change objected.
> > >
> > > There is no change in texture coordinate. It seems that Vector Math
> node
> > > don't receive data from my PyNode.
> > >
> > > Any idea why this is working for color, but not for position ?
> > > Thanks !
> > >
> > > Don't hesitate to contact me if you need more information.
> > >
> > > [1] http://www.pasteall.org/blend/32913
> > >
> > > --
> > > Julien DUROURE
> > >
> > > http://julienduroure.com
> > > _______________________________________________
> > > Bf-committers mailing list
> > > Bf-committers at blender.org
> > > http://lists.blender.org/mailman/listinfo/bf-committers
> >
> > _______________________________________________
> > Bf-committers mailing list
> > Bf-committers at blender.org
> > http://lists.blender.org/mailman/listinfo/bf-committers
> >
>
>
>
> --
> Julien DUROURE
>
> http://julienduroure.com
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>


More information about the Bf-committers mailing list