Ejemplo n.º 1
0
        public static ElementParameter GetParameter(this Parameter p, Document doc)
        {
            var param = new ElementParameter
            {
                Id    = p.Id.IntegerValue,
                Name  = p.Definition.Name,
                Value = ParameterUtils.ParameterToString(doc, p)
            };

            if (p.IsShared)
            {
                param.Guid = p.GUID.ToString().TrimStart('{').TrimEnd('}');
            }
            return(param);
        }
Ejemplo n.º 2
0
        private Model GetFamilyData()
        {
            var model = new FamilyModel {
                Name = _name, Filepath = _filePath
            };

            //todo
            var fam      = _fam;
            var doc      = _doc;
            var paramSet = fam.Parameters.ForwardIterator();

            //var paramList = new List<ElementParameter>();
            while (paramSet.MoveNext())
            {
                var p     = (Parameter)paramSet.Current;
                var name  = p.Definition.Name;
                var value = ParameterUtils.ParameterToString(doc, p);
                if (String.IsNullOrWhiteSpace(value))
                {
                    value = "空";
                }
                var mfP = new ElementParameter {
                    Id = p.Id.IntegerValue, Name = name, Value = value
                };
                if (p.IsShared)
                {
                    mfP.Guid = p.GUID.ToString();
                }
                model.Parameters.Add(mfP);
            }
            var type      = doc.FamilyManager.CurrentType;
            var famParams = doc.FamilyManager.Parameters;

            //var typeParamList = new List<ElementParameter>();
            if (famParams != null)
            {
                var famIter = famParams.ForwardIterator();

                while (famIter.MoveNext())
                {
                    var p     = (FamilyParameter)famIter.Current;
                    var pDef  = p.Definition;
                    var name  = pDef.Name;
                    var value = ParameterUtils.ParameterToString(doc, p, type);
                    if (String.IsNullOrWhiteSpace(value))
                    {
                        value = "空";
                    }
                    var param = new ElementParameter {
                        Id = p.Id.IntegerValue, Name = name, Value = value
                    };
                    if (p.IsShared)
                    {
                        param.Guid = p.GUID.ToString();
                    }
                    model.FamParameters.Add(param);
                }
            }

            Category cate = null;

            if (fam.Category != null)
            {
                cate = fam.Category;
            }
            if (fam.FamilyCategory != null)
            {
                cate = fam.FamilyCategory;
            }
            if (cate != null)
            {
                model.Category = new ElementCategory {
                    Id = cate.Id.IntegerValue, Name = cate.Name
                };
            }

            model.Family = fam.GetFamily(doc);

            return(_model = model);
        }