Esempio n. 1
0
    public void dialogShown_cb()
    {
        try
        {
            realanno.GetProperties().SetLogical("Show", true);

            newviewname.GetProperties().SetLogical("Show", false);
            ifcro.GetProperties().SetLogical("Value", false);
            cro.GetProperties().SetLogical("Enable", false);
            if (ifcro.GetProperties().GetLogical("Value"))
            {
                cro.GetProperties().SetLogical("Enable", true);
            }
            else if (!ifcro.GetProperties().GetLogical("Value"))
            {
                cro.GetProperties().SetLogical("Enable", false);
            }
            iflabel.GetProperties().SetLogical("Value", false);
            selection01.GetProperties().SetLogical("Enable", false);
            OpenFile(ApplicationPath + folderpath + cappass);//undone
            // SetSBF();
            //Part workPart = theSession.Parts.Work;
            //     ModelingViewCollection a = workPart.ModelingViews;
            //     aaa = a.ToArray();
            //  strvalue = new string[aaa.Length+1];
            // int i ;
            //     for ( i = 0; i < aaa.Length;i++ )
            //     {
            //         //enum0.GetProperties().SetEnum("Value", i);
            //        strvalue[i] = aaa[i].Name;

            //     }
            //     strvalue[i] = "添加新视图";
            //     enum0.GetProperties().SetEnumMembers("Value", strvalue);
            //zhushiwenzi = realanno.GetProperties().GetStrings("Value");//这个是注释文字
            //realanno.GetProperties().SetString("Value","");
            refreshenum();
            Session theSession  = Session.GetSession();
            Part    workPart    = theSession.Parts.Work;
            Part    displayPart = theSession.Parts.Display;
            try
            {
                string name = workPart.ModelingViews.WorkView.Name;
                enum0.GetProperties().SetEnumAsString("Value", name);
            }
            catch
            {
                theUI.NXMessageBox.Show("提示", NXMessageBox.DialogType.Warning, "当前工作视图为轻量级剖视图,在此视图下本工具中视图切换工具无法正常使用,\n可将其他非轻量级剖视图设为工作视图后重新启用本工具");
                enum0.GetProperties().SetLogical("Enable", false);
                return;
            }
        }
        catch (Exception ex)
        {
            //---- Enter your exception handling code here -----
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
        }
    }
Esempio n. 2
0
    //------------------------------------------------------------------------------
    //Callback Name: apply_cb
    //------------------------------------------------------------------------------
    public int apply_cb()
    {
        int errorCode = 0;

        try
        {
            if (string0.GetProperties().GetString("Value").Length == 0)
            {
                if (!bodySelect0.GetProperties().GetLogical("Enable"))
                {
                    PartLoadStatus partLoadStatus1;
                    string         path    = nativeFileBrowser0.GetProperties().GetString("Path");    //得到这个浏览器所抓取到的文件的路径
                    Part           thepart = theSession.Parts.OpenDisplay(path, out partLoadStatus1); //打开它并把它显示在窗口中
                    //partLoadStatus1.
                    partLoadStatus1.Dispose();
                    thepart.SetAttribute("所处工序阶段", enum0.GetProperties().GetEnumAsString("Value"));//为一个零件设置属性
                }
                else
                {
                    theoriPart = bodySelect0.GetProperties().GetTaggedObjectVector("SelectedObjects");
                    Body theori = Tag2NXObject <Body>(theoriPart[0].Tag);
                    theori.OwningPart.SetAttribute("所处工序阶段", enum0.GetProperties().GetEnumAsString("Value"));//先得到所选的这个体的owningpart.这个很重要
                    //  theori.SetAttribute("所处工序阶段", enum0.GetProperties().GetEnumAsString("Value"));
                };
            }
            else
            {
                if (!bodySelect0.GetProperties().GetLogical("Enable"))
                {
                    PartLoadStatus partLoadStatus1;
                    string         path    = nativeFileBrowser0.GetProperties().GetString("Path");    //得到这个浏览器所抓取到的文件的路径
                    Part           thepart = theSession.Parts.OpenDisplay(path, out partLoadStatus1); //打开它并把它显示在窗口中
                    //partLoadStatus1.
                    partLoadStatus1.Dispose();
                    thepart.SetAttribute("所处工序阶段", string0.GetProperties().GetString("Value"));//为一个零件设置属性
                }
                else
                {
                    theoriPart = bodySelect0.GetProperties().GetTaggedObjectVector("SelectedObjects");
                    Body theori = Tag2NXObject <Body>(theoriPart[0].Tag);
                    theori.OwningPart.SetAttribute("所处工序阶段", string0.GetProperties().GetString("Value"));
                    //  theori.SetAttribute("所处工序阶段", enum0.GetProperties().GetEnumAsString("Value"));
                };
            };


            //---- Enter your callback code here -----
        }
        catch (Exception ex)
        {
            //---- Enter your exception handling code here -----
            errorCode = 1;
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
        }
        return(errorCode);
    }
Esempio n. 3
0
 //------------------------------------------------------------------------------
 //Callback Name: dialogShown_cb
 //This callback is executed just before the dialog launch. Thus any value set
 //here will take precedence and dialog will be launched showing that value.
 //------------------------------------------------------------------------------
 public void dialogShown_cb()
 {
     try
     {
         nativeFileBrowser0.GetProperties().SetString("Path", null);
         string0.GetProperties().SetString("Value", null);
         //---- Enter your callback code here -----
     }
     catch (Exception ex)
     {
         //---- Enter your exception handling code here -----
         theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
     }
 }
Esempio n. 4
0
 //------------------------------------------------------------------------------
 //Callback Name: dialogShown_cb
 //This callback is executed just before the dialog launch. Thus any value set
 //here will take precedence and dialog will be launched showing that value.
 //------------------------------------------------------------------------------
 public void dialogShown_cb()
 {
     try
     {
         selection01.GetProperties().SetLogical("Enable", false);
         ifotherbase.GetProperties().SetEnum("Value", 0);
         firstrefbase.GetProperties().SetLogical("Enable", false);
         firstrefbasemat.GetProperties().SetLogical("Enable", false);
         secrefbase.GetProperties().SetLogical("Enable", false);
         secrefbasemat.GetProperties().SetLogical("Enable", false);
         toggle0.GetProperties().SetLogical("Value", false);
     }
     catch (Exception ex)
     {
         //---- Enter your exception handling code here -----
         theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
     }
 }
Esempio n. 5
0
    //------------------------------------------------------------------------------
    //Callback Name: ApplyCB
    //------------------------------------------------------------------------------
    public int ApplyCB()
    {
        int errorCode = 0;

        try
        {
            //   Session.UndoMarkId markid = tSetUndoMark(Session.MarkVisibility.Visible, "Test");

            // theSession.UndoToMark(markid, "Test");
            // theSession.DeleteUndoMark(markids[index++], "");
            // markids[index] = theSession.SetUndoMark(Session.MarkVisibility.Visible, "a");

            //回转母线
            TaggedObject[] obs1 = super_section0.GetProperties().GetTaggedObjectVector("SelectedObjects");
            if (obs1.GetLength(0) == 0)
            {
                // theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Warning, "请选择回转母线!");
                return(1);
            }
            //回转轴
            TaggedObject[] obs2 = axis0.GetProperties().GetTaggedObjectVector("SelectedObjects");
            if (obs2.GetLength(0) == 0)
            {
                // theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Warning, "请选择回转轴!");
                return(1);
            }
            //要修剪的体
            TaggedObject[] obs3 = bodySelect0.GetProperties().GetTaggedObjectVector("SelectedObjects");
            if (obs3.GetLength(0) == 0)
            {
                // theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Warning, "请选择目标体!");
                return(1);
            }

            //是否反向
            bool reverse = toggle0.GetProperties().GetLogical("Value");

            Section section = (Section)obs1[0];
            Axis    axis    = (Axis)obs2[0];
            Body    body    = (Body)obs3[0];
            NXOpen.Features.Revolve revolve = NXFun.Revolve(section, axis);
            Body[] bodys = revolve.GetBodies();

            //修剪体
            NXFun.TrimBody(body, bodys[0], reverse);

            //隐藏面
            Body[] bs = revolve.GetBodies();
            NXFun.BlankObject(bs[0]);
        }
        catch (Exception ex)
        {
            errorCode = 1;
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
        }
        return(errorCode);
    }
Esempio n. 6
0
    //------------------------------------------------------------------------------
    //Callback Name: dialogShown_cb
    //------------------------------------------------------------------------------
    public void dialogShown_cb()
    {
        try
        {
            isShowResult = false;
            button01.GetProperties().SetString("Bitmap", "3dppm_finder");
            button01.GetProperties().SetString("Label", "显示结果");
            group1.GetProperties().SetLogical("Show", false);
//             if (theSession.IsInTaskEnvironment)
//             {
//                 theSession.BeginTaskEnvironment();
//             }
        }
        catch (Exception ex)
        {
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
        }
    }
Esempio n. 7
0
    //------------------------------------------------------------------------------
    //Callback Name: apply_cb
    //------------------------------------------------------------------------------
    public int apply_cb()
    {
        int errorCode = 0;

        try
        {
            firstpt = point0.GetProperties().GetTaggedObjectVector("SelectedObjects");
            secpt   = point01.GetProperties().GetTaggedObjectVector("SelectedObjects");
            Point    a      = Tag2NXObject <Point>(firstpt[0].Tag);
            Point    b      = Tag2NXObject <Point>(secpt[0].Tag);
            NXObject axisyo = shank(a, b);
            double[] real3d;
            NXOpen.Features.DatumAxisFeature axisreal = (NXOpen.Features.DatumAxisFeature)axisyo;
            DatumAxis axisreal1 = axisreal.DatumAxis;
            Point3d   stpt;  //轴的起点
            Point3d   endpt; //轴的终点
            stpt  = a.Coordinates;
            endpt = b.Coordinates;
            // axisreal1.GetEndPoints(out stpt, out endpt);
            hideit(axisreal1);
            real3d = angle(axisreal1);
            thepmi = selection0.GetProperties().GetTaggedObjectVector("SelectedObjects");
            NXObject last = Tag2NXObject <NXObject>(thepmi[0].Tag);
            NXOpen.Annotations.Dimension lastdimn = (NXOpen.Annotations.Dimension)last;
            double m     = lastdimn.ComputedSize;
            double cosx  = Math.Cos(ConvertDegreesToRadians(real3d[0]));
            double cosy  = Math.Cos(ConvertDegreesToRadians(real3d[1]));
            double cosz  = Math.Cos(ConvertDegreesToRadians(real3d[2]));
            double cosxx = cosx * m;
            double cosyy = cosy * m;
            double coszz = cosz * m;
            last.SetAttribute("X", cosxx);
            last.SetAttribute("Y", cosyy);
            last.SetAttribute("Z", coszz);
            last.SetAttribute("START-X", stpt.X);
            last.SetAttribute("START-Y", stpt.Y);
            last.SetAttribute("START-Z", stpt.Z);
            last.SetAttribute("END-X", endpt.X);
            last.SetAttribute("END-Y", endpt.Y);
            last.SetAttribute("END-Z", endpt.Z);

            //---- Enter your callback code here -----
        }
        catch (Exception ex)
        {
            //---- Enter your exception handling code here -----
            errorCode = 1;
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
        }
        return(errorCode);
    }
Esempio n. 8
0
    public void dialogShown_cb()
    {
        try
        {
            ifcro.GetProperties().SetLogical("Value", false);
            cro.GetProperties().SetLogical("Enable", false);
            if (ifcro.GetProperties().GetLogical("Value"))
            {
                cro.GetProperties().SetLogical("Enable", true);
            }
            else if (!ifcro.GetProperties().GetLogical("Value"))
            {
                cro.GetProperties().SetLogical("Enable", false);
            }
            OpenFile("F:\\ano\\application\\CAPP助手.exe");
            SetSBF();
            Part workPart            = theSession.Parts.Work;
            ModelingViewCollection a = workPart.ModelingViews;
            aaa      = a.ToArray();
            strvalue = new string[aaa.Length + 1];
            int i;
            for (i = 0; i < aaa.Length; i++)
            {
                //enum0.GetProperties().SetEnum("Value", i);
                strvalue[i] = aaa[i].Name;
            }
            strvalue[i] = "添加新视图";
            enum0.GetProperties().SetEnumMembers("Value", strvalue);

            //---- Enter your callback code here -----
        }
        catch (Exception ex)
        {
            //---- Enter your exception handling code here -----
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
        }
    }
Esempio n. 9
0
    //------------------------------------------------------------------------------
    //---------------------Block Styler Callback Functions--------------------------
    //------------------------------------------------------------------------------

    //------------------------------------------------------------------------------
    //Callback Name: initialize_cb
    //------------------------------------------------------------------------------
    public void initialize_cb()
    {
        try
        {
            group0      = theDialog.TopBlock.FindBlock("group0");
            blockHeight = theDialog.TopBlock.FindBlock("blockHeight");
            blockWidth  = theDialog.TopBlock.FindBlock("blockWidth");
            blockLength = theDialog.TopBlock.FindBlock("blockLength");
            blockOrigin = theDialog.TopBlock.FindBlock("blockOrigin");
            blockColor  = theDialog.TopBlock.FindBlock("blockColor");

            // Set the upper-limits and lower-limits
            PropertyList blockHeightProps = blockHeight.GetProperties();
            blockHeightProps.SetDouble("MaximumValue", 100000.0);
            blockHeightProps.SetDouble("MinimumValue", 0.001);
            blockHeightProps.SetDouble("Value", 100.0);
            blockHeightProps.Dispose();
            blockHeightProps = null;

            PropertyList blockWidthProps = blockWidth.GetProperties();
            blockWidthProps.SetDouble("MaximumValue", 100000.0);
            blockWidthProps.SetDouble("MinimumValue", 0.001);
            blockWidthProps.SetDouble("Value", 100.0);
            blockWidthProps.Dispose();
            blockWidthProps = null;

            PropertyList blockLengthProps = blockLength.GetProperties();
            blockLengthProps.SetDouble("MaximumValue", 100000.0);
            blockLengthProps.SetDouble("MinimumValue", 0.001);
            blockLengthProps.SetDouble("Value", 100.0);
            blockLengthProps.Dispose();
            blockLengthProps = null;
        }
        catch (Exception ex)
        {
            //---- Enter your exception handling code here -----
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.Message);
        }
    }
Esempio n. 10
0
    //------------------------------------------------------------------------------
    //Callback Name: update_cb
    //------------------------------------------------------------------------------
    public int update_cb(NXOpen.BlockStyler.UIBlock block)
    {
        try
        {
            if (block == enum0)
            {
                Part   workPart  = theSession.Parts.Work;
                Layout layout1   = (Layout)workPart.Layouts.FindObject("L1");//此处写死了。。。。。TAG ERROR
                int    sel       = enum0.GetProperties().GetEnum("Value");
                string addnewstr = enum0.GetProperties().GetEnumAsString("Value");
                if (addnewstr != "添加新视图")
                {
                    layout1.ReplaceView(workPart.ModelingViews.WorkView, aaa[sel], true);
                }
                else
                {
                    string newviewname = null;
                    addnew.Show_addnew();
                    addnew theaddnew = new addnew();
                    //newviewname = theaddnew.string0.GetProperties().GetString("Value");
                    //switch (theUI.NXMessageBox.Show("添加新视图", NXMessageBox.DialogType.Question, "是否添加新视图"))
                    //{
                    //    case 0:

                    //        break;
                    //    case 1:

                    //        break;

                    //}
                }

                //---------Enter your code here-----------
            }
            else if (block == ifcro)
            {
                if (ifcro.GetProperties().GetLogical("Value"))
                {
                    cro.GetProperties().SetLogical("Enable", true);
                }
                else if (!ifcro.GetProperties().GetLogical("Value"))
                {
                    cro.GetProperties().SetLogical("Enable", false);
                }


                //---------Enter your code here-----------
            }
            else if (block == cro)
            {
                //---------Enter your code here-----------
            }
            else if (block == realanno)
            {
                //---------Enter your code here-----------
            }
            else if (block == iflabel)
            {
                //---------Enter your code here-----------
            }
            else if (block == selection01)
            {
                if (iflabel.GetProperties().GetLogical("Value"))
                {
                    selection01.GetProperties().SetLogical("Enable", true);
                }
                else if (!iflabel.GetProperties().GetLogical("Value"))
                {
                    selection01.GetProperties().SetLogical("Enable", false);
                }
                //---------Enter your code here-----------
            }
            else if (block == point0)
            {
                NXOpen.TaggedObject[]    guanlian    = null;
                NXOpen.DisplayableObject guanlianobj = null;
                if (ifcro.GetProperties().GetLogical("Value") == true)
                {
                    guanlian    = cro.GetProperties().GetTaggedObjectVector("SelectedObjects");
                    guanlianobj = Tag2NXObject <DisplayableObject>(guanlian[0].Tag);//这个是关联对象
                }


                string[] zhushiwenzi = realanno.GetProperties().GetStrings("Value");//这个是注释文字

                NXOpen.TaggedObject[] zhiyin    = null;
                NXOpen.NXObject       zhiyinobj = null;

                if (iflabel.GetProperties().GetLogical("Value") == true)
                {
                    zhiyin = selection01.GetProperties().GetTaggedObjectVector("SelectedObjects");

                    zhiyinobj = Tag2NXObject <NXObject>(zhiyin[0].Tag);//指引线
                }
                NXOpen.TaggedObject[] placept = null;
                placept = point0.GetProperties().GetTaggedObjectVector("SelectedObjects");
                Point   placeptobj   = Tag2NXObject <Point>(placept[0].Tag);//注释最后的放置点
                Point3d placeptobj3d = placeptobj.Coordinates;
                //---------Enter our code here-----------

                thenotefun.function_note(zhushiwenzi, guanlianobj, zhiyinobj, placeptobj3d);
            }
            else if (block == dic)
            {
                //---------Enter your code here-----------
            }
            else if (block == str)
            {
                //---------Enter your code here-----------
            }
            else if (block == button0) //这个就是添加按钮,在这里调用
            {
                string diction = null; //这个有”添加至CAPP助手“中得到的字符串
                diction = dic.GetProperties().GetString("Value");
                string strvalue = str.GetProperties().GetEnumAsString("Value");
                switch (strvalue)
                {
                case "加工前准备":

                    break;

                case "工作内容":


                    break;

                case "技术条件":

                    break;

                case "附注":

                    break;

                case "特种工艺术语":

                    break;

                case "检验工序":

                    break;

                case "常用符号":

                    break;
                }
                //---------Enter your code here-----------
            }
        }
        catch (Exception ex)
        {
            //---- Enter your exception handling code here -----
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
        }
        return(0);
    }
Esempio n. 11
0
    //------------------------------------------------------------------------------
    //Callback Name: update_cb
    //------------------------------------------------------------------------------
    public int update_cb(NXOpen.BlockStyler.UIBlock block)
    {
        try
        {
            if (block == tolatt)
            {
                //---------Enter your code here-----------
            }
            else if (block == framstyle)
            {
                //---------Enter your code here-----------
            }
            else if (block == double0)
            {
                //---------Enter your code here-----------
            }
            else if (block == valuestyle)
            {
                //---------Enter your code here-----------
            }
            else if (block == matrstyle)
            {
                //---------Enter your code here-----------
            }
            else if (block == mainbase)
            {
                //---------Enter your code here-----------
            }
            else if (block == maiinbasemat)
            {
                //---------Enter your code here-----------
            }
            else if (block == separator0)
            {
                //---------Enter your code here-----------
            }
            else if (block == separator01)
            {
                //---------Enter your code here-----------
            }
            else if (block == ifotherbase)
            {
                int m = ifotherbase.GetProperties().GetEnum("Value");
                if (m == 0)
                {
                    firstrefbase.GetProperties().SetLogical("Enable", false);
                    firstrefbasemat.GetProperties().SetLogical("Enable", false);
                    secrefbase.GetProperties().SetLogical("Enable", false);
                    secrefbasemat.GetProperties().SetLogical("Enable", false);
                }
                else if (m == 1)
                {
                    firstrefbase.GetProperties().SetLogical("Enable", true);
                    firstrefbasemat.GetProperties().SetLogical("Enable", true);
                    secrefbase.GetProperties().SetLogical("Enable", false);
                    secrefbasemat.GetProperties().SetLogical("Enable", false);
                }
                else if (m == 2)
                {
                    firstrefbase.GetProperties().SetLogical("Enable", true);
                    firstrefbasemat.GetProperties().SetLogical("Enable", true);
                    secrefbase.GetProperties().SetLogical("Enable", true);
                    secrefbasemat.GetProperties().SetLogical("Enable", true);
                }
                //---------Enter your code here-----------
            }
            else if (block == separator02)
            {
                //---------Enter your code here-----------
            }
            else if (block == firstrefbase)
            {
                //---------Enter your code here-----------
            }
            else if (block == firstrefbasemat)
            {
                //---------Enter your code here-----------
            }
            else if (block == separator03)
            {
                //---------Enter your code here-----------
            }
            else if (block == secrefbase)
            {
                //---------Enter your code here-----------
            }
            else if (block == secrefbasemat)
            {
                //---------Enter your code here-----------
            }
            else if (block == double01)
            {
                //---------Enter your code here-----------
            }
            else if (block == toggle0)
            {
                if (toggle0.GetProperties().GetLogical("Value"))
                {
                    selection01.GetProperties().SetLogical("Enable", true);
                }
                else if (!toggle0.GetProperties().GetLogical("Value"))
                {
                    selection01.GetProperties().SetLogical("Enable", false);
                }
                //---------Enter your code here-----------
            }
            else if (block == selection01)
            {
                //---------Enter your code here-----------
            }
            else if (block == postion)
            {
                //---------Enter your code here-----------
            }
            else if (block == selection0)
            {
                //---------Enter your code here-----------
            }
            else if (block == point0)
            {
                plcpoint    = point0.GetProperties().GetTaggedObjectVector("SelectedObjects");
                theplcpoint = Tag2NXObject <Point>(plcpoint[0].Tag);
                Point3d pt3d     = theplcpoint.Coordinates; //这个就是放置点
                string  attvalue = tolatt.GetProperties().GetEnumAsString("Value");
                object  attrtype = null;                    //这个是公差类型
                switch (attvalue)
                {
                case "直线度":
                    attrtype = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.Straightness;
                    break;

                case "平面度":
                    attrtype = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.Flatness;

                    break;

                case "圆度":
                    attrtype = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.Circularity;
                    break;

                case "圆柱度":
                    attrtype = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.Cylindricity;
                    break;

                case "直线轮廓":
                    attrtype = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.ProfileOfALine;
                    break;

                case "曲面轮廓":
                    attrtype = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.ProfileOfASurface;
                    break;

                case "倾斜度":
                    attrtype = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.Angularity;
                    break;

                case "垂直度":
                    attrtype = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.Perpendicularity;
                    break;

                case "平行度":
                    attrtype = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.Parallelism;
                    break;

                case "位置":
                    attrtype = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.Position;
                    break;

                case "对称度":
                    attrtype = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.Symmetry;
                    break;

                case "同轴度":
                    attrtype = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.Concentricity;
                    break;

                case "圆跳动":
                    attrtype = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.CircularRunout;
                    break;

                case "全跳动":
                    attrtype = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.TotalRunout;
                    break;
                }
                int    i          = valuestyle.GetProperties().GetEnum("Value");
                object zhileixing = null;//这个是公差的值类型,可以是fai,Sfai.
                if (i == 0)
                {
                    zhileixing = NXOpen.Annotations.FeatureControlFrameDataBuilder.ToleranceZoneShape.Diameter;
                }
                else if (i == 1)
                {
                    zhileixing = NXOpen.Annotations.FeatureControlFrameDataBuilder.ToleranceZoneShape.None;
                }
                else if (i == 2)
                {
                    zhileixing = NXOpen.Annotations.FeatureControlFrameDataBuilder.ToleranceZoneShape.SphericalDiameter;
                }
                object matcondition = null;//行为公差的材料状况
                //string matconditionatt =  .GetProperties().GetEnumAsString("Value");
                string matconditionatt = matrstyle.GetProperties().GetEnumAsString("Value");
                if (matconditionatt == "最好材料状况")
                {
                    matcondition = NXOpen.Annotations.FeatureControlFrameDataBuilder.ToleranceMaterialModifier.MaximumMaterialCondition;
                }
                else if (matconditionatt == "最差材料状况")
                {
                    matcondition = NXOpen.Annotations.FeatureControlFrameDataBuilder.ToleranceMaterialModifier.LeastMaterialCondition;
                }
                else if (matconditionatt == "不考虑特征大小")
                {
                    matcondition = NXOpen.Annotations.FeatureControlFrameDataBuilder.ToleranceMaterialModifier.RegardlessOfFeatureSize;
                }
                else if (matconditionatt == "无")
                {
                    matcondition = null;
                }
                string baseattstr = mainbase.GetProperties().GetEnumAsString("Value");    //基准类型A----H
                if (baseattstr == "无")
                {
                    baseattstr = null;
                }
                string mainbasematstr = maiinbasemat.GetProperties().GetEnumAsString("Value");
                object mainbasematobj = null;//这个是主基准材料状况
                if (mainbasematstr == "最好材料状况")
                {
                    mainbasematobj = NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition.MaximumMaterialCondition;
                }
                else if (mainbasematstr == "最差材料状况")
                {
                    mainbasematobj = NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition.LeastMaterialCondition;
                }
                else if (mainbasematstr == "不考虑特征大小")
                {
                    mainbasematobj = NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition.RegardlessOfFeatureSize;
                }
                else if (mainbasematstr == "无")
                {
                    mainbasematobj = null;
                }
                string firstbasestr = firstrefbase.GetProperties().GetEnumAsString("Value");//第一参考基准,也就是平常说的第二参考基准
                if (firstbasestr == "无")
                {
                    firstbasestr = null;
                }
                string firstbasematstr = firstrefbasemat.GetProperties().GetEnumAsString("Value");
                object firstbasematobj = null;//这个是第一(第二)参考基准的材料特性
                if (firstbasematstr == "最好材料状况")
                {
                    firstbasematobj = NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition.MaximumMaterialCondition;
                }
                else if (firstbasematstr == "最差材料状况")
                {
                    firstbasematobj = NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition.LeastMaterialCondition;
                }
                else if (firstbasematstr == "不考虑特征大小")
                {
                    firstbasematobj = NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition.RegardlessOfFeatureSize;
                }
                else if (firstbasematstr == "无")
                {
                    firstbasematobj = null;
                }
                string secbasestr = secrefbase.GetProperties().GetEnumAsString("Value");//第二参考基准(第三)
                if (secbasestr == "无")
                {
                    secbasestr = null;
                }
                string secbasematstr = secrefbasemat.GetProperties().GetEnumAsString("Value");

                object secbasematobj = null;//这个是第二(第三)参考基准的材料特性
                if (secbasematstr == "最好材料状况")
                {
                    secbasematobj = NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition.MaximumMaterialCondition;
                }
                else if (secbasematstr == "最差材料状况")
                {
                    secbasematobj = NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition.LeastMaterialCondition;
                }
                else if (secbasematstr == "不考虑特征大小")
                {
                    secbasematobj = NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition.RegardlessOfFeatureSize;
                }
                else if (secbasematstr == "无")
                {
                    secbasematobj = null;
                }
                double tolvalue = double0.GetProperties().GetDouble("Value");  //这个是公差值
                double zoom     = double01.GetProperties().GetDouble("Value"); //这个是放大缩小的因子

                int    pp    = framstyle.GetProperties().GetEnum("Value");
                object kuang = null; //框样式
                if (pp == 0)         //单框
                {
                    kuang = NXOpen.Annotations.FeatureControlFrameBuilder.FcfFrameStyle.SingleFrame;
                }
                else if (pp == 1)//多框
                {
                    kuang = NXOpen.Annotations.FeatureControlFrameBuilder.FcfFrameStyle.CompositeFrame;
                }
                int qq = postion.GetProperties().GetEnum("Value");
                //if (qq == 0)//折线形式是选择点
                //{
                //    Selection.MaskTriple[] msktripe = null;
                //    msktripe[0].Type = NXOpen.UF.UFConstants.UF_point_type;
                //    selection0.GetProperties().SetSelectionFilter("SelectionFilter", Selection.SelectionAction.ClearAndEnableSpecific, msktripe);
                //    //NXOpen.TaggedObject tagobj = selection0.GetProperties().GetTaggedObject("SelectedObjects");
                //}
                //else if (qq == 1)//折现形式是选择线
                //{
                //    Selection.MaskTriple[] msktripe = null;
                //    msktripe[0].Type = NXOpen.UF.UFConstants.UF_solid_type;
                //    msktripe[0].Subtype = NXOpen.UF.UFConstants.UF_all_subtype;
                //    msktripe[0].SolidBodySubtype = NXOpen.UF.UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE;


                //}
                Point zhexiandian = null;
                NXOpen.TaggedObject[] tagobj00 = selection0.GetProperties().GetTaggedObjectVector("SelectedObjects");
                zhexiandian = Tag2NXObject <Point>(tagobj00[0].Tag);
                Point3d  realdian = zhexiandian.Coordinates; //这个是折线点
                NXObject guanlian = null;                    //关联对象
                if (selection01.GetProperties().GetLogical("Enable"))
                {
                    NXOpen.TaggedObject[] tagobj1 = selection01.GetProperties().GetTaggedObjectVector("SelectedObjects");

                    guanlian = Tag2NXObject <NXObject>(tagobj1[0].Tag);
                }

                int st = ifotherbase.GetProperties().GetEnum("Value");
                if (st == 0)
                {
                    firstbasematobj = null;
                    firstbasestr    = null;
                    secbasestr      = null;
                    secbasematobj   = null;
                }
                else if (st == 1)
                {
                    secbasestr    = null;
                    secbasematobj = null;
                }
                double conlength = double02.GetProperties().GetDouble("Value");//这是短线长度。
                Selection.MaskTriple msktrp;
                //msktrp.Subtype =
                //selection0.GetProperties().SetSelectionFilter("SelectionFilter",Selection.SelectionAction.ClearAndEnableSpecific,
                thefun.function(tolvalue.ToString(), baseattstr, firstbasestr, secbasestr, zhileixing, matcondition, mainbasematobj, firstbasematobj, secbasematobj, kuang, zoom, conlength, pt3d, realdian, guanlian);

                //---------Enter your code here-----------
            }
        }
        catch (Exception ex)
        {
            //---- Enter your exception handling code here -----
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
        }
        return(0);
    }
Esempio n. 12
0
    //------------------------------------------------------------------------------
    //Callback Name: dialogShown_cb
    //------------------------------------------------------------------------------
    public void dialogShown_cb()
    {
        try
        {
            //读取SheetTemplet.xml中的模板信息
            string xmlpath = NXFun.TDPPMPath + "SheetTemplet.xml";
            List <S_SheetTemplet> SheetTempletList = XML3DPPM.GetSheetTempletList(xmlpath);
            //分类存储
            SheetTempletListA3.Clear();
            SheetTempletListA4.Clear();
            SheetTempletListOther.Clear();
            foreach (S_SheetTemplet SheetTemplet in SheetTempletList)
            {
                if (SheetTemplet.type == "A3")
                {
                    SheetTempletListA3.Add(SheetTemplet);
                }
                else if (SheetTemplet.type == "A4")
                {
                    SheetTempletListA4.Add(SheetTemplet);
                }
                else
                {
                    SheetTempletListOther.Add(SheetTemplet);
                }
            }
            stringA3 = new string[SheetTempletListA3.Count];
            for (int i = 0; i < SheetTempletListA3.Count; i++)
            {
                stringA3[i] = SheetTempletListA3[i].chinese;
            }
            stringA4 = new string[SheetTempletListA4.Count];
            for (int i = 0; i < SheetTempletListA4.Count; i++)
            {
                stringA4[i] = SheetTempletListA4[i].chinese;
            }
            stringOther = new string[SheetTempletListOther.Count];
            for (int i = 0; i < SheetTempletListOther.Count; i++)
            {
                stringOther[i] = SheetTempletListOther[i].chinese;
            }
            //设置初始显示状态
            enum0.GetProperties().SetEnumAsString("Value", "A3");
            list_box0.GetProperties().SetStrings("ListItems", stringA3);

            //取得当前的图纸名称列表
            NXOpen.Drawings.DrawingSheet[] ds = theSession.Parts.Work.DrawingSheets.ToArray();
            SheetNames = new string[ds.Length];
            for (int i = 0; i < ds.Length; i++)
            {
                SheetNames[i] = ds[i].Name;
            }
            list_box02.GetProperties().SetStrings("ListItems", SheetNames);
            //设置图纸名
            string name;
            int    n = 1;
            do
            {
                name = "SHT" + n.ToString();
                n++;
            } while (NXFun.isFindInList(SheetNames, name));
            string0.GetProperties().SetString("Value", name);
        }
        catch (Exception ex)
        {
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
        }
    }
Esempio n. 13
0
    //------------------------------------------------------------------------------
    //Callback Name: update_cb
    //------------------------------------------------------------------------------
    public int update_cb(NXOpen.BlockStyler.UIBlock block)
    {
        try
        {
            if (block == enum0)
            {
                Part   workPart  = theSession.Parts.Work;
                Layout layout1   = (Layout)workPart.Layouts.FindObject("L1");//此处写死了。。。。。TAG ERROR
                int    sel       = enum0.GetProperties().GetEnum("Value");
                string addnewstr = enum0.GetProperties().GetEnumAsString("Value");
                if (addnewstr != "添加新视图")
                {
                    layout1.ReplaceView(workPart.ModelingViews.WorkView, aaa[sel], true);
                }
                else
                {
                    newviewname.GetProperties().SetLogical("Show", true);

                    //string newviewname = null;
                    ////add.Show_add();
                    //add theadd = new add();
                    //theadd.Show();
                    //newviewname = theaddnew.string0.GetProperties().GetString("Value");
                }

                //---------Enter your code here-----------
            }
            else if (block == ifcro)
            {
                if (ifcro.GetProperties().GetLogical("Value"))
                {
                    cro.GetProperties().SetLogical("Enable", true);
                }
                else if (!ifcro.GetProperties().GetLogical("Value"))
                {
                    cro.GetProperties().SetLogical("Enable", false);
                }


                //---------Enter your code here-----------
            }
            else if (block == cro)
            {
                //---------Enter your code here-----------
            }
            else if (block == realanno)
            {
                //---------Enter your code here-----------
            }
            else if (block == iflabel)
            {
                if (iflabel.GetProperties().GetLogical("Value"))
                {
                    selection01.GetProperties().SetLogical("Enable", true);
                }
                else if (!iflabel.GetProperties().GetLogical("Value"))
                {
                    selection01.GetProperties().SetLogical("Enable", false);
                }
                //---------Enter your code here-----------
            }
            else if (block == selection01)
            {
                //---------Enter your code here-----------
            }
            else if (block == point0)
            {
                NXOpen.TaggedObject[]    guanlian    = null;
                NXOpen.DisplayableObject guanlianobj = null;
                if (ifcro.GetProperties().GetLogical("Value") == true)
                {
                    guanlian = cro.GetProperties().GetTaggedObjectVector("SelectedObjects");
                    if (guanlian.Length == 0)
                    {
                        theUI.NXMessageBox.Show("未选择关联对象", NXMessageBox.DialogType.Warning, "请选择关联对象");

                        return(1);
                    }
                    guanlianobj = Tag2NXObject <DisplayableObject>(guanlian[0].Tag);//这个是关联对象
                }

                string[] zhushiwenzi = null;
                zhushiwenzi = realanno.GetProperties().GetStrings("Value");//这个是注释文字
                // int ps = zhushiwenzi[0].Length;
                //if (zhushiwenzi == null)
                //{

                //    theUI.NXMessageBox.Show("警告", NXMessageBox.DialogType.Error, "注释文字不能为空");
                //}
                NXOpen.TaggedObject[] zhiyin    = null;
                NXOpen.NXObject       zhiyinobj = null;

                if (iflabel.GetProperties().GetLogical("Value") == true)
                {
                    zhiyin = selection01.GetProperties().GetTaggedObjectVector("SelectedObjects");
                    if (zhiyin.Length == 0)
                    {
                        theUI.NXMessageBox.Show("未选择Label放置点", NXMessageBox.DialogType.Warning, "请选择Label放置点");
                        return(1);
                    }
                    zhiyinobj = Tag2NXObject <NXObject>(zhiyin[0].Tag);//指引线
                }
                NXOpen.TaggedObject[] placept = null;
                placept = point0.GetProperties().GetTaggedObjectVector("SelectedObjects");
                Point   placeptobj   = Tag2NXObject <Point>(placept[0].Tag);//注释最后的放置点
                Point3d placeptobj3d = placeptobj.Coordinates;
                //---------Enter our code here-----------
                SetSBF();
                thenotefun.function_note(zhushiwenzi, guanlianobj, zhiyinobj, placeptobj3d);
            }
            else if (block == dic)
            {
                //---------Enter your code here-----------
            }
            else if (block == newviewname)
            {
                Part workPart = theSession.Parts.Work;
                viewname = newviewname.GetProperties().GetString("Value");
                workPart.Views.SaveAs(workPart.ModelingViews.WorkView, viewname, true, false);
                refreshenum();

                //enum0.GetProperties().SetEnumAsString("Value", viewname);//TAG undone
                //enum0.GetProperties().get
                //---------Enter your code here-----------
            }
            else if (block == str)
            {
                //---------Enter your code here-----------
            }
            else if (block == button0)   //这个就是添加按钮,在这里调用
            {
                string[] diction = null; //这个有”添加至CAPP助手“中得到的字符串
                diction = dic.GetProperties().GetStrings("Value");
                if (diction == null)
                {
                    theUI.NXMessageBox.Show("警告", NXMessageBox.DialogType.Error, "添加文字不能为空");
                }
                string strvalue = str.GetProperties().GetEnumAsString("Value");

                thenotefun.Xmlforcapp(strvalue, diction[0]);

                StopProcess("CAPP助手");
                OpenFile(ApplicationPath + folderpath + cappass);
                //switch (strvalue)
                //{
                //    case "加工前准备":

                //        break;
                //    case "工作内容":


                //        break;
                //    case "技术条件":

                //        break;
                //    case "附注":

                //        break;
                //    case "特种工艺术语":

                //        break;
                //    case "检验工序":

                //        break;
                //    case "常用符号":

                //        break;


                //}
                //---------Enter your code here-----------
            }
        }
        catch (Exception ex)
        {
            //---- Enter your exception handling code here -----
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
        }
        return(0);
    }
Esempio n. 14
0
    //------------------------------------------------------------------------------
    //Callback Name: apply_cb
    //------------------------------------------------------------------------------
    public int apply_cb()
    {
        int errorCode = 0;

        NXOpen.Features.BlockFeatureBuilder blockFeatureBuilder1 = null;

        try
        {
            Part workPart = theSession.Parts.Work;

            //Get the values from UI Blocks
            PropertyList blockHeightProps = blockHeight.GetProperties();
            double       theHeight        = blockHeightProps.GetDouble("Value");
            blockHeightProps.Dispose();
            blockHeightProps = null;

            PropertyList blockWidthProps = blockWidth.GetProperties();
            double       theWidth        = blockWidthProps.GetDouble("Value");
            blockWidthProps.Dispose();
            blockWidthProps = null;

            PropertyList blockLengthProps = blockLength.GetProperties();
            double       theLength        = blockLengthProps.GetDouble("Value");
            blockLengthProps.Dispose();
            blockLengthProps = null;

            PropertyList blockOriginProps = blockOrigin.GetProperties();
            Point3d      originPoint      = blockOriginProps.GetPoint("Point");
            blockOriginProps.Dispose();
            blockOriginProps = null;

            PropertyList blockColorProps = blockColor.GetProperties();
            int[]        color           = blockColorProps.GetIntegerVector("Value");
            blockColorProps.Dispose();
            blockColorProps = null;

            //Create the NX block
            NXOpen.Features.Feature nullFeatures_Feature = null;
            blockFeatureBuilder1 = workPart.Features.CreateBlockFeatureBuilder(nullFeatures_Feature);

            blockFeatureBuilder1.SetOriginAndLengths(originPoint, theLength.ToString(), theHeight.ToString(), theWidth.ToString());

            NXOpen.Features.Feature feature1;
            feature1 = blockFeatureBuilder1.CommitFeature();


            // Get the body from Feature
            NXOpen.Features.BodyFeature bodyFeat = (NXOpen.Features.BodyFeature)feature1;
            Body[] bodies = new Body[1];
            bodies = bodyFeat.GetBodies();
            // Apply the color to feature body
            DisplayModification displayModification1 = theSession.DisplayManager.NewDisplayModification();
            displayModification1.ApplyToAllFaces = true;
            displayModification1.NewColor        = color[0];
            DisplayableObject[] objects1 = new DisplayableObject[1];
            objects1[0] = bodies[0];
            displayModification1.Apply(objects1);
            displayModification1.Dispose();
        }
        catch (Exception ex)
        {
            //---- Enter your exception handling code here -----
            errorCode = 1;
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.Message);
        }
        finally
        {
            if (blockFeatureBuilder1 != null)
            {
                blockFeatureBuilder1.Destroy();
                blockFeatureBuilder1 = null;
            }
        }
        return(errorCode);
    }