How to make my custom enum work with gammas enum nodes?

hi all,

I followed the example in the grey book to create custom enums via a DLL. Now I want to make them work with the dynamic enum nodes that come with gamma. Is that possible?

Most of the Enum functionality is forwarded from:

Logic nodes like “Switch” do not pick up my enum datatype.
ATM I can copy my enum dropdown and connect them to a switch (and it works)
But it would be nice being able to patch this upwards (like with font and paragraph)



That should work by default. So the question is what did you do exactly in order to not make it work?!

  • Ideally please share a simple demo project that shows this issue
  • Also please point to the exact section in the graybook you followed
  • And which version of vvvv are we talking about?

I am on stable 2021.4.12, I followed this tutorial in the grey book.
I downloaded the VL.DemoLib and edited the CSharp example.

I created a new solution which contains the example from the demo lib, as well as my custom enum implementation. I was not able to get it running in this example. Everytime I click on the enum itself the error log pops up.

But the code is identical to the vl.demolib example
What am I doing wrong?

just tried to download and look at this. but the link is broken. can’t you upload the file here?

I tried uploading the whole solution, here is the script itself: (1.1 KB)

ok, looking at that code, you’re missing the CreateDefault attribute. please have a closer look at the sample code you linked to in the graybook. there is a [CreateDefault] attribute just above the CreateDefault() method.

indeed the demolib probably has not been updated to include that attribute.

I tried adding the attribute you mentioned, but then I am missing some references:

ok seems a lot has changed. could you provide an example of the way mentioned in the grey book? idk which references to add. It now implements “DynamicEnumDefinitionBase” instead of “ManualDynamicEnumDefinitionBase” and also multiple new interfaces.



the only reference that should be necessary is one to the VL.Core nuget.

had a brief look over the demolib example and it indeed does not show the classic dynamic enum usecase but one that allows you to add/remove items from within a patch…

I am still struggling to implement multiple custom enums.

@joreg you mentioned that I am missing a “create default” attribute in my code, but the example in demo.lib is also missing this, and works flawlessly, even on latest previews. (btw, this is also the implementation I need. Being able to add and remove entries at runtime.)

I tried adding the attribute to the code, but it is not getting recognised as such. The “Serializable” registers as attribute, “Create default” just points to the function.

When I use my dll (demo.lib implementation) with latest previews I get a new error message:

"    AmbiguousMatchException: "Ambiguous match found."
            System.RuntimeType { protected virtual System.Reflection.PropertyInfo GetPropertyImpl(string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Type returnType, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) { ... } } 
            System.Type { public virtual System.Reflection.PropertyInfo GetProperty(string name, System.Reflection.BindingFlags bindingAttr) { ... } } 
            VL.Lib.Collections.DynamicEnumExtensions { public static VL.Lib.Collections.IDynamicEnumDefinition GetDynamicEnumDefinition(System.Type type) { ... } } 

idk where this ambiguous match is originating from. The DLL. is referenced once in my VL project. I thought maybe it’s the exposed “create default” functions in the definitions and renamed them. Still, no change.

right, because it is using the “old way” of doing this using a forward for the CreateDefault method. “new way” is using the attribute. and attributes have to be applied to methods, not comments (as you did in the screenshot).

re the ambiguos match: can you share your code? (1.3 KB)
Still using the old code from above.

I tried setting up a net6.0 project in VS 2022.
But when I try to add the Vl.Core nuget, it just shows versions up to 4.x

yes, I set 6.0 for framework

In VS 2019, when opening the DemoLib example, it allows me to download the latest VL.Core

although the old framework is specified

So I’m still a bit confused on how to set this solution up.
VS 22, using just the VL.Core 2022.5.0 nuget.
The code from the Demo.Lib should work?
But I shall add the attribute, since this is the new way to use external functions.

The other enum code on the gray book deals with interfaces and observables.
I guess I do not have to use that if the simple way works for me?

wowow… you’re confusing yourself. don’t jump around so wild. you said you wanted to do this with 2021.4.12, so stick with it. did you fix the [CreateDefault] as i suggested?

I’ve now updated the DemoLib repo to 2021.4.12 and also using the [CreateDefault] attribute instead of the forward. hope this helps.

1 Like

Hey Joreg, thanks a lot for updating the Demo.Lib!

I pasted my code into the new solution and added those attributes you suggested. Enums are working again, with stable and previews.

I guess my initial question was about this ord2enum. This cannot work with dynamic enums, I figured it out now. The nodeset for the dynamic ones does work!

1 Like

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