Creating Custom Attributes in C#



I’m relatively new to working with C# in 3ds max and am having some trouble figuring out how to do custom attributes. I can read them in C#, but I need to create them either by defining them in C# and applying them or using C# to apply custom attributes defined in maxscript.

I have been looking at ICustAttrib for a while and cannot figure out how to go about creating custom attributes or how to use it to assign the ones defined in maxscript (if that is even possible). None of the methods I see in ICustAttrib seem to allow me to define a new custom attributes. I have also looked as MSCustattrib. I get the feeling I will need to go down to the paramblock2 level, but am not sure. I am trying something along these lines:

            IICustAttribContainer mytest = root_node.CustAttribContainer;
            mytest.SetCustAttrib(1, my_attrib2);

But am not sure how to define the my_attrib2 variable. It is currently an ICustAttrib object.

I am porting a set of maxscripts over to C# partly to learn the SDK better and partly to give me some other flexibility within those apps.

Anyway, any help or hints would be appreciated.