Beispiel #1
0
        private List <T.TableMaterialRow> getSummaryData(List <_Db.BlockReference> blocks)
        {
            List <T.TableMaterialRow> parse = new List <T.TableMaterialRow>();

            foreach (_Db.BlockReference block in blocks)
            {
                G.Point            insp = new G.Point(block.Position.X, block.Position.Y);
                T.TableMaterialRow temp = new T.TableMaterialRow(insp);
                parse.Add(temp);
            }

            return(parse);
        }
 private void setRowParameters(_Db.AttributeReference ar, T.TableMaterialRow sumData)
 {
     if (ar != null)
     {
         if (ar.Tag == "Diam")
         {
             ar.TextString = sumData.Text;
         }
         else if (ar.Tag == "Klass")
         {
             ar.TextString = sumData.Material;
         }
         else if (ar.Tag == "Mass")
         {
             ar.TextString = sumData.Weight.ToString("F2").Replace(",", ".");
         }
         else if (ar.Tag == "Ühik")
         {
             ar.TextString = sumData.Units;
         }
     }
 }
        private void insertRow(G.Point insertion, T.TableMaterialRow sumData, double scale, string tableMaterialRow)
        {
            _Ge.Point3d insertPointBlock = new _Ge.Point3d(insertion.X, insertion.Y, 0);
            using (_Db.BlockReference newBlockReference = new _Db.BlockReference(insertPointBlock, _c.blockTable[tableMaterialRow]))
            {
                newBlockReference.Layer = materialLayer;
                _c.modelSpace.AppendEntity(newBlockReference);
                _c.trans.AddNewlyCreatedDBObject(newBlockReference, true);
                newBlockReference.TransformBy(_Ge.Matrix3d.Scaling(scale, insertPointBlock));

                _Db.BlockTableRecord blockBlockTable = _c.trans.GetObject(_c.blockTable[tableMaterialRow], _Db.OpenMode.ForRead) as _Db.BlockTableRecord;
                if (blockBlockTable.HasAttributeDefinitions)
                {
                    foreach (_Db.ObjectId objID in blockBlockTable)
                    {
                        _Db.DBObject obj = _c.trans.GetObject(objID, _Db.OpenMode.ForRead) as _Db.DBObject;

                        if (obj is _Db.AttributeDefinition)
                        {
                            _Db.AttributeDefinition attDef = obj as _Db.AttributeDefinition;

                            if (!attDef.Constant)
                            {
                                using (_Db.AttributeReference attRef = new _Db.AttributeReference())
                                {
                                    attRef.SetAttributeFromBlock(attDef, newBlockReference.BlockTransform);
                                    attRef.Position = attDef.Position.TransformBy(newBlockReference.BlockTransform);
                                    setRowParameters(attRef, sumData);
                                    newBlockReference.AttributeCollection.AppendAttribute(attRef);
                                    _c.trans.AddNewlyCreatedDBObject(attRef, true);
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
0
        private void calculateWeights(DrawingArea field, string languange)
        {
            List <string> MaterialFilter = new List <string>();
            var           DistinctItems  = field._rows.GroupBy(x => x.Material).Select(y => y.First());

            foreach (TableBendingRow item in DistinctItems)
            {
                MaterialFilter.Add(item.Material);
            }

            foreach (string mat in MaterialFilter)
            {
                List <TableBendingRow> matList = field._rows.Where(x => x.Material == mat).ToList();

                List <int> DiameterFilter = new List <int>();
                DistinctItems = matList.GroupBy(x => x.Diameter).Select(y => y.First());
                foreach (TableBendingRow item in DistinctItems)
                {
                    DiameterFilter.Add(item.Diameter);
                }

                double totWeight = 0;

                DiameterFilter.Sort();

                foreach (int diam in DiameterFilter)
                {
                    double radius = diam / 2;
                    double area   = Math.PI * (Math.Pow(radius, 2));

                    List <TableBendingRow> diamList = matList.Where(x => x.Diameter == diam).ToList();

                    TableMaterialRow current = new TableMaterialRow();
                    current.Text     = "%%C" + diam.ToString();
                    current.Material = mat;
                    current.Weight   = 0;
                    current.Units    = "kg";

                    foreach (TableBendingRow r in diamList)
                    {
                        double count  = r.Count * r.Length * area;
                        double weight = count * 7850 / 1000000000;
                        current.Weight += weight;
                        totWeight      += weight;
                    }

                    field.addSummary(current);
                }

                TableMaterialRow total = new TableMaterialRow();

                if (languange == "EN")
                {
                    total.Text = "TOTAL";
                }
                else if (languange == "FIN")
                {
                    total.Text = "KOKON";
                }
                else
                {
                    total.Text = "KOKKU";
                }

                total.Material = mat;
                total.Weight   = totWeight;
                total.Units    = "kg";
                field.addSummary(total);
            }
        }
Beispiel #5
0
 internal void addSummary(TableMaterialRow p)
 {
     _summarys.Add(p);
 }