Files
SzmediTools/Szmedi.RevitToolkit.Approval/Converters/ElementToElementTypeNameConverter.cs
2025-09-16 16:06:41 +08:00

35 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using Autodesk.Revit.DB;
namespace Szmedi.RevitToolkit.Approval.Converters
{
class ElementToElementTypeNameConverter : IValueConverter
{
public static readonly ElementToElementTypeNameConverter Instance = new ElementToElementTypeNameConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is Element element)
{
if (element.GetTypeId() != ElementId.InvalidElementId)
{
var type = element.Document.GetElement(element.GetTypeId()) as ElementType;
return type.FamilyName;
}
}
return System.Windows.Data.Binding.DoNothing; // 如果不是Element类型或没有类型ID则返回Binding.DoNothing
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}