修改命名空间
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace ShrlAlgoToolkit.RevitCore.Extensions
|
||||
{
|
||||
public static class ApplicationExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示窗口
|
||||
/// </summary>
|
||||
/// <param name="window"></param>
|
||||
/// <param name="handle"></param>
|
||||
public static void Show(this Window window, IntPtr handle)
|
||||
{
|
||||
// ReSharper disable once ObjectCreationAsStatement
|
||||
_ = new WindowInteropHelper(window) { Owner = handle };
|
||||
window.Show();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新建族文档
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <param name="templateFileName">族样板文件名,不含扩展</param>
|
||||
/// <returns></returns>
|
||||
public static Document NewFamilyDoc(
|
||||
this Autodesk.Revit.ApplicationServices.Application app,
|
||||
string templateFileName)
|
||||
{
|
||||
var dir = $"{app.FamilyTemplatePath}";
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
dir = Path.Combine($@"C:\ProgramData\Autodesk\RVT {app.VersionNumber}", @"Family Templates\Chinese");
|
||||
if(!Directory.Exists(dir))
|
||||
{
|
||||
throw new InvalidOperationException("未找到族样板路径");
|
||||
}
|
||||
}
|
||||
//查找路径下templateFileName文件
|
||||
var files = Directory.GetFiles(dir, $"{templateFileName}.rft", SearchOption.AllDirectories);
|
||||
if (files.Length > 0)
|
||||
{
|
||||
return app.NewFamilyDocument(files[0]);
|
||||
}
|
||||
throw new InvalidOperationException("未找到该族样板");
|
||||
//var tempatePath = $"{app.FamilyTemplatePath}\\{templateFileName}.rft";
|
||||
//if(!File.Exists(tempatePath))
|
||||
//{
|
||||
// tempatePath = Path.Combine(
|
||||
// $@"C:\ProgramData\Autodesk\RVT {app.VersionNumber}",
|
||||
// @"Family Templates\Chinese",
|
||||
// $"{templateFileName}.rft");
|
||||
// if(!File.Exists(tempatePath))
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
//return app.NewFamilyDocument(tempatePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user