添加项目文件。

This commit is contained in:
GG Z
2024-09-22 11:05:41 +08:00
parent fb5d55723a
commit 49ceaae6a8
764 changed files with 78850 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Data;
using Autodesk.Revit.DB;
using Sai.Toolkit.Mvvm;
namespace Sai.RvKits.Converters
{
public class IdToNameConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (parameter is BindingProxy proxy && proxy.Data is Document document && value is ElementId id && (id != ElementId.InvalidElementId))
{
return document.GetElement(id).Name;
}
return System.Windows.Data.Binding.DoNothing;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Globalization;
using System.Windows.Data;
using Color = System.Windows.Media.Color;
namespace Sai.RvKits.Converters;
/// <summary>
/// Autodesk颜色转Windows系统颜色
/// </summary>
public class Rv2WinColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var color = (Autodesk.Revit.DB.Color)value;
//if (Autodesk.Revit.DB.SelectedColor.InvalidColorValue)
//{
//}
if (color is { IsValid: true })
{
var rgb = Color.FromRgb(color.Red, color.Green, color.Blue);
return rgb;
}
return new Color();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is Color rgb ? new Autodesk.Revit.DB.Color(rgb.R, rgb.G, rgb.B) : (object)Autodesk.Revit.DB.Color.InvalidColorValue;
}
}

View File

@@ -0,0 +1,31 @@
using System;
using Autodesk.Revit.DB;
namespace Sai.RvKits.Converters;
public static class RvConverters
{
public static Element ToElement(this ElementId elementId, Document doc)
{
return doc.GetElement(elementId);
}
public static Category ToCategory(this BuiltInCategory builtInCategory, Document doc)
{
return Category.GetCategory(doc, builtInCategory);
}
public static BuiltInCategory ToBuiltInCategory(this Category category)
{
#if REVIT2018 || REVIT2020
var builtInCategory = (BuiltInCategory)category.Id.IntegerValue;
#elif REVIT2025
var builtInCategory = (BuiltInCategory)category.Id.Value;
#endif
return Enum.IsDefined(typeof(BuiltInCategory), builtInCategory)
? builtInCategory
: throw new ArgumentNullException(nameof(category), "不存在该内建类别");
}
}

View File

@@ -0,0 +1,95 @@
using System.Globalization;
using System.Windows.Data;
using Autodesk.Revit.DB;
namespace Sai.RvKits.Converters
{
public class RvEnumConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{ return RvEnumConverter.GetChineseName(value); }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{ throw new NotImplementedException(); }
private static string GetChineseName(object obj)
{
#if REVIT2018
if (obj is BuiltInParameter parameter)
{
return LabelUtils.GetLabelFor(parameter);
}
else if (obj is BuiltInParameterGroup group)
{
return LabelUtils.GetLabelFor(group);
}
else if (obj is UnitType uType)
{
return LabelUtils.GetLabelFor(uType);
}
else if (obj is ParameterType pType)
{
return LabelUtils.GetLabelFor(pType);
}
#elif REVIT2020
if (obj is BuiltInParameter parameter)
{
return LabelUtils.GetLabelFor(parameter, Autodesk.Revit.ApplicationServices.LanguageType.Chinese_Simplified);
}
else if (obj is BuiltInCategory category)
{
return LabelUtils.GetLabelFor(category);
}
else if (obj is BuiltInParameterGroup group)
{
return LabelUtils.GetLabelFor(group);
}
else if (obj is UnitType uType)
{
return LabelUtils.GetLabelFor(uType);
}
else if (obj is ParameterType pType)
{
return LabelUtils.GetLabelFor(pType);
}
#elif REVIT2025
if (obj is BuiltInParameter parameter)
{
return LabelUtils.GetLabelFor(
parameter,
Autodesk.Revit.ApplicationServices.LanguageType.Chinese_Simplified);
}
else if (obj is BuiltInCategory category)
{
return LabelUtils.GetLabelFor(category);
}
else if (obj is ForgeTypeId forgeTypeId)
{
if (UnitUtils.IsSymbol(forgeTypeId))
{
return LabelUtils.GetLabelForSymbol(forgeTypeId);
}
else if (SpecUtils.IsSpec(forgeTypeId))
{
return LabelUtils.GetLabelForSpec(forgeTypeId);
}
else if (UnitUtils.IsUnit(forgeTypeId))
{
return LabelUtils.GetLabelForUnit(forgeTypeId);
}
else if (ParameterUtils.IsBuiltInGroup(forgeTypeId))
{
return LabelUtils.GetLabelForGroup(forgeTypeId);
}
else if (UnitUtils.GetDiscipline(forgeTypeId).IsValidObject)
{
return LabelUtils.GetLabelForDiscipline(forgeTypeId);
}
}
#endif
return string.Empty;
}
}
}

View File

@@ -0,0 +1,42 @@
using System.Windows.Controls;
using System.Windows.Data;
namespace Sai.RvKits.Converters
{
public class SearchTypeValueConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var cellText = values[0] == null ? string.Empty : values[0].ToString();
var searchText = values[1] as string;
var cell = values[2] as DataGridCell;
var head = cell?.Column?.Header?.ToString();
return head is "族类型" && !string.IsNullOrEmpty(searchText) && !string.IsNullOrEmpty(cellText) ? cellText.Contains(searchText) : (object)false;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
}
public class SearchFamilyValueConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var cellText = values[0] == null ? string.Empty : values[0].ToString();
var searchText = values[1] as string;
var cell = values[2] as DataGridCell;
var head = cell?.Column?.Header?.ToString();
return head is "族名称" && !string.IsNullOrEmpty(searchText) && !string.IsNullOrEmpty(cellText) ? cellText.Contains(searchText) : (object)false;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
}
}