更新
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
using ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
|
||||
using System.Windows.Interop;
|
||||
@@ -22,15 +23,46 @@ namespace ShrlAlgoToolkit.Revit.Extensions
|
||||
_ = new WindowInteropHelper(window) { Owner = handle };
|
||||
window.Show();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新建族文档
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <param name="templateFileName">族样板文件名,不含扩展</param>
|
||||
/// <returns></returns>
|
||||
public static Document NewFamilyDocument(this Autodesk.Revit.ApplicationServices.Application app, string templateFileName)
|
||||
public static Document NewFamilyDoc(
|
||||
this Autodesk.Revit.ApplicationServices.Application app,
|
||||
string templateFileName)
|
||||
{
|
||||
return app.NewFamilyDocument($"{app.FamilyTemplatePath}\\{templateFileName}.rft");
|
||||
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