How to ITab<> class with .NET c#

How to ITab<> class with .NET c#

sharfym
Contributor Contributor
669 Views
2 Replies
Message 1 of 3

How to ITab<> class with .NET c#

sharfym
Contributor
Contributor

ITab<IPoint3> pnts = Global.Tab.Create<IPoint3>();

ITab<IntPtr> adr = Global.Tab.Create<IntPtr>();

 

Are there any code snippets available that show usage of  ITab<> class and its functions with max .net.

 

thanks

 

 

 

0 Likes
670 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

An ITab<T> is really just a List<T>, without actually implementing the IList, ICollection, etc. interfaces.

 

I wrote a little extension method to convert ITab<T> to an IEnumerable to easily iterate through the list:

 

        public static IEnumerable<T> ToIEnumerable<T>(this ITab<T> itab)
        {
            if (itab == null)
            {
                yield break;
            }

            for (int i = 0; i < itab.Count; i++)
            {
                yield return itab[i];
            }
        }

 

If you're asking for an example of where you'd use an ITab, my most common case is the result of running MaxScript from C# - you'll often want to return an ITab<> of data. Here's one that's 100% in C# though:

 

ITab<IMtlBase> materialsLib = GlobalInterface.Instance.COREInterface15.SceneMtls;

foreach (var materialBase in materialsLib.ToIEnumerable())
{
    [...]

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

[Deleted]

0 Likes