整理代码
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using System.IO;
|
||||
|
||||
using System.Windows.Media.Imaging;
|
||||
using ShrlAlgo.Toolkit.Core.Assist;
|
||||
using ShrlAlgoToolkit.Core.Assist;
|
||||
using ShrlAlgoToolkit.Core.Extensions;
|
||||
|
||||
namespace ShrlAlgo.RvKits.RvFamily.FamilyLibrary;
|
||||
|
||||
public partial class FamilyModel : ObservableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 族库缩略图
|
||||
/// </summary>
|
||||
public BitmapSource ImageData => ImageExtensions.LoadFileImage(Path, 128, 128);
|
||||
|
||||
/// <summary>
|
||||
/// 最近使用面板
|
||||
/// </summary>
|
||||
public BitmapImage BitmapImage { get; set; }
|
||||
|
||||
public FileInfo FileInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 族库文件标题
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
public Family ReferenceFamily { get; set; }
|
||||
public string ToolTip { get; set; }
|
||||
public UIApplication UiApplication { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string RevitVersion { get; set; }
|
||||
public ElementId FamilyId => ReferenceFamily.Id;
|
||||
|
||||
//private bool CanPlace()
|
||||
//{
|
||||
// uiApplication.ActiveUIDocument.Document.is
|
||||
// return ReferenceFamily.IsValidObject;
|
||||
// .IsValidObject = true;
|
||||
//}
|
||||
|
||||
[RelayCommand]
|
||||
private static void PlaceRecentFamily(object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (obj is FamilyModel { ReferenceFamily: { } family } info)
|
||||
{
|
||||
var uidoc = info.UiApplication.ActiveUIDocument;
|
||||
var doc = uidoc.Document;
|
||||
|
||||
if (family.IsValidObject && doc.PathName == family.Document.PathName)
|
||||
{
|
||||
var fs = doc.GetElement(family.GetFamilySymbolIds().FirstOrDefault()) as FamilySymbol;
|
||||
uidoc.PostRequestForElementTypePlacement(fs);
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// var docs = info.uiApplication.Application.Documents;
|
||||
// foreach (Document d in docs)
|
||||
// {
|
||||
// if (d.PathName == family.Document.PathName)
|
||||
// {
|
||||
// List<ElementId> list = new List<ElementId>()
|
||||
// {
|
||||
// family.ViewId
|
||||
// };
|
||||
// doc.Invoke(ts =>
|
||||
// {
|
||||
// ElementTransformUtils.CopyElements(d, list, doc, null, new CopyPasteOptions());
|
||||
// },"复制族");
|
||||
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
catch (Autodesk.Revit.Exceptions.OperationCanceledException) { }
|
||||
catch (Exception e)
|
||||
{
|
||||
e.ToLog();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user