コード例 #1
0
        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);
        }
コード例 #2
0
 public static string ToJSON(SerialParameter parameter)
 {
     return(Newtonsoft.Json.JsonConvert.SerializeObject(parameter, Formatting.Indented));
 }