ConvertToTriangleFaces() public static method

This is the routine to convert the input node to triangle faces.
public static ConvertToTriangleFaces ( uint nodeHandle, bool convertToTri = true, bool addShell = true, float shell = 0.1f, bool addEditMesh = true, bool collapseNode = true, bool centerPivot = true ) : int
nodeHandle uint Input the node by handle.
convertToTri bool Input whether to convert to a tri object first.
addShell bool Input whether to add the shell modifier when finished converting to face.
shell float Input the shell thickness amount.
addEditMesh bool Input whether to add the Edit Mesh modifier when finished converting to face.
collapseNode bool Input whether to collapse the node afterwards.
centerPivot bool Input whether to center the pivot on each new face.
return int
Example #1
0
        private void m_btnExplodeIt_Click(object sender, RoutedEventArgs e)
        {
            //
            IGlobal      global = Autodesk.Max.GlobalInterface.Instance;
            IInterface14 ip     = global.COREInterface14;

            this.m_pnlProgressPanel.Visibility = System.Windows.Visibility.Visible;

            try
            {
                global.TheHold.Begin();

                ADN_Utility.SetProgressControl(this);

                bool convertPoly = EI_ConvertTypePoly; // true = poly, false = tri
                bool attemptConvert;
                if (convertPoly)
                {
                    attemptConvert = EI_AttemptConvertToPoly;
                }
                else
                {
                    attemptConvert = EI_AttemptConvertToTri;
                }
                bool  addShell      = EI_AddShellModifier;
                float shellAmount   = EI_ShellAmount;
                bool  addEditMesh   = EI_AddEditMeshModifier;
                bool  collapseStack = EI_CollapseStack;
                bool  deleteNode    = EI_DeleteOriginal;

                //ip.DisableSceneRedraw();
                int stat         = 0;
                int nNumSelNodes = ip.SelNodeCount;
                m_lblTotNode.Content = nNumSelNodes.ToString();

                for (int i = 0; i < nNumSelNodes; i++)
                {
                    IINode nodeCur = ip.GetSelNode(i);
                    m_lblNodeName.Content = nodeCur.Name;
                    m_lblCurrNode.Content = i + 1;
                    if (convertPoly)
                    {
                        stat = ADN_Utility.ConvertToPolygonFaces(nodeCur.Handle, attemptConvert, addShell, shellAmount, addEditMesh, collapseStack);
                        if (stat < 0)
                        {
                            break;
                        }
                    }
                    else
                    {
                        stat = ADN_Utility.ConvertToTriangleFaces(nodeCur.Handle, attemptConvert, addShell, shellAmount, addEditMesh, collapseStack);
                        if (stat < 0)
                        {
                            break;
                        }
                    }
                }


                if (stat < 0)
                {
                    global.TheHold.Cancel();
                }
                else
                {
                    // now we need to start at the top to delete the original nodes.
                    if (deleteNode)
                    {
                        IINodeTab tabNodes = global.INodeTabNS.Create();
                        ip.GetSelNodeTab(tabNodes);
                        if (tabNodes != null)
                        {
                            ip.DeleteNodes(tabNodes, true, true, false);
                        }
                    }
                    global.TheHold.Accept("ADN-PolygonExplode");
                }

                ip.RedrawViews(0, RedrawFlags.Normal, null);
            }
            catch
            {
                global.TheHold.Cancel();
            }

            this.m_pnlProgressPanel.Visibility = System.Windows.Visibility.Hidden;
            ADN_Utility.ClearProgressControl(this);

            m_winParent.Close();
            m_bOk = true;
        }