Out-ports for blocks

StephenTStephenT Fabric for MotionBuilder Posts: 77

Hi,

I'm getting my feet wet with blocks, but one of the first things I've run across is that I can't expose out-ports. This is kinda understandable - you can't, for example, return a value every iteration of a for loop.

However, I want to chain my dependencies. This implies connecting the subject of the for loop onto the next node that uses it. Also - this is how the samples are displayed (2.4 release).

I'm kinda confused - how did the samples do that? Should I only use the exec node for chaining dependencies? (I think I just realized what that port is for!)

Comments

  • StephenTStephenT Fabric for MotionBuilder Posts: 77

    note the "primes" IO port on the for loop

  • malbrechtmalbrecht Fabric for Houdini Posts: 752 ✭✭✭

    Moin,

    I am not fully getting what your problem is, but I'll try to respond anyway ...

    I'm getting my feet wet with blocks, but one of the first things I've run across is that I can't expose out-ports. This is kinda understandable - you can't, for example, return a value every iteration of a for loop.

    well, you cannot "return" a value from inside a loop, because there is no stack address to "return" to (don't take this literally, I am having a 6502 machine code JSR example in mind here) - but you can call a function from inside a loop that deals with a value.

    However, I want to chain my dependencies. This implies connecting the subject of the for loop onto the next node that uses it. Also - this is how the samples are displayed (2.4 release).

    I am puzzled: What do you mean by "subject of the loop"? A loop, usually, has a count (it is, after all, just a "while condition" loop with a built in counter). If any, I would call the counter the "subject" of the loop - and that you can easily connect to the next node. Every variable that you want to change within the loop you have to connect in - if this is of any help: It's not like in Python, but like in a real programming language, what happens in the loop, stays in the loop (local scopes). What you want to come out has to have come in.

    Maybe it would help if you could provide a sample graph ... *1

    Marc

    *1 It may also be that I am just not getting what exactly you are asking :)


    Marc Albrecht - marc-albrecht.de - does things.

  • StephenTStephenT Fabric for MotionBuilder Posts: 77

    Hey Marc,

    I've figured out the answer - even without an out-port defined, you can connect where the outport would be to another graph.

    If you look at the pic I posted - the 'primes' block argument is an IO port. You pass it into the loop, the loop fills it, then it some other node does something with it. However, when creating a block, you can't create IO ports. So how did they get that graph? After some random clicking, I accidentally stumbled on the above answer :)

    Thats the crux of what I was asking. If you pass in a variable to a for loop (an array for filling or whatever) then how does another node indicate get the result? When trying to expose an out-port, Canvas says it can't define out-ports.

  • pzionpzion Moderator, Fabric Employee Posts: 117 Fabric Employee

    First, look at the "Accumulate" node, it's probably more along the lines of what you want. You should look at how it's defined; blocks offer a lot of flexibility because you can make your own function nodes that drive blocks. You can have lots of blocks with lots of "fixed" and "user-defined" parameters.

    Second, there should be a trick to make this work, but it doesn't work right now (at least on the degas branch). The "writability" of a port isn't actually whether it is in vs. io or out, but rather whether it is connected eventually, on the left, to an io or out port. This means that you can pass the result of an out or io port to a "user port" on a block and write to it through a function node that simply sets its value. I don't think we currently have a Set node -- ironically, since it's incredibly simple -- but it's trivial to make a new one, taking an io "variable" port and an in "value" port, and just assigning value to variable. Then chain the Set node's exec to the block's exec and you're in business.

    Except, you're not, as I mentioned, as we seem to cache the original value of "variable". I believe this is a Canvas Core bug and I will file a ticket here.

    Peter Zion
    Fabric Engine

  • StephenTStephenT Fabric for MotionBuilder Posts: 77

    Thanks for the in-depth info Peter! The writability of ports is something I'm still coming to grips with.

    A lot of it is familiarity. And a lot is just adjusting thinking to fit in with a data flow, rather than sequential instructions. But things look good now - lots to enjoy with it!

Sign In or Register to comment.