添加项目文件。
This commit is contained in:
55
Szmedi.RvKits/ModelManager/GetMaterialInfoByName.cs
Normal file
55
Szmedi.RvKits/ModelManager/GetMaterialInfoByName.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
using Autodesk.Revit.Attributes;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Visual;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace Szmedi.RvKits.ModelManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Revit执行命令
|
||||
/// </summary>
|
||||
[Transaction(TransactionMode.Manual)]
|
||||
|
||||
public class GetMaterialInfoByName : ExternalCommand
|
||||
{
|
||||
public override void Execute()
|
||||
{
|
||||
var materials = new FilteredElementCollector(Document).OfClass(typeof(Material)).ToElements().Cast<Material>();
|
||||
StringBuilder sb = new();
|
||||
|
||||
foreach (var material in materials)
|
||||
{
|
||||
if (Document.GetElement(material.AppearanceAssetId) is AppearanceAssetElement assetElem)
|
||||
{
|
||||
var asset = assetElem.GetRenderingAsset();
|
||||
var prop = asset.FindByName("generic_self_illum_luminance");
|
||||
var d = prop as AssetPropertyDouble;
|
||||
if (d?.Value > 0)
|
||||
{
|
||||
sb.AppendLine(material.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
WriteTxt("发光材质", sb.ToString());
|
||||
//TaskDialog.Show("查找结果", $"{sb}");
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteTxt(string fileName, string message)
|
||||
{
|
||||
var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), $"{fileName}.txt");
|
||||
File.WriteAllText(filePath, message);
|
||||
System.Diagnostics.Process.Start(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user