72 lines
2.0 KiB
C#
72 lines
2.0 KiB
C#
using Autodesk.Revit.DB;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
namespace Szmedi.RvKits.FamilyTools
|
|
{
|
|
public class ParaViewModel
|
|
{
|
|
public Dictionary<string, FamilyType> Types { get; set; }
|
|
private Document famDoc { get; }
|
|
private FamilyType familytype { get; }
|
|
|
|
|
|
public ObservableCollection<ParaModel> Parameters { get; set; }
|
|
|
|
public ParaViewModel(Document doc)
|
|
{
|
|
Types = GetTypes(doc);
|
|
}
|
|
|
|
public ParaViewModel(Document doc, FamilyType ft)
|
|
{
|
|
famDoc = doc;
|
|
familytype = ft;
|
|
Parameters = CreateParasData();
|
|
}
|
|
|
|
private Dictionary<string, FamilyType> GetTypes(Document doc)
|
|
{
|
|
Dictionary<string, FamilyType> dictTypes = new();
|
|
|
|
FamilyTypeSet ftset = doc.FamilyManager.Types;
|
|
//var fts = from FamilyType ft in vm
|
|
// where ft.Name!=" "
|
|
// select ft;
|
|
//return fts;
|
|
foreach (FamilyType ft in ftset)
|
|
{
|
|
if (ft.Name != " ")
|
|
{
|
|
dictTypes.Add(ft.Name, ft);
|
|
}
|
|
}
|
|
|
|
return dictTypes;
|
|
}
|
|
|
|
private ObservableCollection<ParaModel> CreateParasData()
|
|
{
|
|
return GetParas(famDoc, familytype);
|
|
}
|
|
|
|
private ObservableCollection<ParaModel> GetParas(Document doc, FamilyType familytype)
|
|
{
|
|
ObservableCollection<ParaModel> paraModels = new();
|
|
FamilyParameterSet paras = doc.FamilyManager.Parameters;
|
|
foreach (FamilyParameter para in paras)
|
|
{
|
|
ParaModel model = new()
|
|
{
|
|
Name = para.Definition.Name,
|
|
Value = familytype.AsValueString(para),
|
|
Formula = para.Formula,
|
|
Group = LabelUtils.GetLabelFor(para.Definition.ParameterGroup)
|
|
};
|
|
paraModels.Add(model);
|
|
}
|
|
|
|
return paraModels;
|
|
}
|
|
}
|
|
} |