Пример #1
0
        /// <summary>
        /// 标注公差
        /// </summary>
        /// <param name="dim"></param>
        /// <param name="type">类型</param>
        /// <param name="upTolerance">上公差</param>
        /// <param name="lowerTolerance">下公差</param>
        public static void ToleranceDim(Dimension dim, NXOpen.Annotations.ToleranceType type, double upTolerance, double lowerTolerance)
        {
            Part workPart = Session.GetSession().Parts.Work;

            NXOpen.DisplayableObject[] objects1 = new NXOpen.DisplayableObject[1];
            objects1[0] = dim;
            NXOpen.Annotations.EditSettingsBuilder editSettingsBuilder1;
            editSettingsBuilder1 = workPart.SettingsManager.CreateAnnotationEditSettingsBuilder(objects1);

            NXOpen.Drafting.BaseEditSettingsBuilder[] editsettingsbuilders1 = new NXOpen.Drafting.BaseEditSettingsBuilder[1];
            editsettingsbuilders1[0] = editSettingsBuilder1;
            workPart.SettingsManager.ProcessForMultipleObjectsSettings(editsettingsbuilders1);
            editSettingsBuilder1.AnnotationStyle.DimensionStyle.ToleranceType        = type;
            editSettingsBuilder1.AnnotationStyle.DimensionStyle.UpperToleranceMetric = upTolerance;
            editSettingsBuilder1.AnnotationStyle.DimensionStyle.LowerToleranceMetric = lowerTolerance;

            try
            {
                NXOpen.NXObject nXObject1;
                nXObject1 = editSettingsBuilder1.Commit();
            }
            catch (NXException ex)
            {
                LogMgr.WriteLog("DrawingUtils:ToleranceDim" + ex.Message);
                throw ex;
            }
            finally
            {
                editSettingsBuilder1.Destroy();
            }
        }
Пример #2
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);
    }
Пример #3
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);
    }