Пример #1
0
        private bool InsertBalloon(int balloonNum, string diCount, Point3d BallonLocation)
        {
            try
            {
                double BallonNumSize = 0;

                //決定數字的大小
                if (balloonNum <= 9)
                {
                    BallonNumSize = 2.5;
                }
                else if (balloonNum > 9 && balloonNum <= 99)
                {
                    BallonNumSize = 1.5;
                }
                else
                {
                    BallonNumSize = 1;
                }
                NXObject balloonObj = null;
                CaxME.CreateBallonOnSheet(balloonNum.ToString(), BallonLocation, BallonNumSize, "BalloonAtt", out balloonObj);
                //如果大於1表示要插入a.b.c.....
                if (diCount != "1")
                {
                    //文字座標
                    CaxME.BoxCoordinate sBoxCoordinate = new CaxME.BoxCoordinate();
                    CaxME.GetTextBoxCoordinate(balloonObj.Tag, out sBoxCoordinate);
                    Point3d textCoord = new Point3d(sBoxCoordinate.lower_left[0] + 1.5, sBoxCoordinate.lower_left[1] - 1.5, 0);
                    string  countText = Convert.ToChar(65 + 0).ToString().ToLower() + "-" + Convert.ToChar(65 + Convert.ToInt32(diCount) - 1).ToString().ToLower();
                    CaxME.InsertDicountNote(balloonNum.ToString(), CaxME.DimenAttr.DiCount, countText, "1.8", textCoord);
                }
            }
            catch (System.Exception ex)
            {
                return(false);
            }
            return(true);
        }
Пример #2
0
    private static void InsertBallon(ref int MaxBallonNum, CoordinateData cCoordinateData, double SheetHeight, double SheetLength, string BalloonAtt)
    {
        double BallonNumSize = 0;

        foreach (KeyValuePair <string, List <DimenData> > kvp in DefineParam.DicDimenData)
        {
            List <DimenData> tempListDimenData = new List <DimenData>();
            DefineParam.DicDimenData.TryGetValue(kvp.Key, out tempListDimenData);
            for (int i = 0; i < tempListDimenData.Count; i++)
            {
                tempListDimenData[i].CurrentSheet.Open();
                MaxBallonNum++;
                Point3d BallonLocation = new Point3d();
                BallonLocation.X = tempListDimenData[i].LocationX;
                BallonLocation.Y = tempListDimenData[i].LocationY;
                //決定數字的大小
                if (MaxBallonNum <= 9)
                {
                    BallonNumSize = 2.5;
                }
                else if (MaxBallonNum > 9 && MaxBallonNum <= 99)
                {
                    BallonNumSize = 1.5;
                }
                else
                {
                    BallonNumSize = 1;
                }
                NXObject balloonObj = null;
                CaxME.CreateBallonOnSheet(MaxBallonNum.ToString(), BallonLocation, BallonNumSize, BalloonAtt, out balloonObj);

                //取得該尺寸數量
                string diCount = "";
                try
                {
                    diCount = tempListDimenData[i].Obj.GetStringAttribute(CaxME.DimenAttr.DiCount);
                }
                catch (System.Exception ex)
                {
                    //當遇到舊料號沒有Dicount的屬性時,在這邊補上
                    tempListDimenData[i].Obj.SetAttribute(CaxME.DimenAttr.DiCount, "1");
                    diCount = "1";
                }
                //如果大於1表示要插入a.b.c.....
                if (diCount != "1")
                {
                    //文字座標
                    CaxME.BoxCoordinate sBoxCoordinate = new CaxME.BoxCoordinate();
                    CaxME.GetTextBoxCoordinate(balloonObj.Tag, out sBoxCoordinate);
                    Point3d textCoord = new Point3d(sBoxCoordinate.lower_left[0] + 1.5, sBoxCoordinate.lower_left[1] - 1.5, 0);
                    string  countText = Convert.ToChar(65 + 0).ToString().ToLower() + "-" + Convert.ToChar(65 + Convert.ToInt32(diCount) - 1).ToString().ToLower();
                    CaxME.InsertDicountNote(MaxBallonNum.ToString(), CaxME.DimenAttr.DiCount, countText, "1.8", textCoord);
                }


                //取得該尺寸所在圖紙
                string SheetNum = tempListDimenData[i].Obj.GetStringAttribute("SheetName");
                #region 計算泡泡相對位置
                //計算泡泡相對位置
                string RegionX = "", RegionY = "";
                for (int ii = 0; ii < cCoordinateData.DraftingCoordinate.Count; ii++)
                {
                    string SheetSize = cCoordinateData.DraftingCoordinate[ii].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[ii].RegionX.Count; j++)
                    {
                        string X0 = cCoordinateData.DraftingCoordinate[ii].RegionX[j].X0;
                        string X1 = cCoordinateData.DraftingCoordinate[ii].RegionX[j].X1;
                        if (BallonLocation.X >= Convert.ToDouble(X0) && BallonLocation.X <= Convert.ToDouble(X1))
                        {
                            RegionX = cCoordinateData.DraftingCoordinate[ii].RegionX[j].Zone;
                        }
                    }
                    //比對Y
                    for (int j = 0; j < cCoordinateData.DraftingCoordinate[ii].RegionY.Count; j++)
                    {
                        string Y0 = cCoordinateData.DraftingCoordinate[ii].RegionY[j].Y0;
                        string Y1 = cCoordinateData.DraftingCoordinate[ii].RegionY[j].Y1;
                        if (BallonLocation.Y >= Convert.ToDouble(Y0) && BallonLocation.Y <= Convert.ToDouble(Y1))
                        {
                            RegionY = cCoordinateData.DraftingCoordinate[ii].RegionY[j].Zone;
                        }
                    }
                }
                #endregion
                tempListDimenData[i].Obj.SetAttribute(CaxME.DimenAttr.BallonNum, MaxBallonNum.ToString());
                tempListDimenData[i].Obj.SetAttribute(CaxME.DimenAttr.BallonLocation, SheetNum + "-" + RegionY + RegionX);
            }
        }
    }
Пример #3
0
        private void InsertBalloon(GridRow row, CoordinateData cCoordinateData)
        {
            //取得圖紙長、高
            NXOpen.Drawings.DrawingSheet drawingSheet1 = (NXOpen.Drawings.DrawingSheet)workPart.DrawingSheets.FindObject(row.Cells["尺寸位置"].Value.ToString());
            drawingSheet1.Open();
            double SheetLength = drawingSheet1.Length;
            double SheetHeight = drawingSheet1.Height;

            //事先塞入該尺寸所在Sheet
            ((NXObject)row.Cells["Dimension"].Value).SetAttribute(CaxME.DimenAttr.SheetName, row.Cells["尺寸位置"].Value.ToString());
            //計算泡泡座標
            CaxME.BoxCoordinate cBoxCoordinate = new CaxME.BoxCoordinate();
            CaxME.GetTextBoxCoordinate(((NXOpen.Annotations.Annotation)row.Cells["Dimension"].Value).Tag, out cBoxCoordinate);
            DimenData sDimenData = new DimenData();

            Functions.CalculateBallonCoordinate(cBoxCoordinate, ref sDimenData);
            Point3d BallonLocation = new Point3d();

            BallonLocation.X = sDimenData.LocationX;
            BallonLocation.Y = sDimenData.LocationY;
            //決定數字的大小
            double BallonNumSize = 0;

            if (Convert.ToInt32(row.Cells["自定泡泡號"].Value) <= 9)
            {
                BallonNumSize = 2.5;
            }
            else if (Convert.ToInt32(row.Cells["自定泡泡號"].Value) > 9 && Convert.ToInt32(row.Cells["自定泡泡號"].Value) <= 99)
            {
                BallonNumSize = 1.5;
            }
            else
            {
                BallonNumSize = 1;
            }
            NXObject balloonObj = null;

            CaxME.CreateBallonOnSheet(row.Cells["自定泡泡號"].Value.ToString(), BallonLocation, BallonNumSize, "BalloonAtt", out balloonObj);

            //取得該尺寸數量
            string diCount = "";

            try
            {
                diCount = ((NXObject)row.Cells["Dimension"].Value).GetStringAttribute(CaxME.DimenAttr.DiCount);
            }
            catch (System.Exception ex)
            {
                //當遇到舊料號沒有Dicount的屬性時,在這邊補上
                ((NXObject)row.Cells["Dimension"].Value).SetAttribute(CaxME.DimenAttr.DiCount, "1");
                diCount = "1";
            }
            //如果大於1表示要插入a.b.c.....
            if (diCount != "1")
            {
                //文字座標
                CaxME.BoxCoordinate sBoxCoordinate = new CaxME.BoxCoordinate();
                CaxME.GetTextBoxCoordinate(balloonObj.Tag, out sBoxCoordinate);
                Point3d textCoord = new Point3d(sBoxCoordinate.lower_left[0] + 1.5, sBoxCoordinate.lower_left[1] - 1.5, 0);
                string  countText = Convert.ToChar(65 + 0).ToString().ToLower() + "-" + Convert.ToChar(65 + Convert.ToInt32(diCount) - 1).ToString().ToLower();
                CaxME.InsertDicountNote(row.Cells["自定泡泡號"].Value.ToString(), CaxME.DimenAttr.DiCount, countText, "1.8", textCoord);
            }

            #region 計算泡泡相對位置
            string RegionX = "", RegionY = "";
            for (int ii = 0; ii < cCoordinateData.DraftingCoordinate.Count; ii++)
            {
                string SheetSize = cCoordinateData.DraftingCoordinate[ii].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[ii].RegionX.Count; j++)
                {
                    string X0 = cCoordinateData.DraftingCoordinate[ii].RegionX[j].X0;
                    string X1 = cCoordinateData.DraftingCoordinate[ii].RegionX[j].X1;
                    if (BallonLocation.X >= Convert.ToDouble(X0) && BallonLocation.X <= Convert.ToDouble(X1))
                    {
                        RegionX = cCoordinateData.DraftingCoordinate[ii].RegionX[j].Zone;
                    }
                }
                //比對Y
                for (int j = 0; j < cCoordinateData.DraftingCoordinate[ii].RegionY.Count; j++)
                {
                    string Y0 = cCoordinateData.DraftingCoordinate[ii].RegionY[j].Y0;
                    string Y1 = cCoordinateData.DraftingCoordinate[ii].RegionY[j].Y1;
                    if (BallonLocation.Y >= Convert.ToDouble(Y0) && BallonLocation.Y <= Convert.ToDouble(Y1))
                    {
                        RegionY = cCoordinateData.DraftingCoordinate[ii].RegionY[j].Zone;
                    }
                }
            }
            #endregion

            ((NXObject)row.Cells["Dimension"].Value).SetAttribute(CaxME.DimenAttr.BallonNum, row.Cells["自定泡泡號"].Value.ToString());
            ((NXObject)row.Cells["Dimension"].Value).SetAttribute(CaxME.DimenAttr.BallonLocation, row.Cells["尺寸位置"].Value.ToString() + "-" + RegionY + RegionX);
            workPart.Views.Refresh();
        }