Esempio n. 1
0
 public ElementFindclass(Document doc, IndependentTag independentTag, List<ViewSheet> listsheet)
 {
     bool flag = independentTag == null || independentTag.OwnerViewId == ElementId.InvalidElementId;
     if (!flag)
     {
         var viewid = independentTag.OwnerViewId;
         foreach (var i in listsheet)
         {
             var allviewonsheet = i.GetAllPlacedViews();
             foreach (var item in allviewonsheet)
             {
                 if (item == viewid)
                 {
                     Sheet = i;
                     Element element = independentTag.GetTaggedLocalElement();
                     Autodesk.Revit.DB.Parameter parameter = (element != null) ? element.LookupParameter("CONTROL_NUMBER") : null;
                     Autodesk.Revit.DB.Parameter parameter2 = (element != null) ? element.LookupParameter("CONTROL_MARK") : null;
                     bool flag4 = parameter == null || parameter.StorageType != StorageType.String;
                     if (!flag4)
                     {
                         bool flag5 = parameter2 == null || parameter2.StorageType != StorageType.String;
                         if (!flag5)
                         {
                             Control_mark = parameter2.AsString();
                             Control_Number = parameter.AsString();
                             SheetName = Sheet.Name;
                             Sheetnumber = Sheet.SheetNumber;
                             ViewName = doc.GetElement(viewid).Name;
                             ID = element.Id;
                         }
                     }
                     else
                     {
                         bool flag5 = parameter2 == null || parameter2.StorageType != StorageType.String;
                         if (!flag5)
                         {
                             Control_mark = parameter2.AsString();
                             Control_Number = "";
                             SheetName = Sheet.Name;
                             Sheetnumber = Sheet.SheetNumber;
                             ViewName = doc.GetElement(viewid).Name;
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Return value Of parameter all case unit
        /// </summary>
        /// <param name="_parameter"></param>
        /// <returns></returns>
        public static string GetValue(this Autodesk.Revit.DB.Parameter _parameter)
        {
            string value;

            switch (_parameter.StorageType)
            {
            // database value, internal units, e.g. feet:
            case StorageType.Double:
                value = RealString(_parameter.AsDouble());
                break;

            case StorageType.Integer:
                value = _parameter.AsInteger().ToString();
                break;

            case StorageType.String:
                value = _parameter.AsString();
                break;

            case StorageType.ElementId:
                value = _parameter.AsElementId().IntegerValue.ToString();
                break;

            case StorageType.None:
                value = "None";
                break;

            default:
                Debug.Assert(false, "unexpected storage type"); value = string.Empty;
                break;
            }

            return(value);
        }
        public Dictionary <string, List <CEGRebarInfo> > GetAllRebar(Document doc)
        {
            Dictionary <string, List <CEGRebarInfo> > dic  = new Dictionary <string, List <CEGRebarInfo> >();
            Dictionary <string, List <CEGRebarInfo> > dic2 = new Dictionary <string, List <CEGRebarInfo> >();
            List <FamilyInstance> col            = (from FamilyInstance x in new FilteredElementCollector(doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_SpecialityEquipment).OfClass(typeof(FamilyInstance)) where x.Symbol.LookupParameter("BAR_SHAPE") != null select x).Cast <FamilyInstance>().ToList();
            ProgressbarWPF        progressbarWPF = new ProgressbarWPF(col.Count, "Export Schedule Rebar")
            {
                topmessage = "Collecting rebar..."
            };

            progressbarWPF.Show();
            foreach (var item in col)
            {
                progressbarWPF.Giatri();
                if (!progressbarWPF.iscontinue)
                {
                    break;
                }
                Autodesk.Revit.DB.Parameter parameter = (item != null) ? item.Symbol.LookupParameter("BAR_SHAPE") : null;
                bool fg = string.IsNullOrEmpty((parameter != null) ? parameter.AsString() : null);
                if (!fg)
                {
                    CEGRebarInfo rebar = new CEGRebarInfo(item);
                    if (rebar.UnistImperial != null && rebar.UnistImperial != "")
                    {
                        if (dic.ContainsKey(rebar.UnistImperial))
                        {
                            dic[rebar.UnistImperial].Add(rebar);
                        }
                        else
                        {
                            dic.Add(rebar.UnistImperial, new List <CEGRebarInfo> {
                                rebar
                            });
                        }
                    }
                }
            }
            var keys = dic.Keys.ToList();

            Caculator(keys);
            foreach (var item in keys)
            {
                foreach (var item2 in dic[item])
                {
                    if (dic2.ContainsKey(item2.UnistImperial))
                    {
                        dic2[item2.UnistImperial].Add(item2);
                    }
                    else
                    {
                        dic2.Add(item2.UnistImperial, new List <CEGRebarInfo> {
                            item2
                        });
                    }
                }
            }
            progressbarWPF.Close();
            return(dic2);
        }
        public Dictionary <string, List <FamilyInstance> > GetAllConnection(Document doc)
        {
            Dictionary <string, List <FamilyInstance> > dic = new Dictionary <string, List <FamilyInstance> >();
            var Conn = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_SpecialityEquipment).OfClass(typeof(FamilyInstance)).Cast <FamilyInstance>().ToList();

            foreach (var i in Conn)
            {
                ElementId faid                 = i.GetTypeId();
                Element   elemtype             = doc.GetElement(faid);
                Autodesk.Revit.DB.Parameter pa = elemtype.LookupParameter("MANUFACTURE_COMPONENT");
                if (pa != null)
                {
                    var vla = pa.AsString();
                    if (vla.Contains("CONNECTION"))
                    {
                        if (dic.ContainsKey(i.Name))
                        {
                            dic[i.Name].Add(i);
                        }
                        else
                        {
                            dic.Add(i.Name, new List <FamilyInstance> {
                                i
                            });
                        }
                    }
                }
            }
            return(dic);
        }
Esempio n. 5
0
        public FamilyinstanceInfo(FamilyInstance familyInstance)
        {
            ID = familyInstance.Id;
            Autodesk.Revit.DB.Parameter parameter = familyInstance.get_Parameter(BuiltInParameter.SKETCH_PLANE_PARAM);
            if (parameter != null)
            {
                var value = parameter.AsString();
                if (value != null)
                {
                    Workplane = value;
                }
                else
                {
                    Workplane = "";
                }
            }
            if (familyInstance.Name.Contains("CONN"))
            {
                Name = familyInstance.Name;
            }
            else
            {
                Name = "(" + familyInstance.Symbol.FamilyName + ")" + " " + familyInstance.Name;
            }
            LocationPoint locationPoint = familyInstance.Location as LocationPoint;

            location = locationPoint.Point;
        }
Esempio n. 6
0
        private static string GetParameterValue(Parameter param)
        {
            string s;

            switch (param.StorageType)
            {
            case StorageType.Double:
                s = param.AsValueString();
                break;

            case StorageType.Integer:
                s = param.AsInteger().ToString();
                break;

            case StorageType.String:
                s = param.AsString();
                break;

            case StorageType.ElementId:
                s = param.AsValueString() == string.Empty ? param.AsElementId().IntegerValue.ToString() : param.AsValueString();
                break;

            case StorageType.None:
                s = "?NONE?";
                break;

            default:
                s = "?ELSE?";
                break;
            }

            return(s);
        }
Esempio n. 7
0
        /// <summary>
        /// Method is taken from here:
        /// https://spiderinnet.typepad.com/blog/2011/08/revit-parameter-api-asvaluestring-tostring-tovaluestring-and-tovaluedisplaystring.html
        /// </summary>
        /// <param name="p">Revit parameter</param>
        /// <returns>Stringified contents of the parameter</returns>
        internal static string ToValueString(this Autodesk.Revit.DB.Parameter p)
        {
            string ret = string.Empty;

            switch (p.StorageType)
            {
            case StorageType.ElementId:
                ret = p.AsValueString().ToString();
                break;

            case StorageType.Integer:
                ret = p.AsInteger().ToString();
                break;

            case StorageType.String:
                ret = p.AsString();
                break;

            case StorageType.Double:
                ret = p.AsValueString();
                break;

            default:
                break;
            }

            return(ret);
        }
Esempio n. 8
0
        public static Model.ParameterValue AsValue(this Autodesk.Revit.DB.Parameter p)
        {
            string text   = null;
            double number = 0;

            switch (p.StorageType)
            {
            case Autodesk.Revit.DB.StorageType.String:
                text = p.AsString();
                return(new Model.ParameterValue {
                    ParameterValueType = ParameterValueType.Text, ValueText = text
                });

            case Autodesk.Revit.DB.StorageType.ElementId:
                text = revitData.Document.GetElement(p.AsElementId()).Name;
                return(new Model.ParameterValue {
                    ParameterValueType = ParameterValueType.Text, ValueText = text
                });

            case Autodesk.Revit.DB.StorageType.Integer:
                number = p.AsInteger();
                return(new Model.ParameterValue {
                    ParameterValueType = ParameterValueType.Number, ValueNumber = number
                });

            case Autodesk.Revit.DB.StorageType.Double:
                number = p.AsDouble().GetConvertValue(p.DisplayUnitType);
                return(new Model.ParameterValue {
                    ParameterValueType = ParameterValueType.Number, ValueNumber = number
                });
            }
            throw new Exception("Đoạn code này không được đọc tới.");
        }
Esempio n. 9
0
        public GroupInstanceInfo(FamilyInstance familyInstance)
        {
            ID = familyInstance.Id.ToString();
            Autodesk.Revit.DB.Parameter parameter = familyInstance.get_Parameter(BuiltInParameter.SKETCH_PLANE_PARAM);
            if (parameter != null)
            {
                var value = parameter.AsString();
                if (value != null)
                {
                    Workplane = value;
                }
                else
                {
                    Workplane = "";
                }
            }

            if (familyInstance.Name.Contains("CONN"))
            {
                Name = familyInstance.Name;
            }
            else
            {
                Name = "(" + familyInstance.Symbol.FamilyName + ")" + " " + familyInstance.Name;
            }
            location       = (familyInstance.Location as LocationPoint).Point;
            Origintranform = familyInstance.GetTransform().Origin;
            Handing        = familyInstance.HandOrientation.ToString() + familyInstance.Name;
            Transform      = familyInstance.GetTransform();
            Bassic         = ((familyInstance.GetTransform().BasisX) + ";" + (familyInstance.GetTransform().BasisY) + ";" + (familyInstance.GetTransform().BasisZ)).ToString();
        }
Esempio n. 10
0
 public bool IsString(out string value)
 {
     value = null;
     if (parameter.StorageType == Rvt.StorageType.String)
     {
         value = parameter.AsString();
     }
     return(value != null);
 }
        public Dictionary <string, Partinfo> GetPartDictionary(Document doc)
        {
            Dictionary <string, Partinfo> dictionary = new Dictionary <string, Partinfo>();
            FilteredElementCollector      filteredElementCollector = new FilteredElementCollector(doc);
            IList <Element> list = filteredElementCollector.OfClass(typeof(FamilyInstance)).ToElements();

            foreach (Element item in list)
            {
                FamilyInstance familyInstance  = item as FamilyInstance;
                FamilyInstance familyInstance2 = familyInstance?.SuperComponent as FamilyInstance;
                if (familyInstance2 != null && familyInstance2.SuperComponent == null)
                {
                    Autodesk.Revit.DB.Parameter parameter = familyInstance.Symbol.LookupParameter("CONTROL_MARK");
                    if (parameter != null && parameter.StorageType == StorageType.String)
                    {
                        string text = parameter.AsString();
                        if (!string.IsNullOrEmpty(text))
                        {
                            string name  = familyInstance2.Symbol.Name;
                            string text2 = familyInstance.LookupParameter("BOM_PRODUCT_HOST")?.AsString() ?? "";
                            if (dictionary.ContainsKey(text))
                            {
                                if (string.IsNullOrEmpty(dictionary[text].ProductName))
                                {
                                    dictionary[text].ProductName = text2;
                                }
                                else if (!dictionary[text].ProductName.Contains(text2))
                                {
                                    dictionary[text].ProductName = dictionary[text].ProductName + "; " + text2;
                                }
                                if (dictionary[text].Connection == null)
                                {
                                    dictionary[text].Connection = name;
                                }
                                else if (!dictionary[text].Connection.Contains(name))
                                {
                                    dictionary[text].Connection = dictionary[text].Connection + "; " + name;
                                }
                            }
                            else
                            {
                                dictionary[text] = new Partinfo
                                {
                                    ProductName = text2
                                };
                                string description = familyInstance.Symbol.LookupParameter("IDENTITY_DESCRIPTION")?.AsString();
                                dictionary[text].Description = description;
                                dictionary[text].Connection  = name;
                            }
                        }
                    }
                }
            }
            return(dictionary);
        }
        private string GetValueOrDefault(string parameterName)
        {
            ProjectInfo projectInfoElement = _doc.ProjectInformation;

            //Check if the param exist
            if (projectInfoElement.GetParameters(parameterName).Count != 0)
            {
                Autodesk.Revit.DB.Parameter param = projectInfoElement.GetParameters(parameterName).FirstOrDefault();
                if (param.AsString() != null || param.AsString() != "")
                {
                    return(param.AsString());
                }

                return("");
            }
            else
            {
                return("");
            }
        }
Esempio n. 13
0
        public static object GetParameterValue(Autodesk.Revit.DB.Parameter param)
        {
            object result;

            switch (param.StorageType)
            {
            case StorageType.ElementId:
                int valueId = param.AsElementId().IntegerValue;
                if (valueId > 0)
                {
                    // When the element is obtained here, to convert it to our element wrapper, it
                    // need to be figured out whether this element is created by us. Here the existing
                    // element wrappers will be checked. If there is one, its property to specify
                    // whether it is created by us will be followed. If there is none, it means the
                    // element is not created by us.
                    var elem = ElementIDLifecycleManager <int> .GetInstance().GetFirstWrapper(valueId) as Element;

                    result = ElementSelector.ByElementId(valueId, elem == null ? true : elem.IsRevitOwned);
                }
                else
                {
                    int paramId = param.Id.IntegerValue;
                    if (paramId == (int)BuiltInParameter.ELEM_CATEGORY_PARAM || paramId == (int)BuiltInParameter.ELEM_CATEGORY_PARAM_MT)
                    {
                        var categories = DocumentManager.Instance.CurrentDBDocument.Settings.Categories;
                        result = new Category(categories.get_Item((BuiltInCategory)valueId));
                    }
                    else
                    {
                        // For other cases, return a localized string
                        result = param.AsValueString();
                    }
                }
                break;

            case StorageType.String:
                result = param.AsString();
                break;

            case StorageType.Integer:
                result = param.AsInteger();
                break;

            case StorageType.Double:
                result = param.AsDouble() * Revit.GeometryConversion.UnitConverter.HostToDynamoFactor(param.Definition.UnitType);
                break;

            default:
                throw new Exception(string.Format(Properties.Resources.ParameterWithoutStorageType, param));
            }

            return(result);
        }
        public ProductCEG(FamilyInstance familyInstance)
        {
            Autodesk.Revit.DB.Parameter parameter = familyInstance.get_Parameter(BuiltInParameter.SKETCH_PLANE_PARAM);
            if (parameter != null)
            {
                var value = parameter.AsString();
                if (value != null)
                {
                    Workplane = value;
                }
                else
                {
                    Workplane = "";
                }
            }
            instance = familyInstance;
            Parameter pa1 = familyInstance.LookupParameter("CONTROL_MARK");
            Parameter pa2 = familyInstance.LookupParameter("CONTROL_NUMBER");
            Parameter pa3 = familyInstance.LookupParameter("MEMBER_WEIGHT_CAST");

            if (pa1 != null)
            {
                Controlmark = pa1.AsString();
            }
            else
            {
                Controlmark = "";
            }
            if (pa2 != null)
            {
                Controlnumber = pa2.AsString();
            }
            else
            {
                Controlnumber = "";
            }
            if (pa3 != null)
            {
                MEMBER_WEIGHT_CAST = pa3.AsString();
            }
            else
            {
                MEMBER_WEIGHT_CAST = "";
            }
        }
        public static string getParameterValue(Element curElem, string paramName)
        {
            string functionReturnValue = null;

            Autodesk.Revit.DB.Parameter curParam = null;

            foreach (Parameter curParam_loopVariable in curElem.Parameters)
            {
                curParam = curParam_loopVariable;
                if (curParam.Definition.Name.ToString() == paramName)
                {
                    Debug.Print("got parameter");
                    functionReturnValue = curParam.AsString();
                    return(functionReturnValue);
                }
            }

            return(null);
        }
Esempio n. 16
0
        private void Getallconnection(Document doc, View view, ref List <FamilyInstance> list)
        {
            var Conn = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_SpecialityEquipment).OfClass(typeof(FamilyInstance)).Cast <FamilyInstance>().ToList();

            foreach (var i in Conn)
            {
                ElementId faid                 = i.GetTypeId();
                Element   elemtype             = doc.GetElement(faid);
                Autodesk.Revit.DB.Parameter pa = elemtype.LookupParameter("MANUFACTURE_COMPONENT");
                if (pa != null)
                {
                    var vla = pa.AsString();
                    if (vla.Contains("CONNECTION"))
                    {
                        list.Add(i);
                    }
                }
            }
        }
Esempio n. 17
0
        //----------------------------------------------------------
        public static void GetParameterValue(Parameter para, Parameter para_change)
        {
            try
            {
                if (para != null)
                {
                    if (para.Definition.Name == para_change.Definition.Name && para.IsReadOnly == false)
                    {
                        // Use different method to get parameter data according to the storage type
                        switch (para.StorageType)
                        {
                        case StorageType.Double:
                            //covert the number into Metric
                            para.Set(para_change.AsDouble());
                            break;

                        case StorageType.ElementId:
                            //find out the name of the element
                            para.Set(para_change.AsElementId());
                            break;

                        case StorageType.Integer:
                            para.Set(para_change.AsInteger());
                            break;

                        case StorageType.String:
                            para.Set(para_change.AsString());
                            break;

                        default:
                            //defValue = "Unexposed parameter.";
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 18
0
        private void Getallvoid(Document doc)
        {
            var Conn = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_GenericModel).OfClass(typeof(FamilyInstance)).Cast <FamilyInstance>().ToList();

            foreach (var i in Conn)
            {
                ElementId faid                 = i.GetTypeId();
                Element   elemtype             = doc.GetElement(faid);
                Autodesk.Revit.DB.Parameter pa = elemtype.LookupParameter("MANUFACTURE_COMPONENT");
                if (pa != null)
                {
                    var value = pa.AsString();
                    if (value.Contains("VOID"))
                    {
                        if (dic2.ContainsKey("(" + i.Symbol.FamilyName + ")" + " " + i.Name))
                        {
                            var ele = i.SuperComponent;
                            if (ele == null)
                            {
                                dic2["(" + i.Symbol.FamilyName + ")" + " " + i.Name].Add(i);
                            }
                        }
                        else
                        {
                            var ele = i.SuperComponent;
                            if (ele == null)
                            {
                                dic2.Add("(" + i.Symbol.FamilyName + ")" + " " + i.Name, new List <FamilyInstance> {
                                    i
                                });
                            }
                        }
                    }
                }
            }
            dic2.OrderByDescending(x => x.Key).ToList();
            foreach (var y in dic2)
            {
                AssortElement(y.Key, "VOID");
            }
        }
Esempio n. 19
0
        public ParameterJSON(RevitParam param,
                             [DefaultArgument("Synthetic.Revit.Document.Current()")] revitDoc Document)
        {
            this.Name        = param.Definition.Name;
            this.StorageType = param.StorageType.ToString();
            switch (this.StorageType)
            {
            case "Double":
                this.Value = param.AsDouble().ToString();
                break;

            case "ElementId":
                ElementIdJSON id = new ElementIdJSON(param.AsElementId(), Document);
                this.Value = ElementIdJSON.ToJSON(id);
                break;

            case "Integer":
                this.Value = param.AsInteger().ToString();
                break;

            case "String":
            default:
                this.Value = param.AsString();
                break;
            }

            this.Id = param.Id.IntegerValue;

            if (IsShared)
            {
                this.GUID = param.GUID.ToString();
            }
            else
            {
                this.GUID = "";
            }

            this.IsShared   = param.IsShared;
            this.IsReadOnly = param.IsReadOnly;
        }
Esempio n. 20
0
        private void Getallconnection(Document doc)
        {
            var Conn = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_SpecialityEquipment).OfClass(typeof(FamilyInstance)).Cast <FamilyInstance>().ToList();

            foreach (var i in Conn)
            {
                ElementId faid                 = i.GetTypeId();
                Element   elemtype             = doc.GetElement(faid);
                Autodesk.Revit.DB.Parameter pa = elemtype.LookupParameter("MANUFACTURE_COMPONENT");
                if (pa != null)
                {
                    var vla = pa.AsString();
                    if (vla.Contains("CONNECTION"))
                    {
                        if (dic.ContainsKey(i.Name))
                        {
                            dic[i.Name].Add(i);
                        }
                        else
                        {
                            dic.Add(i.Name, new List <FamilyInstance> {
                                i
                            });
                        }
                    }
                    else
                    {
                        listspecial.Add(i.Id);
                    }
                }
            }
            var list = dic.Keys.ToList();

            list.Sort();
            foreach (var y in list)
            {
                AssortElement(y, "Connections");
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Get Existing Grevit Elements from Document using the GID
        /// </summary>
        /// <param name="document"></param>
        /// <param name="update">Grevit Client Update Value</param>
        /// <returns></returns>
        public static Dictionary <string, ElementId> GetExistingGrevitElements(this Document document, bool update)
        {
            if (!update)
            {
                return(new Dictionary <string, ElementId>());
            }

            Dictionary <string, ElementId> elems = new Dictionary <string, ElementId>();

            List <Type> types = new List <Type>();

            types.Add(typeof(Autodesk.Revit.DB.Wall));
            types.Add(typeof(Autodesk.Revit.DB.FamilyInstance));
            types.Add(typeof(Autodesk.Revit.DB.RoofBase));

            List <Element> myfilter = document.GetElementsFromClasses(types);

            List <string> banned = new List <string>();

            foreach (Element em in myfilter)
            {
                Autodesk.Revit.DB.Parameter p = em.LookupParameter("GID");
                if (p != null && p.AsString() != null && p.AsString() != string.Empty && em.Id != ElementId.InvalidElementId)
                {
                    if (!banned.Contains(p.AsString()))
                    {
                        if (!elems.ContainsKey(p.AsString()))
                        {
                            elems.Add(p.AsString(), em.Id);
                        }
                        else
                        {
                            elems.Remove(p.AsString()); banned.Add(p.AsString());
                        }
                    }
                }
            }

            return(elems);
        }
Esempio n. 22
0
 ParamValueToStr(Revit.Parameter param)
 {
     if (param.StorageType == Revit.StorageType.Double)
     {
         return(param.AsDouble().ToString());
     }
     else if (param.StorageType == Revit.StorageType.ElementId)
     {
         return(param.AsElementId().ToString());
     }
     else if (param.StorageType == Revit.StorageType.Integer)
     {
         return(param.AsInteger().ToString());
     }
     else if (param.StorageType == Revit.StorageType.String)
     {
         return(param.AsString());
     }
     else
     {
         Debug.Assert(false);
         return(string.Empty);
     }
 }
Esempio n. 23
0
        public SerialParameter(RevitParam parameter,
                               [DefaultArgument("Synthetic.Revit.Document.Current()")] RevitDoc Document)
        {
            this.Name        = parameter.Definition.Name;
            this.StorageType = parameter.StorageType.ToString();
            switch (this.StorageType)
            {
            case "Double":
                this.Value = parameter.AsDouble().ToString();
                break;

            case "ElementId":
                this.ValueElemId = new SerialElementId(parameter.AsElementId(), Document);
                //this.Value = param.AsElementId().ToString();
                break;

            case "Integer":
                this.Value = parameter.AsInteger().ToString();
                break;

            case "String":
            default:
                this.Value = parameter.AsString();
                break;
            }

            this.Id = parameter.Id.IntegerValue;

            if (IsShared)
            {
                this.GUID = parameter.GUID.ToString();
            }

            this.IsShared   = parameter.IsShared;
            this.IsReadOnly = parameter.IsReadOnly;
        }
Esempio n. 24
0
        //----------------------------------------------------------
        public static string GetParameterInformation(Parameter para, Document document)
        {
            string defValue = string.Empty;

            try
            {
                if (para != null)
                {
                    // Use different method to get parameter data according to the storage type
                    switch (para.StorageType)
                    {
                    case StorageType.Double:
                        //covert the number into Metric
                        defValue = para.AsValueString();
                        break;

                    case StorageType.ElementId:
                        //find out the name of the element
                        Autodesk.Revit.DB.ElementId id = para.AsElementId();
                        if (id.IntegerValue >= 0)
                        {
                            defValue = document.GetElement(id).Name;
                        }
                        else
                        {
                            defValue = id.IntegerValue.ToString();
                        }
                        break;

                    case StorageType.Integer:
                        if (ParameterType.YesNo == para.Definition.ParameterType)
                        {
                            if (para.AsInteger() == 0)
                            {
                                defValue = "False";
                            }
                            else
                            {
                                defValue = "True";
                            }
                        }
                        else
                        {
                            defValue = para.AsInteger().ToString();
                        }
                        break;

                    case StorageType.String:
                        defValue = para.AsString();
                        break;

                    default:
                        defValue = "Unexposed parameter.";
                        break;
                    }
                }
            }
            catch (Exception)
            {
                //MessageBox.Show(ex.Message);
            }
            return(defValue);
        }
 public override object GetValue(object component) =>
 parameter.Element is object && parameter.Definition is object?
 (parameter.StorageType == DB.StorageType.String ? parameter.AsString() :
  parameter.AsValueString()) : null;
        public CEGRebarInfo(FamilyInstance familyInstance)
        {
            string imperialSize;
            string metricSize;

            GetBarNumber(familyInstance, out imperialSize, out metricSize);
            this.UnistImperial = imperialSize;
            this.UnistMetric   = UnistMetric;
            Autodesk.Revit.DB.Parameter parameter = familyInstance.LookupParameter("BAR_PREFIX");
            bool flag = parameter != null && parameter.StorageType == StorageType.String;

            if (flag)
            {
                this.BarPrefix = parameter.AsString();
            }
            Autodesk.Revit.DB.Parameter parameter2 = familyInstance.LookupParameter("CONTROL_MARK");
            bool flag2 = parameter2 != null && parameter2.StorageType == StorageType.String;

            if (flag2)
            {
                this.ControlMark = parameter2.AsString();
            }
            Autodesk.Revit.DB.Parameter parameter3 = familyInstance.Symbol.LookupParameter("BAR_SHAPE");
            bool flag3 = parameter3 != null && parameter3.StorageType == StorageType.String;

            if (flag3)
            {
                this.BarShape = parameter3.AsString();
            }
            Autodesk.Revit.DB.Parameter parameter4 = familyInstance.LookupParameter("DIM_LENGTH");
            bool flag4 = parameter4 != null && parameter4.StorageType == StorageType.Double;

            if (flag4)
            {
                this.DimLength = ConVertDoubleToImperial(parameter4.AsDouble());
            }
            Autodesk.Revit.DB.Parameter parameter5 = familyInstance.LookupParameter("BAR_LENGTH_A");
            bool flag5 = parameter5 != null && parameter5.StorageType == StorageType.Double;

            if (flag5)
            {
                this.BarLengthA = ConVertDoubleToImperial(parameter5.AsDouble());
            }
            Autodesk.Revit.DB.Parameter parameter6 = familyInstance.LookupParameter("BAR_LENGTH_B");
            bool flag6 = parameter6 != null && parameter6.StorageType == StorageType.Double;

            if (flag6)
            {
                this.BarLengthB = ConVertDoubleToImperial(parameter6.AsDouble());
            }
            Autodesk.Revit.DB.Parameter parameter7 = familyInstance.LookupParameter("BAR_LENGTH_C");
            bool flag7 = parameter7 != null && parameter7.StorageType == StorageType.Double;

            if (flag7)
            {
                this.BarLengthC = ConVertDoubleToImperial(parameter7.AsDouble());
            }
            Autodesk.Revit.DB.Parameter parameter8 = familyInstance.LookupParameter("BAR_LENGTH_D");
            bool flag8 = parameter8 != null && parameter8.StorageType == StorageType.Double;

            if (flag8)
            {
                this.BarLengthD = ConVertDoubleToImperial(parameter8.AsDouble());
            }
            Autodesk.Revit.DB.Parameter parameter9 = familyInstance.LookupParameter("BAR_LENGTH_E");
            bool flag9 = parameter9 != null && parameter9.StorageType == StorageType.Double;

            if (flag9)
            {
                this.BarLengthE = ConVertDoubleToImperial(parameter9.AsDouble());
            }
            Autodesk.Revit.DB.Parameter parameter10 = familyInstance.LookupParameter("BAR_LENGTH_F");
            bool flag10 = parameter10 != null && parameter10.StorageType == StorageType.Double;

            if (flag10)
            {
                this.BarLengthF = ConVertDoubleToImperial(parameter10.AsDouble());
            }
            Autodesk.Revit.DB.Parameter parameter11 = familyInstance.LookupParameter("BAR_LENGTH_G");
            bool flag11 = parameter11 != null && parameter11.StorageType == StorageType.Double;

            if (flag11)
            {
                this.BarLengthG = ConVertDoubleToImperial(parameter11.AsDouble());
            }
            Autodesk.Revit.DB.Parameter parameter12 = familyInstance.LookupParameter("BAR_LENGTH_H");
            bool flag12 = parameter12 != null && parameter12.StorageType == StorageType.Double;

            if (flag12)
            {
                this.BarLengthH = ConVertDoubleToImperial(parameter12.AsDouble());
            }
            Autodesk.Revit.DB.Parameter parameter13 = familyInstance.LookupParameter("BAR_LENGTH_K");
            bool flag13 = parameter13 != null && parameter13.StorageType == StorageType.Double;

            if (flag13)
            {
                this.BarLengthK = ConVertDoubleToImperial(parameter13.AsDouble());
            }
            Autodesk.Revit.DB.Parameter parameter14 = familyInstance.LookupParameter("TypeNote");
            bool flag14 = parameter14 != null && parameter14.StorageType == StorageType.String;

            if (flag14)
            {
                this.TypeNote = parameter14.AsString();
            }
            Autodesk.Revit.DB.Parameter parameter15 = familyInstance.LookupParameter("BenDia");
            bool flag15 = parameter15 != null && parameter15.StorageType == StorageType.Double;

            if (flag15)
            {
                this.BenDia = ConVertDouble(parameter15.AsDouble());
            }
        }
Esempio n. 27
0
        private void Getallspecialityequipment(Document doc)
        {
            var Conn = new FilteredElementCollector(doc, listspecial).OfCategory(BuiltInCategory.OST_SpecialityEquipment).OfClass(typeof(FamilyInstance)).Cast <FamilyInstance>().ToList();

            foreach (var i in Conn)
            {
                ElementId faid                 = i.GetTypeId();
                Element   elemtype             = doc.GetElement(faid);
                Autodesk.Revit.DB.Parameter pa = elemtype.LookupParameter("MANUFACTURE_COMPONENT");
                if (pa != null)
                {
                    var vla = pa.AsString();
                    if (!vla.Contains("CONNECTION") && !vla.Contains("REBAR") && !vla.Contains("LIFTING"))
                    {
                        if (dic5.ContainsKey("(" + i.Symbol.FamilyName + ")" + " " + i.Name))
                        {
                            var ele = i.SuperComponent;
                            if (ele == null)
                            {
                                dic5["(" + i.Symbol.FamilyName + ")" + " " + i.Name].Add(i);
                            }
                        }
                        else
                        {
                            var ele = i.SuperComponent;
                            if (ele == null)
                            {
                                dic5.Add("(" + i.Symbol.FamilyName + ")" + " " + i.Name, new List <FamilyInstance> {
                                    i
                                });
                            }
                        }
                    }
                }
                else
                {
                    if (dic5.ContainsKey("(" + i.Symbol.FamilyName + ")" + " " + i.Name))
                    {
                        var ele = i.SuperComponent;
                        if (ele == null)
                        {
                            dic5["(" + i.Symbol.FamilyName + ")" + " " + i.Name].Add(i);
                        }
                    }
                    else
                    {
                        var ele = i.SuperComponent;
                        if (ele == null)
                        {
                            dic5.Add("(" + i.Symbol.FamilyName + ")" + " " + i.Name, new List <FamilyInstance> {
                                i
                            });
                        }
                    }
                }
            }
            dic5.OrderByDescending(x => x.Key).ToList();
            foreach (var y in dic5)
            {
                AssortElement(y.Key, "Speciality Equipment");
            }
        }