private string GetParameterValueById(Element element, ElementId paramId)
        {
            if (element == null)
            {
                return(string.Empty);
            }

            Parameter parameter = null;

            if (ParameterUtils.IsBuiltInParameter(paramId))
            {
                parameter = element.get_Parameter((BuiltInParameter)paramId.IntegerValue);
            }
            else
            {
                ParameterElement parameterElem = element.Document.GetElement(paramId) as ParameterElement;
                if (parameterElem == null)
                {
                    return(string.Empty);
                }
                parameter = element.get_Parameter(parameterElem.GetDefinition());
            }

            return(parameter?.AsValueString() ?? string.Empty);
        }
        public static RevitElem ModifyParameter(SerialParameter serialParameter, RevitElem Elem)
        {
            RevitParam param = null;
            RevitDoc   doc   = Elem.Document;

            if (serialParameter.IsShared)
            {
                param = Elem.get_Parameter(new Guid(serialParameter.GUID));
            }
            else if (serialParameter.Id < 0)
            {
                param = Elem.get_Parameter((BuiltInParameter)serialParameter.Id);
            }
            else if (serialParameter.Id > 0)
            {
                ParameterElement paramElem = (ParameterElement)doc.GetElement(new ElementId(serialParameter.Id));
                if (paramElem != null)
                {
                    Definition def = paramElem.GetDefinition();
                    param = Elem.get_Parameter(def);
                }
            }

            if (param != null && !param.IsReadOnly)
            {
                switch (serialParameter.StorageType)
                {
                case "Double":
                    param.Set(Convert.ToDouble(serialParameter.Value));
                    break;

                case "ElementId":
                    SerialParameter._ModifyElementIdParameter(param, serialParameter.ValueElemId, doc);
                    break;

                case "Integer":
                    param.Set(Convert.ToInt32(serialParameter.Value));
                    break;

                case "String":
                default:
                    param.Set(serialParameter.Value);
                    break;
                }
            }

            return(Elem);
        }
Exemple #3
0
        public static RevitElem ModifyParameter(ParameterJSON paramJSON, RevitElem Elem)
        {
            RevitParam param = null;

            if (paramJSON.IsShared)
            {
                param = Elem.get_Parameter(new Guid(paramJSON.GUID));
            }
            else if (paramJSON.Id < 0)
            {
                param = Elem.get_Parameter((BuiltInParameter)paramJSON.Id);
            }
            else if (paramJSON.Id > 0)
            {
                revitDoc         doc       = Elem.Document;
                ParameterElement paramElem = (ParameterElement)doc.GetElement(new ElementId(paramJSON.Id));
                if (paramElem != null)
                {
                    Definition def = paramElem.GetDefinition();
                    param = Elem.get_Parameter(def);
                }
            }

            if (param != null && !param.IsReadOnly)
            {
                switch (paramJSON.StorageType)
                {
                case "Double":
                    param.Set(Convert.ToDouble(paramJSON.Value));
                    break;

                case "ElementId":
                    param.Set(new ElementId(Convert.ToInt32(paramJSON.Value)));
                    break;

                case "Integer":
                    param.Set(Convert.ToInt32(paramJSON.Value));
                    break;

                case "String":
                default:
                    param.Set(paramJSON.Value);
                    break;
                }
            }

            return(Elem);
        }
        private void Stream( ArrayList data, ParameterElement paramElem )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( ParameterElement ) ) );

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

              SharedParameterElement sharedParamElem = paramElem as SharedParameterElement;
              if( sharedParamElem != null )
              {
            Stream( data, sharedParamElem );
            return;
              }
        }