Exemplo n.º 1
0
 private void getSavedGroups()
 {
     Docs docRaw = Docs.getDoc(Decl.TSMATCHINFO_RAW, create_if_notexist: false);
     elements.Clear();
     int cnt = docRaw.Body.iEOL();
     for (int i = docRaw.i0; i <= cnt; i++)
     {
         string guid = docRaw.Body.Strng(i, 1);
         string mat = docRaw.Body.Strng(i, 2);
         string mat_type = docRaw.Body.Strng(i, 3);
         string prf = docRaw.Body.Strng(i, 4);
         double lng = docRaw.Body.Double(i, 5);
         double weight = docRaw.Body.Double(i, 6);
         double vol = docRaw.Body.Double(i, 7);
         Elm elm = new Elm(guid, mat, mat_type, prf, lng, weight, vol);
         elements.Add(elm);
     }
     if (elements.Count != elementsCount)
     {
         Msg.F("TSmatchINFO.xlsx inconsystent", name, elementsCount, elements.Count);
         //11/4                GetSavedReport(doRead: true);
     }
     docReport = Docs.getDoc(Decl.TSMATCHINFO_REPORT);
     getGroups();
     int gr_n = docReport.i0;
     foreach (var gr in elmGroups)
     {
         string grPrice = docReport.Body.Strng(gr_n, Decl.REPORT_SUPL_PRICE);
         gr.totalPrice = Lib.ToDouble(grPrice);
         gr.SupplierName = docReport.Body.Strng(gr_n, Decl.REPORT_SUPPLIER);
         gr.CompSetName = docReport.Body.Strng(gr_n, Decl.REPORT_COMPSET);
         gr_n++;
     }
 }
Exemplo n.º 2
0
        private double getPrice(Elm elm, DPar.DPar csDP, string priceStr)
        {
            double price = Lib.ToDouble(priceStr);

            foreach (var sec in csDP.dpar)
            {
                if (!sec.Key.ToString().Contains("UNIT_"))
                {
                    continue;
                }
                switch (sec.Key)
                {
                case SType.UNIT_Weight:     // kg -> tonn
                    return(elm.weight / 1000 * price);

                case SType.UNIT_Vol:        // mm3 -> m3
                    return(elm.volume / 1000 / 1000 / 1000 * price);

                case SType.UNIT_Length:
                    return(elm.length * price);

                case SType.UNIT_Qty:
                    return(price);
                }
            }
            return(0);
        }
Exemplo n.º 3
0
 public ElmAttSet(Ifc ifc_elm)
 {
     guid     = ifc_elm.guid;
     mat      = ifc_elm.material;
     mat_type = ifc_elm.type_material;
     prf      = ifc_elm.profile;
     length   = Lib.ToDouble(ifc_elm.length);
     weight   = Lib.ToDouble(ifc_elm.weight);
     volume   = Lib.ToDouble(ifc_elm.volume);
     price    = Lib.ToDouble(ifc_elm.price);
 }
Exemplo n.º 4
0
        private static List <ElmAttributes.ElmAttSet> MergeIfcToElmAttSet(List <IfcManager.Core.IfcManager.IfcElement> elements)
        {
            foreach (var ifc_elm in elements)
            {
                string guid = ifc_elm.guid;
                if (!ElmAttSet.ElmAttSet.Elements.ContainsKey(guid))
                {
                    ElmAttSet.ElmAttSet new_elm = new ElmAttSet.ElmAttSet(ifc_elm);
//                    new_elm = new ElmAttSet.ElmAttSet(ifcElemOrg);
                }
                else
                {
                    ElmAttributes.ElmAttSet elm = null;
                    ElmAttSet.ElmAttSet.Elements.TryGetValue(guid, out elm);
                    if (!String.IsNullOrEmpty(ifc_elm.material))
                    {
                        elm.mat = ifc_elm.material;
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.type_material))
                    {
                        elm.mat_type = ifc_elm.type_material;
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.profile))
                    {
                        elm.prf = ifc_elm.profile;
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.length))
                    {
                        elm.length = Lib.ToDouble(ifc_elm.length);
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.weight))
                    {
                        elm.weight = Lib.ToDouble(ifc_elm.weight);
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.volume))
                    {
                        elm.volume = Lib.ToDouble(ifc_elm.volume);
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.price))
                    {
                        elm.price = Lib.ToDouble(ifc_elm.price);
                    }
                }
            }
            return(ElmAttSet.ElmAttSet.Elements.Values.ToList());
        }
Exemplo n.º 5
0
            private List <KeyValuePair <IntPtr, string> > findProperty(String strPropertyName)
            {
                IntPtr iEntitiesCount;
                string propertyType      = string.Empty;
                var    propertyInstances = new List <KeyValuePair <IntPtr, string> >();

                ifcProp2IfcPropType.TryGetValue(strPropertyName, out propertyType);
                if (!string.IsNullOrEmpty(propertyType))
                {
                    IntPtr properties = getAggregator(propertyType, out iEntitiesCount);

                    foreach (IntPtr iPropertyInstance in findEntity(properties, iEntitiesCount))
                    {
                        String strName = getAttrValueAsString(iPropertyInstance, "Name");
                        if (strPropertyName.Equals(strName))
                        {
                            string propValueType = string.Empty;
                            ifcProp2IfcPropValueType.TryGetValue(strPropertyName, out propValueType);
                            if (!string.IsNullOrEmpty(propValueType))
                            {
                                string propValue = getAttrValueAsString(iPropertyInstance, propValueType);
                                if (strPropertyName.Equals("Profile"))
                                {
                                    propertyInstances.Add(new KeyValuePair <IntPtr, string>(iPropertyInstance, propValue));
                                }
                                else
                                {
                                    double x = Lib.ToDouble(propValue);
                                    if (x != 0.0)
                                    {
                                        propertyInstances.Add(new KeyValuePair <IntPtr, string>(iPropertyInstance, propValue));
                                    }
                                }
                            }
                        }
                    }
                }
                return(propertyInstances);
            }
Exemplo n.º 6
0
 /// <summary>
 /// getPrice(gr, csDP, priceStr) - return price made from priceStr in price-list as set in csDP price type 
 /// </summary>
 /// <param name="group">element group to be priced</param>
 /// <param name="csDP">CompSet Dictionary of Parameters</param>
 /// <param name="priceStr">price string in price-list</param>
 /// <returns>double price value, converted from priceStr, group of elemetsa, and pricing type</returns>
 private double getPrice(Group.Group group, DPar.DPar csDP, string priceStr)
 {
     double price = Lib.ToDouble(priceStr);
     foreach (var sec in csDP.dpar)
     {
         if (!sec.Key.ToString().Contains("UNIT_")) continue;
         switch (sec.Key)
         {
             case SType.UNIT_Weight: // kg -> tonn
                 if (group.totalWeight == 0) return group.totalVolume * 7850;
                 return group.totalWeight / 1000 * price;
             case SType.UNIT_Vol:    // NO mm3 -> m3
                 return group.totalVolume * price;
            //     return group.totalVolume / 1000 / 1000 / 1000 * price;
             case SType.UNIT_Length:
                 return group.totalLength * price;
             case SType.UNIT_Qty:
                 return price;
         }
     }
     return 0;
 }
Exemplo n.º 7
0
 string PrfNormStr(string mark)
 {
     string type = string.Empty;
     pars = Lib.GetParsStr(Profile);
     switch (mark)
     {
         case "I":
             if (PrfSub("Б", "b%", "", out type)) goto OK_I;
             if (PrfSub("Б", "б%", "", out type)) goto OK_I;
             if (PrfSub("К", "k%A", "А", out type)) goto OK_I;
             if (PrfSub("К", "k%", "", out type)) goto OK_I;
             if (PrfSub("Ш", "h%", "", out type)) goto OK_I;
             if (PrfSub("Ш", "ш%", "", out type)) goto OK_I;
             if (PrfSub("Д", "d%A", "А", out type)) goto OK_I;
             if (PrfSub("У", "y%A", "А", out type)) goto OK_I;
             if (PrfSub("М", "м%", "", out type)) goto OK_I;
             if (PrfSub("С", "с%", "", out type)) goto OK_I;
             OK_I: mark += pars[0] + type;
             if (type == "" && pars.Count != 1
                 || Regex.IsMatch(type, @"\d") && pars.Count != 2) error(pars);
             break;
         case "[":
             if (PrfSub("[", "aY", "аУ", out type)) goto OK_U;
             if (PrfSub("[", "y", "У", out type)) goto OK_U;
             if (PrfSub("[", "ap", "аП", out type)) goto OK_U;
             if (PrfSub("[", "p", "П", out type)) goto OK_U;
             if (PrfSub("[", "e", "Э", out type)) goto OK_U;
             if (PrfSub("[", "l", "Л", out type)) goto OK_U;
             if (PrfSub("[", "ca", "Cа", out type)) goto OK_U;
             if (PrfSub("[", "cb", "Cб", out type)) goto OK_U;
             if (PrfSub("[", "c", "C", out type)) goto OK_U;
             OK_U: mark += pars[0] + type;
             if (pars.Count != 1) error(pars);
             break;
         case "L":
             if (pars.Count == 2) mark += pars[0] + "x" + pars[1];
             if (pars.Count == 3) mark += pars[0] + "x" + pars[1] + "x" + pars[2];
             if (pars.Count != 2 && pars.Count != 3) error(pars);
             break;
         case "—":
             if (pars.Count == 1) mark += pars[0];
             if (pars.Count == 2)
             {
                 double p0 = Lib.ToDouble(pars[0]);
                 double p1 = Lib.ToDouble(pars[1]);
                 if (p0 < p1) mark += pars[0] + "x" + pars[1];
                 else mark += pars[1] + "x" + pars[0];
             }
             break;
         case "Гн.[]":
         case "Гн.":
             if (pars.Count == 2) mark = "Гн." + pars[0] + "x" + pars[1].Replace(".0", "");
             if (pars.Count == 3)
             {
                 if(pars[0] == pars[1]) mark = "Гн." + pars[0] + "x" + pars[2].Replace(".0", "");
                 else mark = "Гн.[]" + pars[0] + "x" + pars[1] + "x" + pars[2].Replace(".0", "");
             }
             if (pars.Count != 2 && pars.Count != 3) error(pars);
             break;
         case "TK":
         case "TP":
             if(pars.Count >= 2) mark += pars[0] + "x" + pars[1];
             if (pars.Count == 3) mark += "x" + pars[2];
             if (pars.Count != 2 && pars.Count != 3) error(pars);
             break;
         case "IFC_BREP":
             if(pars.Count == 1) mark += "-" + pars[0];
             if (pars.Count > 1) error(pars);
             break;
         default: error(pars); break;
     }
     return mark;
 }
Exemplo n.º 8
0
 public Parameter(string str, ParType _type) : this(str)
 {
     ptype = _type;
     if (ptype == ParType.Integer) par = Lib.ToInt((string)par);
     if (ptype == ParType.Double) par = Lib.ToDouble((string)par);
 }