添加项目文件。
This commit is contained in:
86
Szmedi.RvKits/FamilyTools/SelectFamilySymbol.xaml.cs
Normal file
86
Szmedi.RvKits/FamilyTools/SelectFamilySymbol.xaml.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
using Szmedi.RvKits.FamilyTools;
|
||||
|
||||
namespace Szmedi.RvKits.FamilyLibrary
|
||||
{
|
||||
/// <summary>
|
||||
/// SelectFamilySymbol.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class SelectFamilySymbol
|
||||
{
|
||||
private readonly Document doc;
|
||||
private readonly string path;
|
||||
private readonly UIDocument uidoc;
|
||||
private FamilySymbol fs;
|
||||
private List<SymbolModel> ss;
|
||||
private string fsname;
|
||||
|
||||
public SelectFamilySymbol(UIApplication uiapp, string path, List<SymbolModel> symbols)
|
||||
{
|
||||
uidoc = uiapp.ActiveUIDocument;
|
||||
doc = uidoc.Document;
|
||||
this.path = path;
|
||||
ss = symbols;
|
||||
InitializeComponent();
|
||||
CBSel.ItemsSource = symbols;
|
||||
}
|
||||
|
||||
private void CBSel_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
fsname = CBSel.SelectedValue.ToString();
|
||||
}
|
||||
|
||||
private void LoadAllBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FamilyLoadOption familyLoadOption = new();
|
||||
Family family = null;
|
||||
|
||||
using (Transaction trans = new(doc))
|
||||
{
|
||||
trans.Start("载入族-" + System.IO.Path.GetFileNameWithoutExtension(path));
|
||||
|
||||
doc.LoadFamily(path, familyLoadOption, out family);
|
||||
|
||||
foreach (var symbolId in family.GetFamilySymbolIds())
|
||||
{
|
||||
fs = doc.GetElement(symbolId) as FamilySymbol;
|
||||
if (!fs.IsActive)
|
||||
{
|
||||
fs.Activate();
|
||||
}
|
||||
}
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
|
||||
Close();
|
||||
uidoc.PromptForFamilyInstancePlacement(fs);
|
||||
}
|
||||
|
||||
private void LoadSpecifyBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (fsname != null)
|
||||
{
|
||||
using (Transaction trans = new(doc))
|
||||
{
|
||||
trans.Start("载入族类型-" + System.IO.Path.GetFileNameWithoutExtension(path) + "_" + fsname);
|
||||
doc.LoadFamilySymbol(path, fsname, out fs);
|
||||
if (!fs.IsActive)
|
||||
{
|
||||
fs.Activate();
|
||||
}
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
|
||||
Close();
|
||||
uidoc.PromptForFamilyInstancePlacement(fs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user