Beispiel #1
0
        private void Ins_OK_Click(object sender, EventArgs e)
        {
            try
            {
                status = DataChecked();
                if (!status)
                {
                    MessageBox.Show("Data檢查失敗");
                    return;
                }

                string AssignExcelType = "";

                if (FAIcheckBox.Checked == true)
                {
                    AssignExcelType = FAIcheckBox.Text;
                }

                if (IQCcheckBox.Checked == true)
                {
                    AssignExcelType = IQCcheckBox.Text;
                }

                if (IPQCcheckBox.Checked == true)
                {
                    AssignExcelType = IPQCcheckBox.Text;
                }

                if (FQCcheckBox.Checked == true)
                {
                    AssignExcelType = FQCcheckBox.Text;
                }



                foreach (KeyValuePair <NXObject, string> kvp in DicSelDimension)
                {
                    //取得原始顏色
                    int oldColor = CaxME.GetDimensionColor(kvp.Key);
                    if (oldColor == -1)
                    {
                        oldColor = 125;
                    }
                    //取得檢具顏色
                    AssignGaugeDlg.GaugeData cGaugeData = new AssignGaugeDlg.GaugeData();
                    if (SelfCheckGauge.Text != "")
                    {
                        status = DicGaugeData.TryGetValue(SelfCheckGauge.Text, out cGaugeData);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("此檢具資料可能有誤");
                            return;
                        }
                    }
                    if (Gauge.Text != "")
                    {
                        status = DicGaugeData.TryGetValue(Gauge.Text, out cGaugeData);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("此檢具資料可能有誤");
                            return;
                        }
                    }

                    //改變標註尺寸顏色
                    CaxME.SetDimensionColor(kvp.Key, Convert.ToInt32(cGaugeData.Color));
                    //塞屬性
                    kvp.Key.SetAttribute(CaxME.DimenAttr.OldColor, oldColor.ToString());//舊顏色
                    kvp.Key.SetAttribute(CaxME.DimenAttr.AssignExcelType, AssignExcelType);
                    if (Gauge.Text != "")
                    {
                        kvp.Key.SetAttribute(CaxME.DimenAttr.Gauge, Gauge.Text);//檢具名稱
                    }
                    if (Freq_0.Text != "" & Freq_1.Text != "" & Freq_Units.Text != "")
                    {
                        kvp.Key.SetAttribute(CaxME.DimenAttr.Frequency, Freq_0.Text + "PC/" + Freq_1.Text + Freq_Units.Text);//頻率
                    }
                    if (SelfCheckGauge.Text != "")
                    {
                        kvp.Key.SetAttribute("SelfCheckExcel", "SelfCheck");
                        kvp.Key.SetAttribute(CaxME.DimenAttr.SelfCheck_Gauge, SelfCheckGauge.Text);                                               //檢具名稱
                        kvp.Key.SetAttribute(CaxME.DimenAttr.SelfCheck_Freq, SelfCheck_0.Text + "PC/" + SelfCheck_1.Text + SelfCheck_Units.Text); //SelfCheck
                    }
                }
                //對零件塞上excelType屬性,說明此次尺寸是出哪一張excel(此屬性是給MEUpload時插入資料庫所使用)
                string excelType = "";
                if (FAIcheckBox.Checked == true)
                {
                    try
                    {
                        excelType = workPart.GetStringAttribute("ExcelType");
                    }
                    catch (System.Exception ex)
                    {
                        excelType = "";
                    }
                    if (excelType != "" && !excelType.Contains("FAI"))
                    {
                        excelType = excelType + "," + "FAI";
                        workPart.SetAttribute("ExcelType", excelType);
                    }
                    if (excelType == "")
                    {
                        workPart.SetAttribute("ExcelType", "FAI");
                    }
                }
                if (IQCcheckBox.Checked == true)
                {
                    try
                    {
                        excelType = workPart.GetStringAttribute("ExcelType");
                    }
                    catch (System.Exception ex)
                    {
                        excelType = "";
                    }
                    if (excelType != "" && !excelType.Contains("IQC"))
                    {
                        excelType = excelType + "," + "IQC";
                        workPart.SetAttribute("ExcelType", excelType);
                    }
                    if (excelType == "")
                    {
                        workPart.SetAttribute("ExcelType", "IQC");
                    }
                }
                if (IPQCcheckBox.Checked == true)
                {
                    try
                    {
                        excelType = workPart.GetStringAttribute("ExcelType");
                    }
                    catch (System.Exception ex)
                    {
                        excelType = "";
                    }
                    if (excelType != "" && !excelType.Contains("IPQC"))
                    {
                        excelType = excelType + "," + "IPQC";
                        workPart.SetAttribute("ExcelType", excelType);
                    }
                    if (excelType == "")
                    {
                        workPart.SetAttribute("ExcelType", "IPQC");
                    }
                }
                if (FQCcheckBox.Checked == true)
                {
                    try
                    {
                        excelType = workPart.GetStringAttribute("ExcelType");
                    }
                    catch (System.Exception ex)
                    {
                        excelType = "";
                    }
                    if (excelType != "" && !excelType.Contains("FQC"))
                    {
                        excelType = excelType + "," + "FQC";
                        workPart.SetAttribute("ExcelType", excelType);
                    }
                    if (excelType == "")
                    {
                        workPart.SetAttribute("ExcelType", "FQC");
                    }
                }
                if (SelfCheckGauge.Text != "")
                {
                    try
                    {
                        excelType = workPart.GetStringAttribute("ExcelType");
                    }
                    catch (System.Exception ex)
                    {
                        excelType = "";
                    }
                    if (excelType != "" && !excelType.Contains("SelfCheck"))
                    {
                        excelType = excelType + "," + "SelfCheck";
                        workPart.SetAttribute("ExcelType", excelType);
                    }
                    if (excelType == "")
                    {
                        workPart.SetAttribute("ExcelType", "SelfCheck");
                    }
                }
            }
            catch (System.Exception ex)
            {
                return;
            }
            MessageBox.Show("Assign成功");
            SelDimen.Text = "選擇物件(0)";
        }
Beispiel #2
0
        private void OK_Click(object sender, EventArgs e)
        {
            if (DicSelDimension.Keys.Count == 0)
            {
                CaxLog.ShowListingWindow("請使用【選擇物件】選擇標註尺寸!");
                return;
            }

            #region 選擇Assign
            if (chb_Assign.Checked == true)
            {
                if (FAIcheckBox.Checked == false & IQCcheckBox.Checked == false & IPQCcheckBox.Checked == false & FQCcheckBox.Checked == false)
                {
                    CaxLog.ShowListingWindow("請先選擇一種檢驗報告格式!");
                    return;
                }
                if (Gauge.Text == "" && SelfCheckGauge.Text == "")
                {
                    CaxLog.ShowListingWindow("資料不足,請先填寫【IQC】或【IPQC】或【SelfCheck】!");
                    return;
                }
                if (Gauge.Text != "" && (Freq_0.Text == "" || Freq_1.Text == "" || Freq_Units.Text == ""))
                {
                    CaxLog.ShowListingWindow("IQC尚未填寫完畢!");
                    return;
                }
                if (SelfCheckGauge.Text != "" && (SelfCheck_0.Text == "" || SelfCheck_1.Text == "" || SelfCheck_Units.Text == ""))
                {
                    CaxLog.ShowListingWindow("SelfCheck尚未填寫完畢!");
                    return;
                }

                foreach (KeyValuePair <NXObject, string> kvp in DicSelDimension)
                {
                    //取得原始顏色
                    int oldColor = CaxME.GetDimensionColor(kvp.Key);
                    if (oldColor == -1)
                    {
                        oldColor = 125;
                    }
                    //取得檢具顏色
                    GaugeData cGaugeData = new GaugeData();
                    if (SelfCheckGauge.Text != "")
                    {
                        status = DicGaugeData.TryGetValue(SelfCheckGauge.Text, out cGaugeData);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("此檢具資料可能有誤");
                            return;
                        }
                    }
                    if (Gauge.Text != "")
                    {
                        status = DicGaugeData.TryGetValue(Gauge.Text, out cGaugeData);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("此檢具資料可能有誤");
                            return;
                        }
                    }

                    //改變標註尺寸顏色
                    CaxME.SetDimensionColor(kvp.Key, Convert.ToInt32(cGaugeData.Color));
                    //塞屬性
                    kvp.Key.SetAttribute(CaxME.DimenAttr.OldColor, oldColor.ToString());//舊顏色
                    if (Gauge.Text != "")
                    {
                        if (FAIcheckBox.Checked == true)
                        {
                            kvp.Key.SetAttribute(CaxME.DimenAttr.FAI_Gauge, Gauge.Text);//檢具名稱
                            kvp.Key.SetAttribute(CaxME.DimenAttr.FAI_Freq, Freq_0.Text + "PC/" + Freq_1.Text + Freq_Units.Text);
                        }
                        if (IQCcheckBox.Checked == true)
                        {
                            kvp.Key.SetAttribute(CaxME.DimenAttr.IQC_Gauge, Gauge.Text);//檢具名稱
                            kvp.Key.SetAttribute(CaxME.DimenAttr.IQC_Freq, Freq_0.Text + "PC/" + Freq_1.Text + Freq_Units.Text);
                        }
                        if (IPQCcheckBox.Checked == true)
                        {
                            kvp.Key.SetAttribute(CaxME.DimenAttr.IPQC_Gauge, Gauge.Text);//檢具名稱
                            kvp.Key.SetAttribute(CaxME.DimenAttr.IPQC_Freq, Freq_0.Text + "PC/" + Freq_1.Text + Freq_Units.Text);
                        }
                        if (FQCcheckBox.Checked == true)
                        {
                            kvp.Key.SetAttribute(CaxME.DimenAttr.FQC_Gauge, Gauge.Text);//檢具名稱
                            kvp.Key.SetAttribute(CaxME.DimenAttr.FQC_Freq, Freq_0.Text + "PC/" + Freq_1.Text + Freq_Units.Text);
                        }
                    }
                    if (SelfCheckGauge.Text != "")
                    {
                        kvp.Key.SetAttribute(CaxME.DimenAttr.SelfCheck_Gauge, SelfCheckGauge.Text);                                               //檢具名稱
                        kvp.Key.SetAttribute(CaxME.DimenAttr.SelfCheck_Freq, SelfCheck_0.Text + "PC/" + SelfCheck_1.Text + SelfCheck_Units.Text); //SelfCheck
                    }

                    /*
                     * //泡泡順序增加
                     * BallonNum++;
                     * //取得泡泡的座標
                     * CaxME.BoxCoordinate TextCoordi = new CaxME.BoxCoordinate();
                     * Point3d CreateBallonPt = new Point3d();
                     * CaxME.GetTextBoxCoordinate(kvp.Key.Tag, out TextCoordi);
                     * if (Math.Abs(TextCoordi.upper_left[0] - TextCoordi.lower_left[0]) < 0.01)
                     * {
                     *  CreateBallonPt.X = (TextCoordi.upper_left[0] + TextCoordi.lower_left[0]) / 2 - 2;
                     *  CreateBallonPt.Y = (TextCoordi.upper_left[1] + TextCoordi.lower_left[1]) / 2;
                     * }
                     * else
                     * {
                     *  CreateBallonPt.X = (TextCoordi.upper_left[0] + TextCoordi.lower_left[0]) / 2;
                     *  CreateBallonPt.Y = (TextCoordi.upper_left[1] + TextCoordi.lower_left[1]) / 2 - 2;
                     * }
                     * //插入泡泡
                     * CaxME.CreateBallonOnSheet(BallonNum.ToString(), CreateBallonPt);
                     * //取得泡泡在圖紙的區域
                     * string SheetNum = ListSheet.Text, RegionX = "", RegionY = "";
                     * for (int i = 0; i < cCoordinateData.DraftingCoordinate.Count;i++ )
                     * {
                     *  string SheetSize = cCoordinateData.DraftingCoordinate[i].SheetSize;
                     *  if (Math.Ceiling(SheetHeight) != Convert.ToDouble(SheetSize.Split(',')[0]) || Math.Ceiling(SheetLength) != Convert.ToDouble(SheetSize.Split(',')[1]))
                     *  {
                     *      continue;
                     *  }
                     *  //比對X
                     *  for (int j = 0; j < cCoordinateData.DraftingCoordinate[i].RegionX.Count;j++ )
                     *  {
                     *      string X0 = cCoordinateData.DraftingCoordinate[i].RegionX[j].X0;
                     *      string X1 = cCoordinateData.DraftingCoordinate[i].RegionX[j].X1;
                     *      if (CreateBallonPt.X >= Convert.ToDouble(X0) && CreateBallonPt.X <= Convert.ToDouble(X1))
                     *      {
                     *          RegionX = cCoordinateData.DraftingCoordinate[i].RegionX[j].Zone;
                     *      }
                     *  }
                     *  //比對Y
                     *  for (int j = 0; j < cCoordinateData.DraftingCoordinate[i].RegionY.Count; j++)
                     *  {
                     *      string Y0 = cCoordinateData.DraftingCoordinate[i].RegionY[j].Y0;
                     *      string Y1 = cCoordinateData.DraftingCoordinate[i].RegionY[j].Y1;
                     *      if (CreateBallonPt.Y >= Convert.ToDouble(Y0) && CreateBallonPt.Y <= Convert.ToDouble(Y1))
                     *      {
                     *          RegionY = cCoordinateData.DraftingCoordinate[i].RegionY[j].Zone;
                     *      }
                     *  }
                     * }
                     * //塞泡泡屬性
                     * kvp.Key.SetAttribute(CaxME.DimenAttr.BallonNum, BallonNum.ToString());
                     * kvp.Key.SetAttribute(CaxME.DimenAttr.BallonLocation, SheetNum + "-" + RegionY + RegionX);
                     */
                }
            }

            #endregion

            #region 選擇Remove
            if (chb_Remove.Checked == true)
            {
                foreach (KeyValuePair <NXObject, string> kvp in DicSelDimension)
                {
                    //恢復原始顏色
                    string oldColor = "";
                    try
                    {
                        //第二次以上指定顏色的話,抓出來的顏色就不是內建顏色EX:125->108->186,抓到的是108
                        oldColor = kvp.Key.GetStringAttribute(CaxME.DimenAttr.OldColor);
                        //內建原始顏色
                        oldColor = "125";
                    }
                    catch (System.Exception ex)
                    {
                        oldColor = "125";
                    }
                    CaxME.SetDimensionColor(kvp.Key, Convert.ToInt32(oldColor));

                    //取得泡泡資訊
                    string BallonNum = "";
                    try
                    {
                        BallonNum = kvp.Key.GetStringAttribute(CaxME.DimenAttr.BallonNum);
                    }
                    catch (System.Exception ex)
                    {
                        BallonNum = "";
                    }
                    if (BallonNum != "")
                    {
                        CaxME.DeleteBallon(BallonNum);
                    }

                    kvp.Key.DeleteAllAttributesByType(NXObject.AttributeType.String);
                }
            }
            #endregion

            SelectObject.Text = "選擇物件(0)";
        }