ADNExplodeGeometry.ADN_Utility.AddOsmModifier C# (CSharp) Method

AddOsmModifier() public static method

Adds an object space modifier to provided node (by handle).
public static AddOsmModifier ( uint nodeHandle, IClass_ID cid ) : int
nodeHandle uint Input the node handle to add the modifier to.
cid IClass_ID Input the class id of the modifier add.
return int
        public static int AddOsmModifier(uint nodeHandle, IClass_ID cid)
        {
            try
            {

                IGlobal global = Autodesk.Max.GlobalInterface.Instance;
                IInterface14 ip = global.COREInterface14;

                IINode node = ip.GetINodeByHandle(nodeHandle);

                IObject obj = node.ObjectRef;
                IIDerivedObject dobj = global.CreateDerivedObject(obj);
                object objMod = ip.CreateInstance(SClass_ID.Osm, cid as IClass_ID);
                IModifier mod = (IModifier)objMod;

                dobj.AddModifier(mod, null, 0); // top of stack
                node.ObjectRef = dobj;
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
                return -1;
            }

            return 1;
        }