コード例 #1
0
        /// <summary>
        /// 模板计算工程量方法
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="tyName"></param>
        /// <param name="levList"></param>
        /// <returns></returns>
        public static List <List <Element> > BuiltingQuantityCount(Document doc, bc.TypeName tyName, List <Level> levList)
        {
            List <Element> hostElemList = new List <Element>();
            string         ty           = Enum.GetName(typeof(bc.TypeName), tyName);
            //作为判断的中介
            string p = null;

            if (ty.Contains("模板"))
            {
                p = ty.Split(new char[] { '模' })[0];
            }
            else
            {
                p = ty.Split(new char[] { '砼' })[0];
            }
            foreach (Level lev in levList)
            {
                switch (p)
                {
                case "板":
                    hostElemList.AddRange(bc.FilterElementList <Floor>(doc, BuiltInCategory.OST_Floors, lev));
                    break;

                case "梁":
                    hostElemList.AddRange(bc.FilterElementList <FamilyInstance>(doc, BuiltInCategory.OST_StructuralFraming, lev));
                    break;

                case "柱":
                    hostElemList.AddRange(bc.FilterElementList <FamilyInstance>(doc, BuiltInCategory.OST_StructuralColumns, lev));
                    break;

                case "墙":
                    hostElemList.AddRange(bc.FilterElementList <Wall>(doc, BuiltInCategory.OST_Walls, lev));
                    break;

                case "楼梯":
                    hostElemList.AddRange(bc.FilterElementList <Stairs>(doc, BuiltInCategory.OST_Stairs, lev));
                    break;

                case "基础":
                    hostElemList.AddRange(bc.FilterElementList <FamilyInstance>(doc, BuiltInCategory.OST_StructuralFoundation, lev));
                    break;

                default:
                    break;
                }
            }

            //模板集合
            if (ty.Contains("模板"))
            {
                List <List <Element> > TpListList = hostElemList.ConvertAll(m => new List <Element>()
                {
                    m
                });
                List <Element> dsList = bc.FilterElementList <DirectShape>(doc);
                foreach (DirectShape ds in dsList)
                {
                    int dsId = ds.LookupParameter("HostElemID").AsInteger();
                    //MessageBox.Show("sdjhashdh");
                    foreach (List <Element> tpList in TpListList)
                    {
                        if (tpList[0].Id.IntegerValue == dsId)
                        {
                            tpList.Add(ds);
                            break;
                        }
                    }
                }
                return(TpListList);
            }
            return(new List <List <Element> >()
            {
                hostElemList
            });
        }
コード例 #2
0
        /// <summary>
        /// 模板工程量样板
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="tpName"></param>
        public ProjectAmount(Element ds, bc.TypeName tpName, bool isFirst = false)
        {
            Document       doc          = ds.Document;
            List <Element> hostElemList = new List <Element>();
            Element        hostElem     = null;
            string         ty           = Enum.GetName(typeof(bc.TypeName), tpName);
            //作为判断的中介
            string p = null;

            if (ty.Contains("模板"))
            {
                p = ty.Split(new char[] { '模' })[0];
            }
            else
            {
                p = ty.Split(new char[] { '砼' })[0];
            }
            if (ty.Contains("模板"))
            {
                hostElem = doc.GetElement(new ElementId(ds.LookupParameter("HostElemID").AsInteger()));
            }
            else
            {
                hostElem = ds;
            }
            if (isFirst)
            {
                this.ComponentName = hostElem.Name;
                this.ElemId        = hostElem.Id.IntegerValue;
                switch (p)
                {
                case "板":
                    Floor fl = hostElem as Floor;
                    this.ComponentType = fl.FloorType.Name;
                    this.LevelName     = doc.GetElement(fl.LevelId).Name;
                    break;

                case "梁":
                    FamilyInstance bfi = hostElem as FamilyInstance;
                    this.ComponentType   = bfi.Symbol.FamilyName;
                    this.LevelName       = doc.GetElement(bfi.Host.Id).Name;
                    this.ComponentLength = bfi.LookupParameter("长度").AsValueString();
                    break;

                case "柱":
                    FamilyInstance cfi = hostElem as FamilyInstance;
                    this.ComponentType   = cfi.Symbol.FamilyName;
                    this.LevelName       = doc.GetElement(cfi.LevelId).Name;
                    this.ComponentHighth = cfi.LookupParameter("长度").AsValueString();
                    break;

                case "墙":
                    Wall wal = hostElem as Wall;
                    this.ComponentType   = wal.WallType.Name;
                    this.LevelName       = doc.GetElement(wal.LevelId).Name;
                    this.ComponentLength = wal.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsValueString();
                    this.ComponentHighth = wal.get_Parameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM).AsValueString();
                    break;

                case "楼梯":
                    Stairs stair = hostElem as Stairs;
                    this.ComponentName = doc.GetElement(stair.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsElementId()).Name;
                    this.ComponentType = stair.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsValueString();
                    this.LevelName     = doc.GetElement(stair.get_Parameter(BuiltInParameter.STAIRS_BASE_LEVEL_PARAM).AsElementId()).Name;
                    break;

                case "基础":
                    this.ComponetWidth   = hostElem.get_Parameter(BuiltInParameter.CONTINUOUS_FOOTING_WIDTH).AsValueString();
                    this.ComponentLength = hostElem.get_Parameter(BuiltInParameter.CONTINUOUS_FOOTING_LENGTH).AsValueString();
                    break;

                default:
                    break;
                }
            }
            this.TypeName = Enum.GetName(typeof(bc.TypeName), tpName);
            if (ty.Contains("模板"))
            {
                this.TpId         = ds.Id.IntegerValue;
                this.TpType       = ds.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).AsString();
                this.TemplateSize = ds.LookupParameter("模板尺寸").AsString();
                double tpAmount = ds.LookupParameter("模板面积").AsDouble() * 0.3048 * 0.3048;
                //MessageBox.Show(tpAmount.ToString());
                this.TemplateAmount = bc.TRF(tpAmount, 3);
            }
            else
            {
                bc.AllSolid_Of_Element(hostElem).ConvertAll(m => this.ConcretVolumes += bc.EVToCV(m.Volume));
                this.ConcretVolumes = bc.TRF(ConcretVolumes);
            }
        }