Пример #1
0
        private void AssignGaugeDlg_Load(object sender, EventArgs e)
        {
            try
            {
                int module_id;
                theUfSession.UF.AskApplicationModule(out module_id);
                if (module_id != UFConstants.UF_APP_DRAFTING)
                {
                    MessageBox.Show("請先轉換為製圖模組後再執行!");
                    this.Close();
                }

                Is_Local = Environment.GetEnvironmentVariable("UGII_ENV_FILE");
                if (Is_Local != null)
                {
                    //取得AssignGaugeData
                    status = CaxGetDatData.GetAssignGaugeData(out AGData);
                    if (!status)
                    {
                        CaxLog.ShowListingWindow("GetAssignGaugeData失敗,請檢查MEConfig是否有檔案");
                        return;
                    }

                    //取得圖紙範圍資料Data
                    status = CaxGetDatData.GetDraftingCoordinateData(out cCoordinateData);

                    //取得PRODUCT資料(未完成,資料庫還沒建立)
                    ISession            session    = MyHibernateHelper.SessionFactory.OpenSession();
                    IList <Sys_Product> sysProduct = session.QueryOver <Sys_Product>().List <Sys_Product>();
                    foreach (Sys_Product i in sysProduct)
                    {
                        listProduct.Add(i.productName);
                    }
                }
                else
                {
                    //取得AssignGaugeData
                    string AssignGaugeData_dat  = "AssignGaugeData.dat";
                    string AssignGaugeData_Path = string.Format(@"{0}\{1}", "D:", AssignGaugeData_dat);
                    AGData = System.IO.File.ReadAllLines(AssignGaugeData_Path);

                    //取得圖紙範圍資料Data
                    string DraftingCoordinate_dat  = "DraftingCoordinate.dat";
                    string DraftingCoordinate_Path = string.Format(@"{0}\{1}", "D:", DraftingCoordinate_dat);
                    if (!System.IO.File.Exists(DraftingCoordinate_Path))
                    {
                        MessageBox.Show("路徑:" + DraftingCoordinate_Path + "不存在");
                        return;
                    }

                    CaxPublic.ReadCoordinateData(DraftingCoordinate_Path, out cCoordinateData);
                }
                //預設關閉選擇物件
                //SelectDimen.Enabled = false;

                #region 存AGData到DicGaugeData中
                foreach (string Row in AGData)
                {
                    string[] splitRow = Row.Split(',');
                    if (splitRow.Length == 0)
                    {
                        continue;
                    }

                    GaugeData cGaugeData = new GaugeData();
                    status = DicGaugeData.TryGetValue(splitRow[1], out cGaugeData);
                    if (status)
                    {
                        continue;
                    }

                    cGaugeData       = new GaugeData();
                    cGaugeData.Color = splitRow[0];
                    try
                    {
                        cGaugeData.EngName = splitRow[2];
                    }
                    catch (System.Exception ex)
                    {
                        cGaugeData.EngName = "";
                    }
                    DicGaugeData.Add(splitRow[1], cGaugeData);
                }
                #endregion

                //填檢具到下拉選單中
                //Gauge.Items.Add("");
                //Gauge.Items.AddRange(DicGaugeData.Keys.ToArray());
                //填檢具到SelfCheck下拉選單中
                //SelfCheckGauge.Items.Add("");
                //foreach (KeyValuePair<string,GaugeData> kvp in DicGaugeData)
                //{
                //    if (kvp.Key.Contains("T"))
                //    {
                //        continue;
                //    }
                //    SelfCheckGauge.Items.Add(kvp.Key);
                //}

                //取得sheet並填入下拉選單中
                int          SheetCount  = 0;
                NXOpen.Tag[] SheetTagAry = null;
                theUfSession.Draw.AskDrawings(out SheetCount, out SheetTagAry);
                for (int i = 0; i < SheetCount; i++)
                {
                    NXOpen.Drawings.DrawingSheet CurrentSheet = (NXOpen.Drawings.DrawingSheet)NXObjectManager.Get(SheetTagAry[i]);
                    ListSheet.Items.Add(CurrentSheet.Name);
                }

                //預設開啟sheet1圖紙
                NXOpen.Drawings.DrawingSheet DefaultSheet = (NXOpen.Drawings.DrawingSheet)NXObjectManager.Get(SheetTagAry[0]);
                ListSheet.Text = DefaultSheet.Name;

                //取得圖紙長寬
                SheetLength = DefaultSheet.Length;
                SheetHeight = DefaultSheet.Height;

                //填入IQC、IPQC與SelfCheck的單位
                //string[] CheckUnits = new string[] { "HRS", "PCS", "100%" };
                //Freq_Units.Items.AddRange(CheckUnits.ToArray());
                //SelfCheck_Units.Items.AddRange(CheckUnits.ToArray());
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #2
0
        private void AssignGaugeDlg_Load(object sender, EventArgs e)
        {
            /*
             * //取回目前泡泡最大值
             * try
             * {
             *  BallonNum = Convert.ToInt32(workPart.GetStringAttribute(CaxME.DimenAttr.BallonNum));
             * }
             * catch (System.Exception ex)
             * {
             *  BallonNum = 0;
             * }
             */

            //預設關閉選擇物件
            SelectObject.Enabled = false;

            //取得AssignGaugeData
            string[] AGData = new string[] { };
            status = CaxGetDatData.GetAssignGaugeData(out AGData);
            if (!status)
            {
                CaxLog.ShowListingWindow("GetAssignGaugeData失敗,請檢查MEConfig是否有檔案");
                return;
            }

            #region 存AGData到DicGaugeData中
            foreach (string Row in AGData)
            {
                string[] splitRow = Row.Split(',');
                if (splitRow.Length == 0)
                {
                    continue;
                }

                GaugeData cGaugeData = new GaugeData();
                status = DicGaugeData.TryGetValue(splitRow[1], out cGaugeData);
                if (status)
                {
                    continue;
                }

                cGaugeData       = new GaugeData();
                cGaugeData.Color = splitRow[0];
                try
                {
                    cGaugeData.EngName = splitRow[2];
                }
                catch (System.Exception ex)
                {
                    cGaugeData.EngName = "";
                }
                DicGaugeData.Add(splitRow[1], cGaugeData);
            }
            #endregion

            //填檢具到IQC、IPQC下拉選單中
            Gauge.Items.Add("");
            Gauge.Items.AddRange(DicGaugeData.Keys.ToArray());
            //填檢具到SelfCheck下拉選單中
            SelfCheckGauge.Items.Add("");
            foreach (KeyValuePair <string, GaugeData> kvp in DicGaugeData)
            {
                if (kvp.Key.Contains("T"))
                {
                    continue;
                }
                SelfCheckGauge.Items.Add(kvp.Key);
            }

            //取得sheet並填入下拉選單中
            int          SheetCount  = 0;
            NXOpen.Tag[] SheetTagAry = null;
            theUfSession.Draw.AskDrawings(out SheetCount, out SheetTagAry);
            for (int i = 0; i < SheetCount; i++)
            {
                NXOpen.Drawings.DrawingSheet CurrentSheet = (NXOpen.Drawings.DrawingSheet)NXObjectManager.Get(SheetTagAry[i]);
                ListSheet.Items.Add(CurrentSheet.Name);
            }

            //預設開啟sheet1圖紙
            NXOpen.Drawings.DrawingSheet DefaultSheet = (NXOpen.Drawings.DrawingSheet)NXObjectManager.Get(SheetTagAry[0]);
            ListSheet.Text = DefaultSheet.Name;

            //取得圖紙長寬
            SheetLength = DefaultSheet.Length;
            SheetHeight = DefaultSheet.Height;

            //填入IQC、IPQC與SelfCheck的單位
            string[] CheckUnits = new string[] { "HRS", "PCS", "100%Check" };
            Freq_Units.Items.AddRange(CheckUnits.ToArray());
            SelfCheck_Units.Items.AddRange(CheckUnits.ToArray());

            //取得圖紙範圍資料Data
            CaxGetDatData.GetDraftingCoordinateData(out cCoordinateData);
        }