测量曲面的面积(UG(NX)二次开发)

这里用的是比较笨的方法:首先抽取面成为片体,然后计算片体的面积,最后将片体删除。

在此给出抽取面成为片体的函数和计算片体面积的函数。

   ///


        /// 抽取面成片体
        ///

        /// 被抽取面
        /// 创建的片体
        public void ExtractFace(Face face, out Body sheet_body)
        {
            try
            {
                int mode = 0;
                Tag sheet_body_tag;
                theUFSession.Modl.ExtractFace(face.Tag, mode, out sheet_body_tag);
                sheet_body = Tag2NXObject(sheet_body_tag);
            }
            catch (Exception ex)
            {
                sheet_body = null;
                MessageBox.Show(ex.ToString());
            }
        }

   ///


        /// 计算片体的表面积
        ///

        /// 片体
        /// 面积
        public void AskAreaOfSheetbody(Body sheet_body, out double area)
        {
            try
            {
                Tag[] obj = new Tag[1] { sheet_body.Tag };
                int num_obj = 1;
                int type = 2;
                int unites = 4;
                double density = 1.0;
                int accuracy = 1;
                double[] acc_value = new double[11];
                for (int i = 0; i < 11; i++)
                {
                    acc_value[i] = 0.0254;
                }
                double[] mass_props = new double[47];
                double[] statistics = new double[13];
                theUFSession.Modl.AskMassProps3d(obj, num_obj, type, unites, density, accuracy, acc_value, mass_props, statistics);
                area = mass_props[0] * 1000000;
            }
            catch (Exception ex)
            {
                area = 0;
                MessageBox.Show(ex.ToString());
            }
        }

 

转载于:https://www.cnblogs.com/yyFisheep/archive/2012/08/27/2658725.html

你可能感兴趣的:(测量曲面的面积(UG(NX)二次开发))