ADNExplodeGeometry.ADN_Utility.GetModifier C# (CSharp) Method

GetModifier() public static method

This will return a modifier from the stack
public static GetModifier ( IINode nodeToSearch, IClass_ID cid ) : IModifier
nodeToSearch IINode Input node to search.
cid IClass_ID Input the class id of the modifier to find.
return IModifier
        public static IModifier GetModifier(IINode nodeToSearch, IClass_ID cid)
        {
            IGlobal global = Autodesk.Max.GlobalInterface.Instance;

            IIDerivedObject dobj = nodeToSearch.ObjectRef as IIDerivedObject;

            while (dobj != null)
            {
                int nmods = dobj.NumModifiers;
                for (int i = 0; i < nmods; i++)
                {
                    IModifier mod = dobj.GetModifier(i);
                    // have to compare ClassID Parts A and B separately. The equals operator is not
                    // implemented so it will return false even when they are equal.
                    if ((mod.ClassID.PartA == cid.PartA) && (mod.ClassID.PartB == cid.PartB))
                        return mod;
                }
                dobj = dobj.ObjRef as IIDerivedObject;
            }

            return null;
        }