Create Enums in VL

After trying a few times and getting some pretty nice crashes, I decided I’d come here and ask:

How does one create enums in VL?

hi guest, currently you can only create Enums with C# and import them…

what did you try and which VL version did you use when it crashed?

I’ll come back to you on that a little later, because I’m working with it at the moment and I don’t want to undo my current work. I think I tried to create a Dynamic Enum. Trying it in another patch document ant the moment causes an error (hovering over the red ringed node):
“Not in Dataflow context”
perhaps because the document isn’t linked to vvvv runtime.

Trying to delete the node causes this Pubop error (Pop-up box of pain):
“Object reference not set to an instance of an object.”

Full Error Here (41.0 KB)

Clicking continue and closing the document seems to sort it out.

Could you give me a quick guide to wiriting the enums in C#? they aren’t essential, just pretty useful.

the document patch is not a ‘normal patch’, it will not be “called” from any runtime. it is only an overview of the definitions that are inside the document. this means that you can only create definitions there. definitions are one of: Operation, Process, Record or Class.

“normal” nodes like +, create, … can only be used inside one of the above mentioned definitions.

in C# you define an Enum as you would normally do it:

using System;
using VL.Core; //required for the [Type] attribute

namespace MyVLStuff
{
    [Type] //this tells VL that this enum type is available
    public enum MyEnum
    {
        Option1,
        Option2,
        Option3
    }
}

how to get this into VL is descibed here:

but also not that this becomes much more easy in the upcoming alpha after the beta35.7 release.

also note that the above gives you the enumeration and the comparison nodes like = and != also IOBoxes will work with it. but these are the only nodes that will work with the enum. so to use the enum in a meaningful way you need some more logic, like checking for an entry with = and then place some code in an IF region if a enum value equals the entry…

I’ll give it a try, Thanks

Here we go, please see:

NOTE: This works with latest alphas and will be included in beta36!

1 Like

Hi @joreg, I get this error from the demo dynamicEnum code in the graybook.

It says The name Observable does not exist in the current context.

I’ve imported Collections.Specialized, Collections.Objects, Collections.Generic and VL.Lib.Collections.

ah, sorry, forgot to mention: requires the Rx-Main nuget. will also add some more additional info to that page shortly…

Cheers

info on dynamic enums is now updated (images still missing). also see:

please always let us know if you have any more questions!

Being picky, but your dynamic enum doesn’t work in vvvv.

Inside

Outside

hehe, jep, that’s not yet promised. but on the list of course…

1 Like

GitHub - vvvv/VL.DemoLib: A vl library with a few simple demo nodes written in c#

Is it working with vvvv_50alpha35.18_x64?
I trying to create enumeration in VL, is it possible? (Especially i’m interested because I see some changes with enumeration in upcoming release)

did you build the C# .sln in the VL.DemoLib?

@yar you still cannot patch your own enum in VL. what’s possible though, is to use enums and even dynamic enums created in c#. how to do this is described in the graybook articles linked above.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.