コード例 #1
0
        public bool checkcol(Part p)
        {
            Parameter param = p.get_Parameter(BuiltInParameter.DPART_ORIGINAL_CATEGORY);
            string    a     = param.AsString();

            if (a == "Structural Columns")
            {
                return(true);
            }
            return(false);
        }
コード例 #2
0
        /// <summary>
        /// Get the IFC type from shared parameters, from a type name, or from a default value.
        /// </summary>
        /// <typeparam name="TEnum">The type of Enum.</typeparam>
        /// <param name="element">The element.</param>
        /// <param name="typeName">The type value.</param>
        /// <param name="defaultValue">A default value that can be null.</param>
        /// <returns>The found value, or null.</returns>
        public static string GetValidIFCType <TEnum>(Element element, string typeName, string defaultValue) where TEnum : struct
        {
            BuiltInParameter paramId = (element is ElementType) ? BuiltInParameter.IFC_EXPORT_PREDEFINEDTYPE_TYPE :
                                       BuiltInParameter.IFC_EXPORT_PREDEFINEDTYPE;
            Parameter exportElementParameter = element.get_Parameter(paramId);
            string    value = exportElementParameter?.AsString();

            if (ValidateStrEnum <TEnum>(value) != null)
            {
                return(value);
            }

            if (paramId == BuiltInParameter.IFC_EXPORT_PREDEFINEDTYPE)
            {
                Element elementType = element.Document.GetElement(element.GetTypeId());
                exportElementParameter = elementType?.get_Parameter(BuiltInParameter.IFC_EXPORT_PREDEFINEDTYPE_TYPE);
                value = exportElementParameter?.AsString();
                if (ValidateStrEnum <TEnum>(value) != null)
                {
                    return(value);
                }
            }

            if (!string.IsNullOrEmpty(typeName) &&
                (string.Compare(typeName, "NotDefined", true) != 0 || string.IsNullOrEmpty(defaultValue)))
            {
                if (ValidateStrEnum <TEnum>(typeName) != null)
                {
                    return(typeName);
                }
            }

            if (!String.IsNullOrEmpty(defaultValue))
            {
                return(defaultValue);
            }

            // We used to return "NotDefined" here.  However, that assumed that all types had "NotDefined" as a value.
            // It is better to return null.
            return(null);
        }
コード例 #3
0
        /// <summary>
        /// 获取面层类型,如“防水”
        /// </summary>
        /// <param name="faceType">提取到的面层类型信息</param>
        /// <returns>如果没有找到此参数,则返回false。</returns>
        public bool GetFaceType(out string faceType)
        {
            Parameter pa = FaceElement.get_Parameter(FaceWallParameters.sp_FaceType_guid);

            if (pa == null)
            {
                faceType = null;
                return(false);
            }
            faceType = pa.AsString();
            return(true);
        }
コード例 #4
0
        /// <summary>
        /// Gets double value from parameter of an element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="group">Optional property group to limit search to.</param>
        /// <param name="propertyName">The property name.</param>
        /// <param name="propertyValue">The output property value.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when element is null.</exception>
        /// <exception cref="System.ArgumentException">Thrown when propertyName is null or empty.</exception>
        /// <returns>The parameter, or null if not found.</returns>
        public static Parameter GetDoubleValueFromElement(Element element, BuiltInParameterGroup?group, string propertyName, out double propertyValue)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            if (String.IsNullOrEmpty(propertyName))
            {
                throw new ArgumentException("It is null or empty.", "propertyName");
            }

            propertyValue = 0.0;

            Parameter parameter = GetParameterFromName(element.Id, group, propertyName);

            if (parameter != null && parameter.HasValue)
            {
                switch (parameter.StorageType)
                {
                case StorageType.Double:
                    propertyValue = parameter.AsDouble();
                    return(parameter);

                case StorageType.Integer:
                    propertyValue = parameter.AsInteger();
                    return(parameter);

                case StorageType.String:
                {
                    string propValue;
                    propValue = parameter.AsString();

                    string propValuetrim = propValue.Trim();
                    // This is kind of hack to quickly check whether we need to parse the parameter or not
                    if (((propValuetrim.Length > 1 && propValuetrim[0] == '{') || (propValuetrim.Length > 2 && propValuetrim[1] == '{')) && (propValuetrim[propValuetrim.Length - 1] == '}'))
                    {
                        ParamExprResolver pResv = new ParamExprResolver(element, propertyName, propValuetrim);
                        double?           propertyDoubleValue = pResv.GetDoubleValue();
                        if (propertyDoubleValue.HasValue)
                        {
                            propertyValue = propertyDoubleValue.Value;
                            return(parameter);
                        }
                    }

                    return(Double.TryParse(propValue, out propertyValue) ? parameter : null);
                }
                }
            }

            return(null);
        }
コード例 #5
0
        public String GetParameterValue(Parameter para, Document document)
        {
            string value = "";

            switch (para.StorageType)
            {
            case StorageType.Double:

                value += para.AsValueString();

                break;

            case StorageType.ElementId:
                Autodesk.Revit.DB.ElementId id = para.AsElementId();
                if (id.IntegerValue >= 0)
                {
                    value += document.GetElement(id).Name;
                }
                else
                {
                    value += id.IntegerValue.ToString();
                }
                break;

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

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

            default:
                value = "Unexposed parameter.";
                break;
            }

            return(value);
        }
コード例 #6
0
        // <summary>
        ///   La subroutine di selezione di un elemento che torna il valore stringa dell'Unit Identifier
        /// </summary>
        /// <remarks>
        /// Il valore dell'UnitIdentifier e' composto dai Parametri dell'elemento UI-ItemCategory,
        /// UI-ProjectAbbreviation, UI-Quadrant, UI-FloorNumber e UI-UnitNumber
        /// </remarks>
        /// <param name="uiapp">L'oggetto Applicazione di Revit</param>m>
        ///
        private string PickCodeTypologie(UIApplication uiapp, Element ele)
        {
            string typologieCode = string.Empty;

            if (ele.LookupParameter("BOLDDistinta") != null)
            {
                Parameter par = ele.LookupParameter("BOLDDistinta");
                typologieCode = par.AsString();
            }

            return(typologieCode);
        }
コード例 #7
0
        public string GetParameterValueAsString(string parameterName)
        {
            Parameter theParam = GetParameterFromProjectInfo(parameterName);

            if (null == theParam)
            {
                return(null);
            }

            // Reads data in the parameter
            return(theParam.AsString());
        }
コード例 #8
0
        private string GetStringValue(Parameter p)
        {
            string value = "";

            if (!p.HasValue)
            {
                return(value);
            }
            if (string.IsNullOrEmpty(p.AsValueString()) && string.IsNullOrEmpty(p.AsString()))
            {
                return(value);
            }
            if (!string.IsNullOrEmpty(p.AsValueString()))
            {
                return(p.AsValueString().ToLowerInvariant());
            }
            else
            {
                return(p.AsString().ToLowerInvariant());
            }
        }
コード例 #9
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            // Modify document within a transaction
            try
            {
                FilteredElementCollector ImportedInstancesCollector = new FilteredElementCollector(mDoc).OfClass(typeof(ImportInstance)).WhereElementIsNotElementType();

                int           count = ImportedInstancesCollector.GetElementCount();
                List <string> str   = new List <string>();

                using (Transaction tx = new Transaction(mDoc, "Clear All Imported DWG Instances"))
                {
                    tx.Start();

                    if (count == 0)
                    {
                        MessageBox.Show("There are no imported instances in this project file!", "Warning");
                    }
                    else
                    {
                        string           filter = tbFilter.Text;
                        List <ElementId> Ids    = new List <ElementId>();

                        foreach (Element c in ImportedInstancesCollector)
                        {
                            Parameter n = c.get_Parameter(BuiltInParameter.IMPORT_SYMBOL_NAME);


                            if (n.AsString().Contains(filter))
                            {
                                Ids.Add(c.Id);
                            }
                        }
                        mDoc.Delete(Ids);
                        if (Ids.Count > 0)
                        {
                            MessageBox.Show(Ids.Count + " instances containing the word " + filter + " have been succesfully deleted!");
                        }
                        else
                        {
                            MessageBox.Show("None of the imported instances in the project match with the filter!");
                        }
                    }

                    tx.Commit();
                }
            }

            catch
            {
                MessageBox.Show("Cannot collect imported instances!", "Warning");
            }
        }
コード例 #10
0
ファイル: RevitUtils.cs プロジェクト: funthing/XPRevitAddins
        public static object GetParameterValue(Parameter p)
        {
            if (p != null)
            {
                switch (p.StorageType)
                {
                case StorageType.Double:
                    return(p.AsDouble());

                case StorageType.Integer:
                    return(p.AsInteger());

                case StorageType.ElementId:
                    return(p.Element.Document.GetElement(p.AsElementId()));

                case StorageType.String:
                    return(p.AsString() != null?p.AsString() : "-");
                }
            }
            return(string.Empty);
        }
コード例 #11
0
        /// <summary>
        ///   La subroutine che calcola il NUMERO dei pannelli per CODICE
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="uiapp">L'oggetto Applicazione di Revit</param>m>
        ///
        private void GetNumberOfPanels(UIApplication uiapp)
        {
            // Cattura tutti i Curtain Panels presenti
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Document   doc   = uidoc.Document;

            // Metodo per catturare i Curtain Panels del Document
            FilteredElementCollector collector      = new FilteredElementCollector(doc);
            ElementCategoryFilter    categoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_CurtainWallPanels);

            collector.WherePasses(categoryFilter);

            int countT = 0;
            int countC = 0;
            int countP = 0;

            // Filtra tutti gli elementi e conta quanti pannelli con quel nome ci sono
            foreach (Element elem in collector)
            {
                Parameter par = elem.LookupParameter(_typologieCode);
                if (par != null && par.AsString() == _valueTypologieCode)
                {
                    countT++;
                }

                par = elem.LookupParameter(_cellCode);
                if (par != null && par.AsString() == _valueCellCode)
                {
                    countC++;
                }

                par = elem.LookupParameter(_positionalCode);
                if (par != null && par.AsString() == _valuePositionalCode)
                {
                    countP++;
                }
            }
            // Salva il numero di pannelli in una variabile
            _nrCodes = new int[] { countT, countC, countP };
        }
コード例 #12
0
ファイル: ParameterUtils.cs プロジェクト: weijx-xa/test
        public static string ParameterToString(Document doc, Parameter param)
        {
            if (!param.HasValue)
            {
                return("无");
            }
            if (param.Definition.ParameterType == ParameterType.Invalid)
            {
                return("不可用");
            }
            if (doc == null)
            {
                doc = param.Element.Document;
            }
            switch (param.StorageType)
            {
            case StorageType.Double:
                var uStr = FormatNumber(doc, param.Definition.UnitType, param.AsDouble());
                return(uStr);

            //var uStr = string.Empty;
            //if (param.Definition.ParameterType == ParameterType.Length)
            //{
            //    uStr = GetParamaterUnit(param.DisplayUnitType);
            //}
            //var dStr = param.AsValueString();
            //if (!String.IsNullOrEmpty(uStr) && !dStr.EndsWith(uStr)) dStr += uStr;
            //return dStr;
            case StorageType.Integer:
                var v = param.AsInteger();
                if (param.Definition.ParameterType == ParameterType.YesNo)
                {
                    if (v == 0)
                    {
                        return("否");
                    }
                    return("是");
                }
                return(FormatNumber(doc, param.Definition.UnitType, v));

            case StorageType.String:
                return(param.AsString());

            case StorageType.ElementId:
                ElementId idVal = param.AsElementId();
                return(AsElementName(doc, idVal));

            case StorageType.None:
            default:
                return("无");
            }
        }
コード例 #13
0
        public Dictionary <string, List <FamilyInstance> > Getelementview(Document doc, View view)
        {
            Dictionary <string, List <FamilyInstance> > dic = new Dictionary <string, List <FamilyInstance> >();
            var col = (from FamilyInstance x in new FilteredElementCollector(doc, view.Id).OfClass(typeof(FamilyInstance)).Cast <FamilyInstance>().ToList() where x.HaveParameterInTypeorRebar(doc, "CONTROL_MARK") select x).ToList();

            try
            {
                foreach (var element in col)
                {
                    ElementId elementId     = element.GetTypeId();
                    Element   eletype       = doc.GetElement(elementId);
                    int       sorting_order = eletype.LookupParameter("SORTING_ORDER").AsInteger();
                    string    val           = string.Empty;
                    if (sorting_order == 405)
                    {
                        Parameter Fy = element.LookupParameter("CONTROL_MARK");
                        if (Fy != null)
                        {
                            val = Fy.AsString();
                            if (dic.ContainsKey(val))
                            {
                                dic[val].Add(element);
                            }
                            else
                            {
                                dic.Add(val, new List <FamilyInstance> {
                                    element
                                });
                            }
                        }
                    }
                    else
                    {
                        val = eletype.LookupParameter("CONTROL_MARK").AsString();
                        if (dic.ContainsKey(val))
                        {
                            dic[val].Add(element);
                        }
                        else
                        {
                            dic.Add(val, new List <FamilyInstance> {
                                element
                            });
                        }
                    }
                }
            }
            catch
            {
            }
            return(dic);
        }
コード例 #14
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication app = commandData.Application;
            Document      doc = app.ActiveUIDocument.Document;

#if _2010
            List <Element> set = new List <Element>();

            ParameterFilter f
                = app.Create.Filter.NewParameterFilter(
                      _bipCode,
                      CriteriaFilterType.NotEqual,
                      string.Empty);

            ElementIterator it = doc.get_Elements(f);
#endif

            using (StreamWriter sw
                       = File.CreateText("C:/omni.txt"))
            {
                FilteredElementCollector collector = new FilteredElementCollector(doc);
                collector.WhereElementIsNotElementType();

                // in 2011, we should probably add some more quick filters here ...
                // and make use of something like:

                //ParameterValueProvider provider = new ParameterValueProvider( new ElementId( Bip.SystemType ) );
                //FilterStringRuleEvaluator evaluator = new FilterStringEquals();
                //string ruleString = ParameterValue.SupplyAir;
                //FilterRule rule = new FilterStringRule( provider, evaluator, ruleString, false );
                //ElementParameterFilter filter = new ElementParameterFilter( rule );
                //collector.WherePasses( filter );

                foreach (Element e in collector)
                {
                    Parameter p = e.get_Parameter(_bipCode);
                    if (null != p)
                    {
                        sw.WriteLine(string.Format(
                                         "{0} code {1} desc {2}",
                                         Util.ElementDescription(e),
                                         p.AsString(),
                                         e.get_Parameter(_bipDesc).AsString()));
                    }
                }
                sw.Close();
            }
            return(Result.Failed);
        }
コード例 #15
0
        public bool execute()
        {
            string txtFile = SettingsUtils.CheckOrCreateSettings();

            Print(txtFile, KPLN_Loader.Preferences.MessageType.Regular);
            if (!System.IO.File.Exists(txtFile))
            {
                Print("Не найден файл " + txtFile, KPLN_Loader.Preferences.MessageType.Error);
                return(false);
            }

            string[] data = System.IO.File.ReadAllLines(txtFile);
            foreach (string s in data)
            {
                string[] line = s.Split(';');
                marksBase.Add(line[0], line[1]);
            }

            int counter = 0;

            foreach (Element elem in elems)
            {
                Parameter markParam = elem.get_Parameter(BuiltInParameter.ALL_MODEL_MARK);
                if (markParam == null)
                {
                    continue;
                }
                if (markParam.HasValue)
                {
                    string   mark      = markParam.AsString();
                    string[] splitmark = mark.Split('-');
                    if (splitmark.Length > 1)
                    {
                        string markPrefix = splitmark[0];
                        if (!marksBase.ContainsKey(markPrefix))
                        {
                            Print("Недопустимый префикс марки " + markPrefix + " у элемента id. Параметр не заполнен!" + elem.Id.IntegerValue.ToString(), KPLN_Loader.Preferences.MessageType.Regular);
                            continue;
                        }
                        string    group      = marksBase[markPrefix];
                        Parameter groupParam = elem.LookupParameter(paramNameGroupConstr);
                        if (groupParam != null)
                        {
                            groupParam.Set(group);
                        }
                        counter++;
                    }
                }
            }
            Print("Обработано элементов: " + counter, KPLN_Loader.Preferences.MessageType.Success);
            return(true);
        }
コード例 #16
0
 public RoomConversionManager(Document doc)
 {
     departmentsInModel = new Dictionary <string, string>();
     allCandidates      = new List <RoomConversionCandidate>();
     this.doc           = doc;
     titleBlocks        = GetAllTitleBlockTypes(this.doc);
     TitleBlockId       = ElementId.InvalidElementId;
     viewTemplates      = GetViewTemplates(this.doc);
     ViewTemplateId     = ElementId.InvalidElementId;
     areaPlanTypes      = GetAreaPlanTypes(this.doc);
     AreaPlanTypeId     = areaPlanTypes.First().Value;
     Scale = 50;
     CropRegionEdgeOffset = 300;
     SheetCopier.SheetCopierManager.GetAllSheets(existingSheets, this.doc);
     SheetCopier.SheetCopierManager.GetAllViewsInModel(existingViews, this.doc);
     CreatePlan = true;
     CreateRCP  = false;
     using (var collector = new FilteredElementCollector(this.doc))
     {
         collector.OfClass(typeof(SpatialElement));
         foreach (Element e in collector)
         {
             if (e.IsValidObject && (e is Room))
             {
                 Room room = e as Room;
                 if (room.Area > 0 && room.Location != null)
                 {
                     allCandidates.Add(new RoomConversionCandidate(room, existingSheets, existingViews));
                     Parameter p = room.LookupParameter("Department");
                     if (p != null && p.HasValue)
                     {
                         string depo = p.AsString().Trim();
                         if (departmentsInModel.Count > 0)
                         {
                             if (!string.IsNullOrEmpty(depo) && !departmentsInModel.ContainsKey(depo))
                             {
                                 departmentsInModel.Add(depo, depo);
                             }
                         }
                         else
                         {
                             if (!string.IsNullOrEmpty(depo))
                             {
                                 departmentsInModel.Add(depo, depo);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #17
0
        public static DuctType[] GetDuctTypes(Document doc, DuctShapeEnum shape)
        {
            FilteredElementCollector coll = new FilteredElementCollector(doc);

            coll.OfClass(typeof(DuctType));

            IEnumerable <DuctType> pts = coll.Cast <DuctType>();

            if ((pts == null) || (pts.Count <DuctType>() == 0))
            {
                return(null);
            }

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

            switch (shape)
            {
            case DuctShapeEnum.Round:
                familyNames.Add("Round Duct");
                familyNames.Add("Gaine circulaire");
                break;

            case DuctShapeEnum.Rectangular:
                familyNames.Add("Rectangular Duct");
                familyNames.Add("Gaine rectangulaire");
                break;

            case DuctShapeEnum.Oval:
                familyNames.Add("Oval Duct");
                familyNames.Add("Gaine ovale");
                break;
            }

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

            foreach (DuctType dt in pts)
            {
                Parameter p = dt.get_Parameter(BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM);
                foreach (string familyName in familyNames)
                {
                    if (p.AsString().ToUpper() == familyName.ToUpper())
                    {
                        types.Add(dt);
                    }
                }
            }
            if (types.Count == 0)
            {
                return(null);
            }
            return(types.ToArray());
        }
コード例 #18
0
        public void setTag(Parameter parTagModel, Element draftElement)
        {
            Parameter parTagDraft = draftElement.LookupParameter("TAG");

            if (parTagDraft != null)
            {
                string tagModel = parTagModel.AsString();
                if (!string.IsNullOrWhiteSpace(tagModel))
                {
                    parTagDraft.Set(tagModel);
                }
            }
        }
コード例 #19
0
 public static void SetTitleBlockParameters(Element existingTitleBlock, Element newTitleBlock)
 {
     try
     {
         Autodesk.Revit.DB.FamilyInstance familyInstance1 = existingTitleBlock as Autodesk.Revit.DB.FamilyInstance;
         Autodesk.Revit.DB.FamilyInstance familyInstance2 = newTitleBlock as Autodesk.Revit.DB.FamilyInstance;
         IList <Parameter> orderedParameters = familyInstance1.GetOrderedParameters();
         familyInstance2.GetOrderedParameters();
         foreach (Parameter parameter1 in (IEnumerable <Parameter>)orderedParameters)
         {
             string    name       = parameter1.Definition.Name;
             Parameter parameter2 = familyInstance1.LookupParameter(name);
             Parameter parameter3 = familyInstance2.LookupParameter(name);
             if (parameter3 != null || parameter2 != null)
             {
                 BuiltInParameter parameterId1 = BuiltInParameter.SHEET_NUMBER;
                 Parameter        parameter4   = familyInstance2.get_Parameter(parameterId1);
                 BuiltInParameter parameterId2 = BuiltInParameter.SHEET_NAME;
                 Parameter        parameter5   = familyInstance2.get_Parameter(parameterId2);
                 if (!(parameter3.Definition.Name == parameter4.Definition.Name) && !(parameter3.Definition.Name == parameter5.Definition.Name))
                 {
                     try
                     {
                         if (parameter3.StorageType == StorageType.Double)
                         {
                             parameter3.Set(parameter2.AsDouble());
                         }
                         else if (parameter3.StorageType == StorageType.ElementId)
                         {
                             parameter3.Set(parameter2.AsElementId());
                         }
                         else if (parameter3.StorageType == StorageType.Integer)
                         {
                             parameter3.Set(parameter2.AsInteger());
                         }
                         else if (parameter3.StorageType == StorageType.String)
                         {
                             parameter3.Set(parameter2.AsString());
                         }
                     }
                     catch
                     {
                     }
                 }
             }
         }
     }
     catch
     {
     }
 }
コード例 #20
0
ファイル: FloorRooms.cs プロジェクト: yazmolod/TerrTools
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            throw new Exception("Macros is deprecated");
            uiapp = commandData.Application;
            uidoc = uiapp.ActiveUIDocument;
            doc   = uidoc.Document;


            ElementId KeyScheduleId = ElementId.InvalidElementId;

            if (KeyScheduleId != null && doc.GetElement(KeyScheduleId) == null)
            {
                TaskDialog.Show("Ошибка", "Не найдена спецификация");
                return(Result.Failed);
            }

            Dictionary <string, string> floorRooms = GetRoomsByFloor();
            List <Element> items = new FilteredElementCollector(doc, KeyScheduleId).ToList();

            using (Transaction tr = new Transaction(doc, "Обновить параметры пола"))
            {
                tr.Start();
                bool doneFlag = false;
                foreach (Element item in items)
                {
                    Parameter floorParameter = item.LookupParameter("Отделка пола");
                    if (floorParameter != null)
                    {
                        doneFlag = true;
                        string floorType = floorParameter.AsString();
                        string value     = "";
                        floorRooms.TryGetValue(floorType, out value);
                        try { item.LookupParameter("Номер помещения (полы)").Set(value); }
                        catch {
                            TaskDialog.Show("Ошибка", "Непредвиденная ошибка");
                            return(Result.Failed);
                        }
                    }
                }
                tr.Commit();
                if (doneFlag)
                {
                    TaskDialog.Show("Результат", "Параметр успешно обновлен");
                }
                else
                {
                    TaskDialog.Show("Результат", "Параметр не обновлен. Попробуйте другую спецификацию");
                }
                return(Result.Succeeded);
            }
        }
コード例 #21
0
        //取得 parameter 內容
        private CusParameter getParameterInfo(Parameter parm, Document doc)
        {
            string value = "< >";

            string defname = parm.Definition.Name;

            switch (parm.StorageType)
            {
            case StorageType.Double:
                value = parm.AsValueString();
                break;

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

            case StorageType.ElementId:
                ElementId eid = parm.AsElementId();
                if (eid.IntegerValue > 0)
                {
                    value = doc.GetElement(eid).Name;
                }
                else
                {
                    value = eid.IntegerValue.ToString();
                }
                break;

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

            default:
                return(null);
            }
            return(new CusParameter(defname, value));
        }
コード例 #22
0
        public static string GetTrackingParameterValue(string documentGuid, string ruleGuid, Element element)
        {
            RegexRule regexRule = RegularApp.RegexRuleCacheService.GetRegexRule(documentGuid, ruleGuid);

            if (regexRule == null)
            {
                return(null);
            }

            Parameter parameter = element?.get_Parameter((BuiltInParameter)regexRule.TrackingParameterObject.ParameterObjectId);

            if (parameter != null)
            {
                // Regular only works with text-based parameters
                if (parameter.StorageType != StorageType.String)
                {
                    return(null);
                }
                return(parameter.AsString());
            }

            Document  document      = RegularApp.DocumentCacheService.GetDocument(documentGuid);
            Element   elementType   = document.GetElement(element.GetTypeId());
            Parameter typeParameter = elementType?.get_Parameter((BuiltInParameter)regexRule.TrackingParameterObject.ParameterObjectId);

            if (typeParameter != null)
            {
                if (typeParameter.StorageType != StorageType.String)
                {
                    return(null);
                }
                string parameterString = typeParameter.AsString();
                string valueString     = typeParameter.AsValueString();
                bool   hasValue        = typeParameter.HasValue;
                return(typeParameter.AsString());
            }
            return(null);
        }
コード例 #23
0
        public ComponentInfo(Component component, Document doc)
        {
            m_component = component;
            ifcGuid     = component.IfcGuid;
            revitId     = component.AuthoringToolId;
            ElementId eId     = new ElementId(int.Parse(revitId));
            Element   element = doc.GetElement(eId);

            if (null != element)
            {
                revitElement = element;
                Parameter param = element.get_Parameter(BuiltInParameter.ALL_MODEL_FAMILY_NAME);
                if (null != param)
                {
                    familyName = param.AsString();
                }
                param = element.get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_NAME);
                if (null != param)
                {
                    symbolName = param.AsString();
                }
            }
        }
コード例 #24
0
 internal connectorSpatialGroup(IEnumerable <Connector> collection, Document doc)
 {
     Connectors = collection.ToList();
     nrOfCons   = Connectors.Count();
     ListOfIds  = new List <string>(nrOfCons);
     foreach (Connector con in collection)
     {
         Element   owner = con.Owner;
         Parameter par   = owner.get_Parameter(new Guid("90be8246-25f7-487d-b352-554f810fcaa7")); //PCF_ELEM_SPEC parameter
         SpecList.Add(par.AsString());
         ListOfIds.Add(owner.Id.ToString());
         Sys = con.MEPSystemAbbreviation(doc);
     }
 }
コード例 #25
0
        /// <summary>
        ///   La subroutine di selezione di un elemento che torna il valore stringa del Codice Posizionale
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="uiapp">L'oggetto Applicazione di Revit</param>m>
        ///
        private void PickPositionalCode(UIApplication uiapp, Reference reference)
        {
            // Chiamo la vista attiva e seleziono gli elementi che mi servono
            UIDocument uidoc = uiapp.ActiveUIDocument;
            ElementId  eleId = reference.ElementId;
            Element    ele   = uidoc.Document.GetElement(eleId);

            // Restituisce il valore del parametro
            if (ele.LookupParameter(_positionalCode) != null)
            {
                Parameter code = ele.LookupParameter(_positionalCode);
                _valuePositionalCode = code.AsString();
            }
        }
コード例 #26
0
        public objectcheck(FamilyInstance familyInstance)
        {
            FamilyInstance = familyInstance;
            Parameter pa = familyInstance.LookupParameter("CONTROL_NUMBER");

            if (pa != null)
            {
                string value = pa.AsString();
                if (!string.IsNullOrEmpty(value))
                {
                    controlnumber = Convert.ToDouble(value);
                }
            }
        }
コード例 #27
0
ファイル: Utils.cs プロジェクト: BIM-Team/RevitProject
        public static string GetParameterValueAsString(Element elem, string parameterName)
        {
#if (Since2016)
            Parameter _param = elem.LookupParameter(parameterName);
#else
            Parameter _param = elem.get_Parameter(parameterName);
#endif
            if (null == _param || _param.StorageType != StorageType.String)
            {
                return(null);
            }

            return(_param.AsString());
        }
コード例 #28
0
        /// <summary>
        /// Add a system mismatch entry to the string builder
        /// </summary>
        static void ReportSystemMistmatch(
            StringBuilder sb,
            Element e,
            string cnctrSys,
            string cnntdSys)
        {
            Parameter p = e.get_Parameter(
                BuiltInParameter.ALL_MODEL_MARK);

            sb.Append(string.Format("Family instance '{0}' "
                                    + "has a connector {{{1}}} that is connected to a "
                                    + "{{{2}}} system...\n\n",
                                    p.AsString(), cnctrSys, cnntdSys));
        }
コード例 #29
0
        private string GetValueOrDefault(string parameterName, string defaultValue)
        {
            //Check if the param exist
            Element firstOne = _elementList.FirstOrDefault();

            if (firstOne.GetParameters(parameterName).Count != 0)
            {
                foreach (Element e in _elementList)
                {
                    Parameter param = e.GetParameters(parameterName).FirstOrDefault();
                    if (param.AsString() != null || param.AsString() != "")
                    {
                        return(param.AsString());
                    }
                }

                return(defaultValue);
            }
            else
            {
                return(defaultValue);
            }
        }
コード例 #30
0
        private String GetProperties(Element e)
        {
            String properties = "";

            foreach (Parameter p in e.Parameters)
            {
                if (p.AsValueString() == "" || p.AsValueString() == null)
                {
                    continue;
                }

                String propertyname = p.Definition.Name;
                propertyname = Regex.Replace(propertyname, @"\s+", "");
                propertyname = propertyname.Replace("(", "_");
                propertyname = propertyname.Replace(")", "");
                propertyname = propertyname.Replace("\\", "");
                propertyname = propertyname.Replace("/", "");
                propertyname = propertyname.Replace(",", "COMMA");
                propertyname = propertyname.Replace(".", "_");
                propertyname = propertyname.Replace("=", "EQUALS");
                properties  += " ;" + NLT + "props:" + propertyname + " \"" + p.AsValueString() + "\"";
            }
            foreach (Parameter p in e.ParametersMap)
            {
                if (p.AsValueString() == "" || p.AsValueString() == null)
                {
                    continue;
                }

                String propertyname = p.Definition.Name;
                propertyname = Regex.Replace(propertyname, @"\s+", "");
                propertyname = propertyname.Replace("(", "_");
                propertyname = propertyname.Replace(")", "");
                propertyname = propertyname.Replace("\\", "");
                propertyname = propertyname.Replace("/", "");
                propertyname = propertyname.Replace(",", "COMMA");
                propertyname = propertyname.Replace(".", "_");
                propertyname = propertyname.Replace("=", "EQUALS");
                properties  += " ;" + NLT + "propsMap:" + propertyname + " \"" + p.AsValueString() + "\"";
            }
            Guid      g     = new Guid("13ea898e-9eb5-4f60-9a35-ca11f0349686");
            Parameter sepID = e.get_Parameter(g);

            if (sepID != null && sepID.HasValue)
            {
                properties += " ;" + NLT + "propsMap:separationID \"" + sepID.AsString() + "\"";
            }
            return(properties);
        }
コード例 #31
0
ファイル: Para.cs プロジェクト: AMEE/revit
 // jeremy
 //public static Object GetParameterValue(Parameter parameter) // jeremy
 /// <summary>
 /// get parameter's value
 /// </summary>
 /// <param name="parameter">parameter of Element</param>
 /// <returns>parameter's value include unit if have</returns>
 public static string GetParameterValue(Parameter parameter)
 {
     switch (parameter.StorageType)
     {
         case StorageType.Double:
             //get value with unit, AsDouble() can get value without unit
             return parameter.AsValueString();
         case StorageType.ElementId:
             return parameter.AsElementId().IntegerValue.ToString();
         case StorageType.Integer:
             //get value with unit, AsInteger() can get value without unit
             return parameter.AsValueString();
         case StorageType.None:
             return parameter.AsValueString();
         case StorageType.String:
             return parameter.AsString();
         default:
             return "";
     }
 }
コード例 #32
0
 private void writeValueByStorageType(Parameter p, TextWriter writer, Document doc)
 {
     if (null != p)
     {
         switch (p.StorageType)
         {
             case StorageType.Double:
                 {
                     writer.Write(p.AsDouble());
                     break;
                 }
             case StorageType.Integer:
                 {
                     writer.Write(p.AsInteger());
                     break;
                 }
             case StorageType.String:
                 {
                     writer.Write(p.AsString());
                     break;
                 }
             case StorageType.ElementId:
                 {
                     Element elem = doc.get_Element(p.AsElementId());
                     if (null == elem)
                         writer.Write("NULL ELEMENT FOUND");
                     else
                         writer.Write(elem.Name);
                     break;
                 }
             default:
                 writer.Write("N/A");
                 break;
         }
     }
 }
コード例 #33
0
ファイル: FamilyInstance.cs プロジェクト: Zhengzi/Dynamo
 private static Value _getParam(FamilyInstance fi, Parameter p)
 {
     if (p.StorageType == StorageType.Double)
     {
         switch (p.Definition.ParameterType)
         {
             case ParameterType.Length:
                 return Value.NewContainer(Units.Length.FromFeet(p.AsDouble()));
                 break;
             case ParameterType.Area:
                 return Value.NewContainer(Units.Area.FromSquareFeet(p.AsDouble()));
                 break;
             case ParameterType.Volume:
                 return Value.NewContainer(Units.Volume.FromCubicFeet(p.AsDouble()));
                 break;
             default:
                 return Value.NewNumber(p.AsDouble());
                 break;
         }
     }
     else if (p.StorageType == StorageType.Integer)
     {
         return Value.NewNumber(p.AsInteger());
     }
     else if (p.StorageType == StorageType.String)
     {
         return Value.NewString(p.AsString());
     }
     else
     {
         return Value.NewContainer(p.AsElementId());
     }
 }
コード例 #34
0
ファイル: dynFamilies.cs プロジェクト: Dewb/Dynamo
 private static Expression _getParam(FamilyInstance fi, Parameter p)
 {
     if (p.StorageType == StorageType.Double)
     {
         return Expression.NewNumber(p.AsDouble());
     }
     else if (p.StorageType == StorageType.Integer)
     {
         return Expression.NewNumber(p.AsInteger());
     }
     else if (p.StorageType == StorageType.String)
     {
         return Expression.NewString(p.AsString());
     }
     else
     {
         return Expression.NewContainer(p.AsElementId());
     }
 }
コード例 #35
0
        private void Stream(ArrayList data, Parameter param)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(Parameter)));

            data.Add(new Snoop.Data.Object("Definition", param.Definition));

            try {   // this only works for certain types of Parameters
                data.Add(new Snoop.Data.String("Display unit type", param.DisplayUnitType.ToString()));
            }
            catch (System.Exception) {
                data.Add(new Snoop.Data.String("Display unit type", "N/A"));
            }
            try
            {   // this only works for certain types of Parameters
              data.Add(new Snoop.Data.Object("Element", param.Element));
            }
            catch (System.Exception ex)
            {
              data.Add(new Snoop.Data.Exception("Element", ex));
            }
            try
            {   // this only works for certain types of Parameters
              data.Add(new Snoop.Data.String("GUID", param.GUID.ToString()));
            }
            catch (System.Exception ex)
            {
              data.Add(new Snoop.Data.Exception("GUID", ex));
            }
            try
            {   // this only works for certain types of Parameters
              data.Add(new Snoop.Data.Bool("HasValue", param.HasValue));
            }
            catch (System.Exception ex)
            {
              data.Add(new Snoop.Data.Exception("HasValue", ex));
            }
            try
            {   // this only works for certain types of Parameters
              data.Add(new Snoop.Data.ElementId("ID", param.Id,m_activeDoc));
            }
            catch (System.Exception ex)
            {
              data.Add(new Snoop.Data.Exception("ID", ex));
            }
            try
            {   // this only works for certain types of Parameters
              data.Add(new Snoop.Data.Bool("IsShared", param.IsShared));
            }
            catch (System.Exception ex)
            {
              data.Add(new Snoop.Data.Exception("IsShared", ex));
            }

            data.Add(new Snoop.Data.String("Storage type", param.StorageType.ToString()));

            if (param.StorageType == StorageType.Double)
                data.Add(new Snoop.Data.Double("Value", param.AsDouble()));
            else if (param.StorageType == StorageType.ElementId)
                data.Add(new Snoop.Data.ElementId("Value", param.AsElementId(), m_app.ActiveUIDocument.Document));
            else if (param.StorageType == StorageType.Integer)
                data.Add(new Snoop.Data.Int("Value", param.AsInteger()));
            else if (param.StorageType == StorageType.String)
                data.Add(new Snoop.Data.String("Value", param.AsString()));

            data.Add(new Snoop.Data.String("As value string", param.AsValueString()));
        }
コード例 #36
0
        /// <summary>
        /// Extract the parameter information.
        /// By Dan Tartaglia.
        /// </summary>
        public string GetParameterInformation(
            Parameter para,
            Document doc)
        {
            string defName = "";

              // Use different method to get parameter
              // data according to the storage type

              switch( para.StorageType )
              {
            // Determine the parameter type

            case StorageType.Double:

              // Convert the number into Metric

              defName = para.AsValueString();
              break;

            case StorageType.ElementId:

              // Find out the name of the element

              Autodesk.Revit.DB.ElementId id
            = para.AsElementId();

              defName = ( id.IntegerValue >= 0 )
            ? doc.GetElement( id ).Name
            : id.IntegerValue.ToString();

              break;

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

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

            default:
              defName = "Unexposed parameter";
              break;
              }
              return defName;
        }
コード例 #37
0
        /// <summary>
        /// Helper to return parameter value as string.
        /// One can also use param.AsValueString() to
        /// get the user interface representation.
        /// </summary>
        public static string GetParameterValue( Parameter param )
        {
            string s;
              switch( param.StorageType )
              {
            case StorageType.Double:
              //
              // the internal database unit for all lengths is feet.
              // for instance, if a given room perimeter is returned as
              // 102.36 as a double and the display unit is millimeters,
              // then the length will be displayed as
              // peri = 102.36220472440
              // peri * 12 * 25.4
              // 31200 mm
              //
              //s = param.AsValueString(); // value seen by user, in display units
              //s = param.AsDouble().ToString(); // if not using not using LabUtils.RealString()
              s = RealString( param.AsDouble() ); // raw database value in internal units, e.g. feet
              break;

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

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

            case StorageType.ElementId:
              s = param.AsElementId().IntegerValue.ToString();
              break;

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

            default:
              s = "?ELSE?";
              break;
              }
              return s;
        }
コード例 #38
0
ファイル: FamilyType.cs プロジェクト: kscalvin/Dynamo
 private static FScheme.Value _getParam(FamilySymbol fi, Parameter p)
 {
     if (p.StorageType == StorageType.Double)
     {
         return FScheme.Value.NewNumber(p.AsDouble());
     }
     else if (p.StorageType == StorageType.Integer)
     {
         return FScheme.Value.NewNumber(p.AsInteger());
     }
     else if (p.StorageType == StorageType.String)
     {
         return FScheme.Value.NewString(p.AsString());
     }
     else
     {
         return FScheme.Value.NewContainer(p.AsElementId());
     }
 }
コード例 #39
0
ファイル: FamilyInstance.cs プロジェクト: parchjs/Dynamo
 private static Value _getParam(Parameter p)
 {
     switch (p.StorageType)
     {
         case StorageType.ElementId:
             return Value.NewContainer(p.AsElementId());
         case StorageType.String:
             return Value.NewString(p.AsString());
         case StorageType.Integer:
         case StorageType.Double:
             switch (p.Definition.ParameterType)
         {
             case ParameterType.Length:
                 return Value.NewContainer(Units.Length.FromFeet(p.AsDouble(), dynSettings.Controller.UnitsManager));
             case ParameterType.Area:
                 return Value.NewContainer(Units.Area.FromSquareFeet(p.AsDouble(), dynSettings.Controller.UnitsManager));
             case ParameterType.Volume:
                 return Value.NewContainer(Units.Volume.FromCubicFeet(p.AsDouble(), dynSettings.Controller.UnitsManager));
             default:
                 return Value.NewNumber(p.AsDouble());
         }
         default:
             throw new Exception(string.Format("Parameter {0} has no storage type.", p));
     }
 }
コード例 #40
0
    /// <summary>
    /// Helper function: return a string form of a given parameter.
    /// </summary>
    public static string ParameterToString(Parameter param)
    {
      string val = "none";

      if (param == null)
      {
        return val;
      }

      // To get to the parameter value, we need to pause it depending on its storage type 

      switch (param.StorageType)
      {
        case StorageType.Double:
          double dVal = param.AsDouble();
          val = dVal.ToString();
          break;
        case StorageType.Integer:
          int iVal = param.AsInteger();
          val = iVal.ToString();
          break;
        case StorageType.String:
          string sVal = param.AsString();
          val = sVal;
          break;
        case StorageType.ElementId:
          ElementId idVal = param.AsElementId();
          val = idVal.IntegerValue.ToString();
          break;
        case StorageType.None:
          break;
      }
      return val;
    }