Beispiel #1
0
 public MachinedSurface()
 {
     try
     {
         InitializeComponent();
         theSession = Session.GetSession();
         NXOpenUI.FormUtilities.ReparentForm(this);
         NXOpenUI.FormUtilities.SetApplicationIcon(this);
         undomark = theSession.SetUndoMark(Session.MarkVisibility.Visible, "加工面标注");
         //记录并改变View的类型
         Part workpart = theSession.Parts.Work;
         foreach (NXOpen.Drawings.DraftingView draftingview in workpart.DraftingViews)
         {
             NXOpen.Preferences.GeneralExtractedEdgesOption type = NXFun.GetViewEdgesPreference(draftingview);
             map.Add(draftingview, type);
             NXFun.SetViewEdgesPreference(draftingview, NXOpen.Preferences.GeneralExtractedEdgesOption.Associative);
         }
         label1.Text = "- 请选择加工面 (0)";
         //开始监控选定的东东
         this.timer1.Start();
     }
     catch (System.Exception ex)
     {
         UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
     }
 }
Beispiel #2
0
 private void button_add_Click(object sender, EventArgs e)
 {
     try
     {
         //得到选中
         NXObject[] obs;
         NXFun.GetSelectObjects(out obs);
         Part workpart = theSession.Parts.Work;
         workpart.Views.WorkView.Fit();
         foreach (NXOpen.Drawings.DraftingView draftingview in workpart.DraftingViews)
         {
             foreach (NXObject ob in obs)
             {
                 try
                 {
                     //在视图中都尝试改变线型
                     if (NXFun.isFindInView(draftingview, ob))
                     {
                         NXFun.SetViewCurveWidth(draftingview, (NXOpen.DisplayableObject)ob, NXOpen.ViewDependentDisplayManager.Width.Thick);
                     }
                 }
                 catch/*(System.Exception ex)*/
                 {
                 }
             }
         }
         NXFun.RemoveAllSelect();
     }
     catch (Exception ex)
     {
         UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
     }
 }
Beispiel #3
0
        private void button_remove_Click(object sender, EventArgs e)
        {
            //得到选中
            NXObject[] obs;
            NXFun.GetSelectObjects(out obs);
            Part workpart = theSession.Parts.Work;

            workpart.Views.WorkView.Fit();
            foreach (NXOpen.Drawings.DraftingView draftingview in workpart.DraftingViews)
            {
                foreach (NXObject ob in obs)
                {
                    try
                    {
                        //在所有视图中都尝试改变线型
                        if (NXFun.isFindInView(draftingview, ob))
                        {
                            NXFun.SetViewCurveWidth(draftingview, (NXOpen.DisplayableObject)ob, NXOpen.ViewDependentDisplayManager.Width.Normal);
                        }
                    }
                    catch/* (System.Exception ex)*/
                    {
                    }
                }
            }
            NXFun.RemoveAllSelect();
        }
Beispiel #4
0
 //计时器,多线程执行全选宏操作
 private void timer1_Tick(object sender, EventArgs e)
 {
     try
     {
         if (((Timer)sender).Tag.ToString() == "全选")
         {
             timer1.Stop();
             ObjectsInView = NXFun.GetSelectObjects();
             NXFun.RemoveAllSelect();
             timer1.Interval = 1000;
             timer1.Tag      = "取消全选";
             timer1.Start();
         }
         else if (((Timer)sender).Tag.ToString() == "取消全选")
         {
             timer1.Stop();
             //遍历尺寸
             List <NXOpen.Annotations.Dimension> dims = NXFun.GetDimensionInCurrentView(ObjectsInView);
             List <NXOpen.Annotations.BaseFcf>   fcfs = NXFun.GetBaseFcfInCurrentView(ObjectsInView);
             LabelDimMap.Clear();
             foreach (NXOpen.Annotations.Dimension dim in dims)
             {
                 DimInfor diminfor = NXFun.GetDimInfor(dim);
                 //存入Dictionary
                 LabelDimMap.Add(diminfor.id, diminfor);
             }
             LabelFcfMap.Clear();
             foreach (NXOpen.Annotations.BaseFcf fcf in fcfs)
             {
                 DimInfor diminfor = NXFun.GetFcfInfor(fcf);
                 LabelFcfMap.Add(diminfor.id, diminfor);
             }
             //转存到  LabelDimList
             LabelDimList.Clear();
             foreach (int k in LabelDimMap.Keys)
             {
                 foreach (DimInfor diminfor in LabelDimMap[k])
                 {
                     LabelDimList.Add(diminfor);
                 }
             }
             //转存到  LabelFcfList
             LabelFcfList.Clear();
             foreach (int k in LabelFcfMap.Keys)
             {
                 foreach (DimInfor diminfor in LabelFcfMap[k])
                 {
                     LabelFcfList.Add(diminfor);
                 }
             }
             //刷新显示
             RefreshDisplay();
             SetStatusLabel("查询结束!", 2);
         }
     }
     catch (System.Exception ex)
     {
         NXFun.MessageBox(ex.Message);
     }
 }
Beispiel #5
0
        //新建图纸页按钮
        private void tsrbtnAdd_Click(object sender, EventArgs e)
        {
            TreeNode sel = tvwSheet.SelectedNode;

            if (sel == null || (sel.Tag.ToString() != "Gongyi" && sel.Tag.ToString() != "Gongxu"))
            {
                SetStatusLabel("请选中树中工艺或工序节点", 1);
                return;
            }
            int    index    = sel.Index;
            string filename = XML3DPPM.GetModelName(0, index, XmlFile);

            if (string.IsNullOrEmpty(filename))
            {
                SetStatusLabel("选中节点下无模型,请在编辑模型模块中创建模型!", 1);
                return;
            }
            Part prt = NXFun.OpenPrt(ToFullPath(filename));

            if (prt == null)
            {
                SetStatusLabel("打开模型错误!", 1);
                return;
            }
            mainDlg.Enabled = false;    //如果这里不禁用主窗口,再点击一次添加或退出就会出错,而如果直接隐藏主窗口有时会把NX隐藏,奇怪的很。
            // mainDlg.WindowState = FormWindowState.Minimized;
            CreateSheet.MainFun();
            mainDlg.Enabled = true;
            //  mainDlg.WindowState = FormWindowState.Normal;
            SetStatusLabel("添加图纸页返回", 2);
            FreshSheetTree();
        }
Beispiel #6
0
 //查询按钮
 private void tsrbtnSearch_Click(object sender, EventArgs e)
 {
     try
     {
         NXFun.SetHighlight(oldhighlight, false);
         //确认打开图纸页
         NXOpen.Drawings.DrawingSheet ds = NXFun.GetOnShowSheet();
         if (ds == null)
         {
             SetStatusLabel("请打开图纸页!", 1);
             return;
         }
         IsEdit = true;
         S_Sheet sheet = NXFun.GetSheetTemplet(ds);
         OnEidtSheetGuid = sheet.guid;
         NXFun.Fit();
         NXFun.SelectAll();
         timer1.Interval = 1000;
         timer1.Tag      = "全选";
         timer1.Start();
     }
     catch (System.Exception ex)
     {
         NXFun.MessageBox(ex.Message);
     }
 }
Beispiel #7
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);
    }
Beispiel #8
0
    //------------------------------------------------------------------------------
    //Callback Name: ApplyCB
    //------------------------------------------------------------------------------
    public int ApplyCB()
    {
        int errorCode = 0;

        try
        {
            //得到选中的图纸
            int[]          sel = list_box0.GetProperties().GetIntegerVector("SelectedItems");
            string         sheetpath;
            S_SheetTemplet SheetTemplet;
            if (sel.Length == 0)
            {
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Warning, "请选择图纸!");
                return(1);
            }
            else
            {
                string type = enum0.GetProperties().GetEnumAsString("Value");
                if (type == "A3")
                {
                    SheetTemplet = SheetTempletListA3[sel[0]];
                }
                else if (type == "A4")
                {
                    SheetTemplet = SheetTempletListA4[sel[0]];
                }
                else
                {
                    SheetTemplet = SheetTempletListOther[sel[0]];
                }
            }
            sheetpath = NXFun.TDPPMPath + SheetTemplet.filepath;
            //得到名称
            string sheetname = string0.GetProperties().GetString("Value");
            if (NXFun.isFindInList(SheetNames, sheetname))
            {
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Warning, "图纸名称已存在!");
                return(1);
            }
            //创建图纸页
            S_SheetAttr sheetattr;
            sheetattr.GUID      = Guid.NewGuid().ToString();
            sheetattr.ISPRINT   = "是";
            sheetattr.ISCHECKED = "否";
            sheetattr.REMARK    = SheetTemplet.chinese;
            sheetattr.TEMPLET   = SheetTemplet.name;
            NXFun.CreateSheet(sheetname, sheetpath, sheetattr);
        }
        catch (Exception ex)
        {
            errorCode = 1;
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
        }
        return(errorCode);
    }
Beispiel #9
0
 private void button_ok_Click(object sender, EventArgs e)
 {
     //还原视图类型
     //7.5有bug,还原时会出现标注附着混乱,8.0不存在。
     //foreach (KeyValuePair<NXOpen.Drawings.DraftingView, NXOpen.Preferences.GeneralExtractedEdgesOption> a in map)
     //{
     //    NXFun.SetViewEdgesPreference(a.Key, a.Value);
     //}
     NXFun.RemoveAllSelect();
     this.Close();
 }
Beispiel #10
0
 //取消按钮
 private void tsrbtnCancel_Click(object sender, EventArgs e)
 {
     IsEdit = false;
     NXFun.SetHighlight(oldhighlight, false);
     //初始化
     LabelDimMap.Clear();
     LabelFcfMap.Clear();
     LabelDimList.Clear();
     LabelFcfList.Clear();
     RefreshDisplay();
     SetStatusLabel("已取消操作!", 0);
 }
Beispiel #11
0
 //形位起始编号改变
 private void tsrtxtXingwei_TextChanged(object sender, EventArgs e)
 {
     try
     {
         int i = System.Convert.ToInt32(tsrtxtXingwei.Text);
         FcfStartNum = i;
         RefreshDisplay();
     }
     catch (System.Exception ex)
     {
         NXFun.MessageBox(ex.Message);
     }
 }
Beispiel #12
0
        //帮助按钮
        private void tsrbtnHelp_Click(object sender, EventArgs e)
        {
            string help =
                "注意事项:\n" +
                "1、支持继承的三维PMI标注;\n" +
                "2、编号必须在1~999之间;\n" +
                "3、如遇警告“试图使用不活动的对象”,请点击查询按钮重新查询;\n" +
                "4、投影视图如果不是1:1,可能标号尺寸会大小不一,NX手工操作亦然,此问题待解决。\n" +
                "------------------\n" +
                "打标号工具 V1.0";

            NXFun.MessageBox(help, "帮助", 1);
        }
Beispiel #13
0
        //刷新dgv
        private void RefreshDisplay()
        {
            try
            {
                tsrbtnSearch.Visible = !IsEdit;
                tsrbtnOk.Visible     = IsEdit;
                tsrbtnCancel.Visible = IsEdit;

                bieluandong = true;
                dgvChicun.Rows.Clear();
                for (int i = 0; i < LabelDimList.Count; i++)
                {
                    string title = "";
                    if (LabelDimList[i].isLabel == "是")
                    {
                        title = (i + DimStartNum).ToString();
                        DimInfor temp = LabelDimList[i];
                        temp.id         = i + DimStartNum;
                        LabelDimList[i] = temp;
                    }
                    dgvChicun.Rows.Add(title);
                    dgvChicun[1, i].Value = LabelDimList[i].text;
                    dgvChicun[2, i].Value = LabelDimList[i].value;
                    dgvChicun[3, i].Value = LabelDimList[i].up;
                    dgvChicun[4, i].Value = LabelDimList[i].low;
                    dgvChicun[5, i].Value = NXFun.string2bool(LabelDimList[i].isLabel);
                    DataGridViewCheckBoxCell a = (DataGridViewCheckBoxCell)dgvChicun[5, i];
                }
                dgvXingwei.Rows.Clear();
                for (int i = 0; i < LabelFcfList.Count; i++)
                {
                    string title = "";
                    if (LabelFcfList[i].isLabel == "是")
                    {
                        title = "J" + (i + FcfStartNum).ToString();
                        DimInfor temp = LabelFcfList[i];
                        temp.id         = i + FcfStartNum;
                        LabelFcfList[i] = temp;
                    }
                    dgvXingwei.Rows.Add(title);
                    dgvXingwei[1, i].Value = LabelFcfList[i].text;
                    dgvXingwei[2, i].Value = LabelFcfList[i].value;
                    dgvXingwei[3, i].Value = NXFun.string2bool(LabelFcfList[i].isLabel);
                }
                bieluandong = false;
            }
            catch (System.Exception ex)
            {
                NXFun.MessageBox(ex.Message);
            }
        }
Beispiel #14
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                //监控状态指示的小东东,嘻嘻
                count = (++count) % 3;
                string star = "\\";
                switch (count)
                {
                case 0: star = "-";
                    break;

                case 1: star = "\\";
                    break;

                case 2: star = "/";
                    break;
                }
                //得到选中的东东
                NXObject[] nxobs;
                int        num = NXFun.GetSelectObjects(out nxobs);
                label1.Text = star + " 请选择加工面 (" + System.Convert.ToString(num) + ")";
                string[] obs = new string[num];
                for (int i = 0; i < num; i++)
                {
                    if (isShowFullType)
                    {
                        obs[i] = nxobs[i].GetType().FullName;
                    }
                    else
                    {
                        obs[i] = nxobs[i].ToString();
                    }
                }
                //检测有无改变
                if (!NXFun.isArrayEqual(ob_list, obs))
                {
                    listBox1.Items.Clear();
                    foreach (string str in obs)
                    {
                        listBox1.Items.Add(str);
                    }
                }
                ob_list = obs;
            }
            catch (System.Exception ex)
            {
                UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
            }
        }
Beispiel #15
0
        //------------------------------------------------------------------------------
        //  Explicit Activation
        //      This entry point is used to activate the application explicitly
        //------------------------------------------------------------------------------
        public static int Main(string[] args)
        {
            int retValue = 0;

            try
            {
                theProgram = new Program();

                //TODO: Add your application code here
                if (args[0] == "3DPPM_RevolveTrim")
                {
                    NXFun.ShowHuizhuan();
                }
                else if (args[0] == "3DPPM_AddTolerance")
                {
                    NXFun.ShowGongcha();
                }
                else if (args[0] == "3DPPM_MachinedSurface")
                {
                    NXFun.ShowJiagongmian();
                }
                else if (args[0] == "3DPPM_CAPPAssistant")
                {
                    //                 CAPPAssistant assistant = new CAPPAssistant();
                    //                 assistant.Show();
                    NXFun.ShowCAPP();
                }
                else if (args[0] == "3DPPM_Help")
                {
                    NXFun.ShowHelp();
                }
                else if (args[0] == "3DPPM_3DPPM")
                {
                    MainDlg md = new MainDlg();
                    md.Show();
                }
                else if (args[0] == "3DPPM_About")
                {
                    NXFun.ShowAbout();
                }
                theProgram.Dispose();
            }
            catch (NXOpen.NXException ex)
            {
                // ---- Enter your exception handling code here -----
                UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
            }
            return(retValue);
        }
Beispiel #16
0
 private void button_read_Click(object sender, EventArgs e)
 {
     NXObject[] nxobs = NXFun.GetSelectObjects();
     if (nxobs.Length == 0)
     {
         MessageBox.Show("没有在NX选中东东哦!");
     }
     else   //查询
     {
         AttrList.Clear();
         if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
         {
             //得到sheet 做二维图表需要设置隐藏属性
             NXOpen.Drawings.DrawingSheet[] ds = theSession.Parts.Work.DrawingSheets.ToArray();
             if (ds.Length != 0)
             {
                 obj = ds[0];
             }
             else
             {
                 obj = nxobs[0];
             }
         }
         else
         {
             obj = nxobs[0];
         }
         s_Attr s_attr;
         NXObject.AttributeInformation[] ais = obj.GetAttributeTitlesByType(NXObject.AttributeType.String);
         for (int i = 0; i < ais.Length; i++)
         {
             s_attr.title   = ais[i].Title;
             s_attr.s_value = obj.GetStringAttribute(s_attr.title);
             s_attr.type    = "string";
             s_attr.i_value = 0;
             AttrList.Add(s_attr);
         }
         ais = obj.GetAttributeTitlesByType(NXObject.AttributeType.Integer);
         for (int i = 0; i < ais.Length; i++)
         {
             s_attr.title   = ais[i].Title;
             s_attr.i_value = obj.GetIntegerAttribute(s_attr.title);
             s_attr.type    = "int";
             s_attr.s_value = "";
             AttrList.Add(s_attr);
         }
         RefreshDisplay();
     }
 }
Beispiel #17
0
 //形位选择发生改变
 private void dgvXingwei_SelectionChanged(object sender, EventArgs e)
 {
     if (dgvXingwei.SelectedRows.Count == 0)
     {
         NXFun.SetHighlight(oldhighlight, false);
     }
     else
     {
         dgvChicun.ClearSelection();
         NXFun.SetHighlight(oldhighlight, false);
         int index = dgvXingwei.SelectedRows[0].Index;
         NXFun.SetHighlight(LabelFcfList[index].dim, true);
         oldhighlight = LabelFcfList[index].dim;
     }
 }
Beispiel #18
0
 //双击打开模型
 private void tvwSheet_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         System.Drawing.Point clickPoint = new System.Drawing.Point(e.X, e.Y);
         TreeNode             sel        = tvwSheet.GetNodeAt(clickPoint);
         //判断点击的是否是一个节点
         if (sel != null && sel.Tag.ToString() == "Sheet")
         {
             string prtfullpath = ToFullPath(XML3DPPM.GetModelName(0, sel.Parent.Index, XmlFile));
             string guid        = sel.Name;
             NXFun.OpenPrt(prtfullpath);
             NXFun.ShowSheetByGuid(prtfullpath, guid);
             SetStatusLabel("已显示图纸页", 2);
         }
     }
 }
Beispiel #19
0
        //打开图纸页按钮
        private void tsrbtnOpen_Click(object sender, EventArgs e)
        {
            TreeNode sel = tvwSheet.SelectedNode;

            if (sel == null || sel.Tag.ToString() != "Sheet")
            {
                SetStatusLabel("请选中树中图纸节点", 1);
                return;
            }
            string prtfullpath = ToFullPath(XML3DPPM.GetModelName(0, sel.Parent.Index, XmlFile));
            string guid        = sel.Name;

            NXFun.OpenPrt(prtfullpath);
            NXFun.ShowSheetByGuid(prtfullpath, guid);
            SetStatusLabel("已显示图纸页", 2);
            //FreshSheetTree();
        }
Beispiel #20
0
        //新建工艺
        private void CreateNewProject()
        {
            int flag = 0;

            //选择保存路径;
            saveFileDialog.AddExtension    = true;
            saveFileDialog.Title           = "请选择要保存的工艺所在路径";
            saveFileDialog.DefaultExt      = "3dppm";
            saveFileDialog.Filter          = "三维机加工艺文件(*.3dppm)|*.3dppm";
            saveFileDialog.OverwritePrompt = true;
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                string filename = saveFileDialog.FileName;
                if (NXFun.IsChina(filename))
                {
                    MessageBox.Show("NX不支持中文路径,请重新选择保存路径");
                    flag = 1;
                }
                else
                {
                    //得到工艺路径和文件名;
                    ProPath = Path.GetDirectoryName(filename);
                    ProName = Path.GetFileNameWithoutExtension(filename);
                    XmlFile = ToFullPath(NXFun.ProcessXML);
                    //删除并创建文件夹;
                    bool result = NXFun.DeleteDirectory(ToFullPath(""));
                    if (!result)
                    {
                        MessageBox.Show("文件夹" + ToFullPath("") + "无法删除,请手动关闭可能已打开的文件并删除该目录。");
                        return;
                    }
                    Directory.CreateDirectory(ToFullPath(""));
                    //复制工艺模板;
                    File.Copy(NXFun.TDPPMPath + NXFun.ProcessXML, XmlFile, true);
                    OpenOrCreateProjectInit();
                    SetStatusLabel("工艺新建成功!", 2);
                }
            }
            if (flag == 1)
            {
                //包含中文,重新选择文件;
                CreateNewProject();
            }
        }
Beispiel #21
0
 //读取控件的值
 /// <summary>
 /// 读取控件的值   (0,0)表示工艺   (N,0)表示第N个工序 (N,M)表示第N个工序的第M个工步
 /// </summary>
 /// <param name="a">第几个工序</param>
 /// <param name="b">第几个工步</param>
 private void InitializeInputBox(int a, int b)
 {
     if (a == 0 && b == 0)
     {
         //读取并刷新工艺面板
         foreach (Control control in tlpGongyiNormal.Controls)
         {
             if (control is TextBox)
             {
                 ((TextBox)control).Text = XML3DPPM.GetIndexAttr(a, b, control.Name, XmlFile);
             }
         }
     }
     else if (a > 0 && b == 0)
     {
         //读取并刷新工序面板
         foreach (Control control in tlpGongxuNormal.Controls)
         {
             if (control is TextBox)
             {
                 ((TextBox)control).Text = XML3DPPM.GetIndexAttr(a, b, control.Name, XmlFile);
             }
             else if (control is CheckBox)
             {
                 bool check = NXFun.string2bool(XML3DPPM.GetIndexAttr(a, b, control.Name, XmlFile));
                 ((CheckBox)control).CheckState = check?CheckState.Checked:CheckState.Unchecked;
             }
         }
     }
     else if (a > 0 && b > 0)
     {
         //读取并刷新工步面板
         foreach (Control control in tlpGongbu.Controls)
         {
             if (control is TextBox)
             {
                 ((TextBox)control).Text = XML3DPPM.GetIndexAttr(a, b, control.Name, XmlFile);
             }
         }
         //读取并刷新子工步面板
         UpdateZigongbu(a, b, true);
     }
 }
Beispiel #22
0
        //应用按钮
        private void tsrbtnOk_Click(object sender, EventArgs e)
        {
            string guid = NXFun.GetOnShowSheetGuid();

            if (string.IsNullOrEmpty(guid) || guid != OnEidtSheetGuid)
            {
                SetStatusLabel("当前信息与当前图纸不对应,请点击取消后重新查询尺寸标注,或者切换到之前的图纸!", 1);
                return;
            }
            Apply();
            IsEdit = false;
            //初始化
            LabelDimMap.Clear();
            LabelFcfMap.Clear();
            LabelDimList.Clear();
            LabelFcfList.Clear();
            RefreshDisplay();
            SetStatusLabel("标号编辑成功!", 2);
        }
Beispiel #23
0
        //恢复工艺
        private void RecoverProject()
        {
            folderBrowserDialog.Description         = "请选择要打开的工艺临时文件夹:";
            folderBrowserDialog.ShowNewFolderButton = false;
            DialogResult result = folderBrowserDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                string path = folderBrowserDialog.SelectedPath;
                //判断合法性
                string root     = Path.GetPathRoot(path);
                string pathname = Path.GetDirectoryName(path);
                string filename = Path.GetFileName(path);
                if (path.Equals(root) && string.IsNullOrEmpty(pathname) && string.IsNullOrEmpty(filename))
                {
                    MessageBox.Show("请不要选择根目录!");
                    return;
                }
                else if (NXFun.IsChina(path))
                {
                    MessageBox.Show("NX不支持中文路径,请修改路径!");
                    return;
                }
                else if (!NXFun.isFileExist(path + "\\" + NXFun.ProcessXML))
                {
                    MessageBox.Show("所选路径非工艺临时数据包");
                    return;
                }
                else
                {
                    ProPath = pathname;
                    ProName = filename;
                    XmlFile = ToFullPath(NXFun.ProcessXML);
                    XML3DPPM.Update3dppm(XmlFile, TemplateXML);
                    OpenOrCreateProjectInit();
                }
            }
        }
Beispiel #24
0
 private void button_cancel_Click(object sender, EventArgs e)
 {
     try
     {
         theSession.UndoToMark(undomark, "加工面标注");
         theSession.DeleteUndoMark(undomark, "加工面标注");
         //还原视图类型
         //7.5有bug,还原时会出现标注附着混乱,8.0不存在。
         //                 foreach (KeyValuePair<NXOpen.Drawings.DraftingView, NXOpen.Preferences.GeneralExtractedEdgesOption> a in map)
         //                 {
         //                     NXFun.SetViewEdgesPreference(a.Key, a.Value);
         //                 }
         NXFun.RemoveAllSelect();
     }
     catch (System.Exception ex)
     {
         UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
     }
     finally
     {
         this.Close();
     }
 }
Beispiel #25
0
        //关闭工艺
        private bool CloseProject(bool isSave)
        {
            bool           result    = false;
            List <S_Model> ModelList = XML3DPPM.GetModelList(XmlFile);

            //关闭所有并保存压缩
            foreach (S_Model model in ModelList)
            {
                if (!String.IsNullOrEmpty(model.filename))
                {
                    NXFun.ClosePrt(ToFullPath(model.filename), isSave);
                }
            }
            if (isSave)
            {
                //压缩
                string tempZip = ProPath + "\\" + ProName + ".tmp";
                bool   isSaved = Compress.RAR(NXFun.TDPPMPath + NXFun.RarEXE, tempZip, ProPath + "\\" + ProName);
                if (isSaved)
                {
                    File.Copy(tempZip, ProPath + "\\" + ProName + ".3dppm", true);
                    File.Delete(tempZip);
                    NXFun.DeleteDirectory(ProPath + "\\" + ProName);
                    SetStatusLabel("保存工艺成功!", 2);
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            else
            {
                result = true;
            }
            return(result);
        }
Beispiel #26
0
        //打开或新建工艺时初始化
        private void OpenOrCreateProjectInit()
        {
            //变量值
            IsProjectOpen = true;

            //控件状态
            pnlWelcome.Hide();
            pnlMain.Show();

            this.Text = ProPath + "\\" + ProName + ".3dppm";
            //更新会签
            if (NXFun.isFileExist(ToFullPath(NXFun.SignOffXML)))
            {
                bool result = XML3DPPM.UpdateSignOff(XmlFile, ToFullPath(NXFun.SignOffXML));
                if (result)
                {
                    NXFun.MessageBox("更新会签信息成功,请在\"编辑图纸->二维图表\"模块点击\"更新表头\"来刷新会签信息。");
                }
                else
                {
                    NXFun.MessageBox("更新会签信息失败,请确认会签文件是否有效!");
                }
            }
            //操作
            ProcessEdit.ProPath = ProPath;
            ProcessEdit.ProName = ProName;
            ProcessEdit.Init();

            ModelEdit.ProPath = ProPath;
            ModelEdit.ProName = ProName;
            ModelEdit.Init();

            SheetEdit.ProPath = ProPath;
            SheetEdit.ProName = ProName;
            SheetEdit.Init();
        }
Beispiel #27
0
        //删除图纸页按钮
        private void tsrbtnDel_Click(object sender, EventArgs e)
        {
            TreeNode sel = tvwSheet.SelectedNode;

            if (sel == null || sel.Tag.ToString() != "Sheet")
            {
                SetStatusLabel("请选中树中图纸节点", 1);
                return;
            }
            DialogResult dialogResult = MessageBox.Show("是否删除选中图纸?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult != DialogResult.Yes)
            {
                return;
            }
            string prtfullpath = ToFullPath(XML3DPPM.GetModelName(0, sel.Parent.Index, XmlFile));
            string guid        = sel.Name;

            NXFun.OpenPrt(prtfullpath);
            NXOpen.Drawings.DrawingSheet ds = NXFun.GetSheetByGuid(prtfullpath, guid);
            NXFun.DeleteObject(ds);
            SetStatusLabel("已删除图纸页", 2);
            FreshSheetTree();
        }
Beispiel #28
0
 //形位打标checkbox
 private void dgvXingwei_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     if (bieluandong)
     {
         return;
     }
     if (e.ColumnIndex == 3)  //标号
     {
         int sel = e.RowIndex;
         //修改这项并移动
         if ((bool)dgvXingwei[e.ColumnIndex, e.RowIndex].Value)
         {
             DimInfor temp = LabelFcfList[sel];
             if (temp.isLabel == "是")
             {
                 //本来就是 是  一般不会出现这种情况
             }
             else
             {
                 for (int i = sel; i >= 0; i--)
                 {
                     //移动到最末一个是的后面
                     if (LabelFcfList[i].isLabel == "是")
                     {
                         DimInfor temp1 = LabelFcfList[i + 1];
                         NXFun.Swap <DimInfor>(ref temp1, ref temp);
                         temp1.isLabel       = "是";
                         LabelFcfList[sel]   = temp;
                         LabelFcfList[i + 1] = temp1;
                         RefreshDisplay();
                         //恢复选中
                         dgvXingwei.Rows[i + 1].Selected = true;
                         break;
                     }
                     //没有 是 移动到顶
                     else if (i == 0 && LabelFcfList[i].isLabel == "否")
                     {
                         DimInfor temp1 = LabelFcfList[0];
                         NXFun.Swap <DimInfor>(ref temp1, ref temp);
                         temp1.isLabel     = "是";
                         LabelFcfList[sel] = temp;
                         LabelFcfList[0]   = temp1;
                         RefreshDisplay();
                         //恢复选中
                         dgvXingwei.Rows[0].Selected = true;
                         break;
                     }
                 }
             }
         }
         else
         {
             DimInfor temp = LabelFcfList[sel];
             if (temp.isLabel == "否")
             {
                 //本来就是 否  一般不会出现这种情况
             }
             else
             {
                 temp.isLabel = "否";
                 LabelFcfList.RemoveAt(sel);
                 LabelFcfList.Add(temp);
                 //移动到末
                 RefreshDisplay();
                 //恢复选中
                 dgvXingwei.Rows[LabelFcfList.Count - 1].Selected = true;
             }
         }
     }
 }
Beispiel #29
0
 //应用回调
 private void Apply()
 {
     try
     {
         NXFun.SetHighlight(oldhighlight, false);
         Session.UndoMarkId undomark = Program.theSession.SetUndoMark(Session.MarkVisibility.Visible, "打标号");
         foreach (DimInfor listitem in LabelDimList)
         {
             if (listitem.isLabel == "是")
             {
                 if (listitem.is_herited)  //PMIdimention
                 {
                     NXOpen.Annotations.BalloonNote balloon = NXFun.FindObjectByAttr <NXOpen.Annotations.BalloonNote>("GUID", listitem.guid);
                     if (balloon == null)
                     {
                         //没找到 添加
                         NXFun.SetDisplayState(1);
                         NXOpen.Annotations.BalloonNote balloonnote = NXFun.AddBalloonNote((NXOpen.Annotations.Annotation)listitem.dim, listitem.id.ToString(), listitem);
                         NXFun.SetDisplayState(2);
                         //找到二维继承的BalloonNote并设置大小。
                         NXOpen.Annotations.PmiAttribute[] bns = Session.GetSession().Parts.Work.PmiManager.PmiAttributes.ToArray();
                         foreach (NXOpen.Annotations.PmiAttribute pmi in bns)
                         {
                             NXOpen.Annotations.Lettering Lettering = balloonnote.GetLetteringPreferences().GetDimensionText();
                             if (NXFun.GetInheritParent(pmi).Equals(balloonnote) && !pmi.Equals(balloonnote))
                             {
                                 NXFun.EditBalloonNoteSize((NXOpen.Annotations.BalloonNote)pmi, Lettering);
                             }
                         }
                     }
                     else
                     {
                         //找到 改写
                         NXFun.EditBalloonNote(balloon, listitem.id.ToString(), listitem);
                     }
                     NXFun.SetStringAttr((NXObject)listitem.dimParent, "DISP", listitem.isLabel);
                     NXFun.SetIntegerAttr((NXObject)listitem.dimParent, "ID", listitem.id);
                 }
                 else               //普通dimention
                 {
                     //找到IdSymbol 并改写 否则添加
                     NXOpen.Annotations.IdSymbol idsymbol = NXFun.FindObjectByAttr <NXOpen.Annotations.IdSymbol>("GUID", listitem.guid);
                     if (idsymbol == null)
                     {
                         //没找到 添加
                         NXFun.AddIdSymbol((NXOpen.Annotations.Annotation)listitem.dim, listitem.id.ToString(), listitem);
                     }
                     else
                     {
                         //找到 改写
                         NXFun.EditIdSymbol(idsymbol, listitem.id.ToString(), listitem);
                     }
                     NXFun.SetStringAttr((NXObject)listitem.dimParent, "DISP", listitem.isLabel);
                     NXFun.SetIntegerAttr((NXObject)listitem.dimParent, "ID", listitem.id);
                 }
             }
             else if (listitem.isLabel == "否")
             {
                 if (listitem.is_herited)  //PMIdimention
                 {
                     NXOpen.Annotations.BalloonNote balloon = NXFun.FindObjectByAttr <NXOpen.Annotations.BalloonNote>("GUID", listitem.guid);
                     if (balloon != null)
                     {
                         NXFun.DeleteBalloonNoteByAttr("GUID", listitem.guid);
                     }
                     NXFun.SetStringAttr((NXObject)listitem.dimParent, "DISP", listitem.isLabel);
                     NXFun.SetIntegerAttr((NXObject)listitem.dimParent, "ID", listitem.id);
                 }
                 else               //普通dimention
                 {
                     //找到IdSymbol 并改写 否则添加
                     NXOpen.Annotations.IdSymbol idsymbol = NXFun.FindObjectByAttr <NXOpen.Annotations.IdSymbol>("GUID", listitem.guid);
                     if (idsymbol != null)
                     {
                         NXFun.DeleteIdSymbolByAttr("GUID", listitem.guid);
                     }
                     NXFun.SetStringAttr((NXObject)listitem.dimParent, "DISP", listitem.isLabel);
                     NXFun.SetIntegerAttr((NXObject)listitem.dimParent, "ID", listitem.id);
                 }
             }
         }
         foreach (DimInfor listitem in LabelFcfList)
         {
             string num = "J<C0.5>" + listitem.id.ToString() + "<C>";
             if (listitem.isLabel == "是")
             {
                 if (listitem.is_herited)  //Fcf
                 {
                     NXOpen.Annotations.BalloonNote balloon = NXFun.FindObjectByAttr <NXOpen.Annotations.BalloonNote>("GUID", listitem.guid);
                     if (balloon == null)
                     {
                         //没找到 添加
                         NXFun.SetDisplayState(1);
                         NXOpen.Annotations.BalloonNote balloonnote = NXFun.AddBalloonNote((NXOpen.Annotations.Annotation)listitem.dim, num, listitem);
                         NXFun.SetDisplayState(2);
                         //找到二维继承的BalloonNote并设置大小。
                         NXOpen.Annotations.PmiAttribute[] bns = Session.GetSession().Parts.Work.PmiManager.PmiAttributes.ToArray();
                         foreach (NXOpen.Annotations.PmiAttribute pmi in bns)
                         {
                             NXOpen.Annotations.Lettering Lettering = balloonnote.GetLetteringPreferences().GetDimensionText();
                             if (NXFun.GetInheritParent(pmi).Equals(balloonnote) && !pmi.Equals(balloonnote))
                             {
                                 NXFun.EditBalloonNoteSize((NXOpen.Annotations.BalloonNote)pmi, Lettering);
                             }
                         }
                     }
                     else
                     {
                         //找到 改写
                         NXFun.EditBalloonNote(balloon, num, listitem);
                     }
                     NXFun.SetStringAttr((NXObject)listitem.dimParent, "DISP", listitem.isLabel);
                     NXFun.SetIntegerAttr((NXObject)listitem.dimParent, "ID", listitem.id);
                 }
                 else               //普通DraftingFcf
                 {
                     //找到IdSymbol 并改写 否则添加
                     NXOpen.Annotations.IdSymbol idsymbol = NXFun.FindObjectByAttr <NXOpen.Annotations.IdSymbol>("GUID", listitem.guid);
                     if (idsymbol == null)
                     {
                         //没找到 添加
                         NXFun.AddIdSymbol((NXOpen.Annotations.Annotation)listitem.dim, num, listitem);
                     }
                     else
                     {
                         //找到 改写
                         NXFun.EditIdSymbol(idsymbol, num, listitem);
                     }
                     NXFun.SetStringAttr((NXObject)listitem.dimParent, "DISP", listitem.isLabel);
                     NXFun.SetIntegerAttr((NXObject)listitem.dimParent, "ID", listitem.id);
                 }
             }
             else if (listitem.isLabel == "否")
             {
                 if (listitem.is_herited)  //Fcf
                 {
                     NXOpen.Annotations.BalloonNote balloon = NXFun.FindObjectByAttr <NXOpen.Annotations.BalloonNote>("GUID", listitem.guid);
                     if (balloon != null)
                     {
                         NXFun.DeleteBalloonNoteByAttr("GUID", listitem.guid);
                     }
                     NXFun.SetStringAttr((NXObject)listitem.dimParent, "DISP", listitem.isLabel);
                     NXFun.SetIntegerAttr((NXObject)listitem.dimParent, "ID", listitem.id);
                 }
                 else               //DraftingFcf
                 {
                     //找到IdSymbol 并改写 否则添加
                     NXOpen.Annotations.IdSymbol idsymbol = NXFun.FindObjectByAttr <NXOpen.Annotations.IdSymbol>("GUID", listitem.guid);
                     if (idsymbol != null)
                     {
                         NXFun.DeleteIdSymbolByAttr("GUID", listitem.guid);
                     }
                     NXFun.SetStringAttr((NXObject)listitem.dimParent, "DISP", listitem.isLabel);
                     NXFun.SetIntegerAttr((NXObject)listitem.dimParent, "ID", listitem.id);
                 }
             }
         }
         Program.theSession.UpdateManager.DoUpdate(undomark);
     }
     catch (System.Exception ex)
     {
         UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
     }
 }
Beispiel #30
0
        //刷新图纸树
        public void FreshSheetTree()
        {
            tvwSheet.Nodes.Clear();
            tvwSheet.ImageIndex         = 3;
            tvwSheet.SelectedImageIndex = 3;
            //第一个为工艺节点
            TreeNode gyTreeNode = new TreeNode();
            string   filename   = XML3DPPM.GetModelName(0, 0, XmlFile);

            gyTreeNode.Text =
                XML3DPPM.GetIndexAttr(0, 0, "gongyi_jianming", XmlFile) +
                " (" +
                filename +
                ")";
            gyTreeNode.Tag = "Gongyi";
            bool IsNull = string.IsNullOrEmpty(filename);

            gyTreeNode.ImageIndex         = IsNull?1:0;
            gyTreeNode.SelectedImageIndex = IsNull ? 1 : 0;
            tvwSheet.Nodes.Add(gyTreeNode);
            if (!string.IsNullOrEmpty(filename))
            {
                List <S_Sheet> SheetTempletList = NXFun.GetSheetTempletList(ToFullPath(filename));
                foreach (S_Sheet sheet in SheetTempletList)
                {
                    TreeNode sheetTreeNode = new TreeNode();
                    sheetTreeNode.Text               = sheet.SheetName + "_" + sheet.Remark;
                    sheetTreeNode.Tag                = "Sheet";
                    sheetTreeNode.Name               = sheet.guid; //利用guid标识图纸
                    sheetTreeNode.ImageIndex         = 2;
                    sheetTreeNode.SelectedImageIndex = 2;
                    gyTreeNode.Nodes.Add(sheetTreeNode);
                }
            }
            //之后为工序节点
            int gxNum = XML3DPPM.GetGongxuCount(XmlFile);

            for (int i = 0; i < gxNum; i++)
            {
                TreeNode gxTreeNode = new TreeNode();
                filename        = XML3DPPM.GetModelName(0, i + 1, XmlFile);
                gxTreeNode.Text =
                    XML3DPPM.GetIndexAttr(i + 1, 0, "gongxu_gongxuhao", XmlFile) +
                    "_" +
                    XML3DPPM.GetIndexAttr(i + 1, 0, "gongxu_gongxumingcheng", XmlFile) +
                    " (" +
                    filename +
                    ")";
                gxTreeNode.Tag                = "Gongxu";
                IsNull                        = string.IsNullOrEmpty(filename);
                gxTreeNode.ImageIndex         = IsNull ? 1 : 0;
                gxTreeNode.SelectedImageIndex = IsNull ? 1 : 0;
                tvwSheet.Nodes.Add(gxTreeNode);
                if (!string.IsNullOrEmpty(filename))
                {
                    List <S_Sheet> SheetTempletList = NXFun.GetSheetTempletList(ToFullPath(filename));
                    foreach (S_Sheet sheet in SheetTempletList)
                    {
                        TreeNode sheetTreeNode = new TreeNode();
                        sheetTreeNode.Text               = sheet.SheetName + "_" + sheet.Remark;
                        sheetTreeNode.Tag                = "Sheet";
                        sheetTreeNode.Name               = sheet.guid; //利用guid标识图纸
                        sheetTreeNode.ImageIndex         = 2;
                        sheetTreeNode.SelectedImageIndex = 2;
                        gxTreeNode.Nodes.Add(sheetTreeNode);
                    }
                }
            }
            tvwSheet.ExpandAll();
            CharEdit.RefreshSheet();
        }