コード例 #1
0
        private EdgeBanding getPartEdgebanding(IWorkbook bookE, EdgebandingType type, List <EdgeBanding> tempEdgeBandings)
        {
            int index = 0;

            switch (type)
            {
            case EdgebandingType.EBL1:
                index = 24;
                break;

            case EdgebandingType.EBL2:
                index = 25;
                break;

            case EdgebandingType.EBW1:
                index = 22;
                break;

            case EdgebandingType.EBW2:
                index = 23;
                break;

            default:
                throw new Exception("Unknow type of edgebanding");
            }

            string edgeName = range[0, index].Text.ToUpper();

            if (string.IsNullOrEmpty(edgeName.Trim()))
            {
                return(EdgeBanding.Default());
            }

            EdgeBanding edge = tempEdgeBandings.Find(it => it.Name.Trim().ToUpper() == edgeName);

            if (edge.Name != string.Empty)
            {
                return(edge);
            }

            var sheet = bookE.Worksheets[1];

            for (int i = 0; i < sheet.Cells.RowCount; i++)
            {
                string _name = sheet.Cells[i, 0].Text;

                if (string.IsNullOrEmpty(_name.Trim()))
                {
                    break;
                }

                if (_name.ToUpper() == edgeName)
                {
                    double thick = GetDoubleValue(sheet.Cells[i, 1].Text, "封边厚度", true, errors);

                    if (thick > 0)
                    {
                        tempEdgeBandings.Add(new EdgeBanding(edgeName, thick));
                    }
                }
            }

            //errors.Add()

            tempEdgeBandings.Add(EdgeBanding.Default());
            return(EdgeBanding.Default());
        }
コード例 #2
0
        public List <ModelError> GetPartsFromOneLine(IRange partRange, IProduct product, List <Part> parts, IWorkbookSet books, List <Material> tempMaterials, List <EdgeBanding> tempEdgebandings)
        {
            List <ModelError> errors = new List <ModelError>();

            PartChecker check = new PartChecker(partRange, errors);

            string partName = check.PartName();
            int    qty      = check.Qty();

            if (qty <= 0)
            {
                return(errors);
            }

            double width  = check.Width();
            double length = check.Length();

            Material material;
            double   thick = check.Thick(books.Workbooks["M"], out material, tempMaterials, errors);

            EdgeBanding ebw1 = check.EBW1(books.Workbooks["E"], tempEdgebandings);
            EdgeBanding ebw2 = check.EBW2(books.Workbooks["E"], tempEdgebandings);
            EdgeBanding ebl1 = check.EBL1(books.Workbooks["E"], tempEdgebandings);
            EdgeBanding ebl2 = check.EBL2(books.Workbooks["E"], tempEdgebandings);

            int          basepoint    = check.BasePoint();
            MachinePoint machinePoint = check.MachinePoint();

            double xRotation = check.XRotation();
            double yRotation = check.YRotation();
            double zRotation = check.ZRotation();

            bool   isDraw3d;
            string layname3d = check.Layname3d(out isDraw3d);
            string layname2d = partRange[0, 36].Text;

            if (width <= 0 || length <= 0 || thick <= 0)
            {
                return(errors);
            }

            check.IsMaterialFitPartLengthAndWidth(length, width, material, errors);

            //TODO:tokens

            bool isEQPart = check.IsEQPart();

            if (isEQPart)
            {
                List <double[]> origins = check.Positions(qty, thick, product.Width);

                foreach (var d in origins)
                {
                    Part part = new Part(partName, 1, width, length, thick, material.Name,
                                         ebw1.Name, ebw2.Name, ebl1.Name, ebl2.Name,
                                         "", "", "",
                                         basepoint, machinePoint.MP,
                                         d[0], d[1], d[2], xRotation, yRotation, zRotation,
                                         layname3d, layname2d,
                                         product);
                    parts.Add(part);
                }
            }
            else
            {
                double xPos = check.XPosition();
                double yPos = check.YPosition();
                double zPos = check.ZPosition();
                Part   part = new Part(partName, qty, width, length, thick, material.Name,
                                       ebw1.Name, ebw2.Name, ebl1.Name, ebl2.Name,
                                       "", "", "",
                                       basepoint, machinePoint.MP,
                                       xPos, yPos, zPos, xRotation, yRotation, zRotation,
                                       layname3d, layname2d,
                                       product);

                parts.Add(part);
            }

            return(errors);
        }