大量更新
This commit is contained in:
@@ -17,7 +17,6 @@ namespace Szmedi.RvKits.InfoManager.AFCA
|
||||
/// 报批报建
|
||||
/// </summary>
|
||||
[Transaction(TransactionMode.Manual)]
|
||||
[Regeneration(RegenerationOption.Manual)]
|
||||
public class AFCAMetroCmd : ExternalCommand
|
||||
{
|
||||
private static readonly string DbString = $"Data Source={GlobalVariables.DirAssembly}\\SZBIM.db";
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace Szmedi.RvKits.InfoManager.EAMTools
|
||||
/// Revit执行命令
|
||||
/// </summary>
|
||||
[Transaction(TransactionMode.Manual)]
|
||||
[Regeneration(RegenerationOption.Manual)]
|
||||
public class EAMCodeCheckCmd : ExternalCommand
|
||||
{
|
||||
public override void Execute()
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
@@ -14,23 +12,16 @@ using Nice3point.Revit.Toolkit.External.Handlers;
|
||||
|
||||
using OfficeOpenXml;
|
||||
|
||||
using Szmedi.RvKits.InfoManager.EAMTools;
|
||||
|
||||
namespace Szmedi.RvKits.InfoManager
|
||||
namespace Szmedi.RvKits.InfoManager.EAMTools
|
||||
{
|
||||
public partial class EAMCodeCheckViewModel : ObservableObject
|
||||
{
|
||||
private readonly ActionEventHandler handler;
|
||||
[ObservableProperty]
|
||||
private List<EAMData> currentFacilities;
|
||||
[ObservableProperty]
|
||||
private List<InstanceFacility> instances;
|
||||
[ObservableProperty]
|
||||
private string selectedStation;
|
||||
[ObservableProperty]
|
||||
private List<string> facilitySystems;
|
||||
[ObservableProperty]
|
||||
private string selectedSystem;
|
||||
[ObservableProperty] private List<EAMData> currentFacilities;
|
||||
[ObservableProperty] private List<InstanceFacility> instances;
|
||||
[ObservableProperty] private string selectedStation;
|
||||
[ObservableProperty] private List<string> facilitySystems;
|
||||
[ObservableProperty] private string selectedSystem;
|
||||
|
||||
public EAMCodeCheckViewModel(Document doc)
|
||||
{
|
||||
@@ -44,12 +35,10 @@ namespace Szmedi.RvKits.InfoManager
|
||||
try
|
||||
{
|
||||
var list = doc.OfClass<FamilyInstance>()
|
||||
.Where(
|
||||
e => e.Category.AllowsBoundParameters &&
|
||||
e.Category.CategoryType == CategoryType.Model &&
|
||||
!Enum.GetName(typeof(BuiltInCategory), e.Category.Id.IntegerValue)!.Contains("Fitting") &&
|
||||
e.Category.CategoryType == CategoryType.Model &&
|
||||
e.Category.Id.IntegerValue != -2008013) //风道末端
|
||||
.Where(e => e.Category.AllowsBoundParameters &&
|
||||
!Enum.GetName(typeof(BuiltInCategory), e.Category.Id.IntegerValue)!.Contains("Fitting") &&
|
||||
e.Category.CategoryType == CategoryType.Model &&
|
||||
e.Category.Id.IntegerValue != -2008013) //风道末端
|
||||
.Cast<FamilyInstance>()
|
||||
.OrderBy(ins => ins.Name)
|
||||
.Select(ins => new InstanceFacility(ins));
|
||||
@@ -57,7 +46,7 @@ namespace Szmedi.RvKits.InfoManager
|
||||
Facilities = package.ToList<EAMData>(1, configuration => configuration.SkipCastingErrors());
|
||||
var group = Facilities.GroupBy(fa => fa.StationName).OrderBy(g => g.Key);
|
||||
Stations = [.. group.Select(g => g.Key)];
|
||||
Regex regex = new Regex(@"-(\D+站|所|段|场)-");
|
||||
var regex = new Regex(@"-(\D+站|所|段|场)-");
|
||||
var result = regex.Matches(doc.PathName).Cast<Match>().Select(m => m.Groups[1].Value).FirstOrDefault();
|
||||
if (result != null && Stations.Contains(result))
|
||||
{
|
||||
@@ -66,13 +55,12 @@ namespace Szmedi.RvKits.InfoManager
|
||||
}
|
||||
catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException)
|
||||
{
|
||||
System.Windows.MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行。");
|
||||
MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行。");
|
||||
}
|
||||
finally
|
||||
{
|
||||
AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomainOnAssemblyResolve;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -82,6 +70,7 @@ namespace Szmedi.RvKits.InfoManager
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var EAMData in CurrentFacilities)
|
||||
{
|
||||
//var b = Instances.Any(ins => ins.Number.Contains(EAMData.EAMCode));
|
||||
@@ -95,9 +84,11 @@ namespace Szmedi.RvKits.InfoManager
|
||||
}
|
||||
}
|
||||
}
|
||||
CurrentFacilities = [.. CurrentFacilities.OrderBy(fa => fa.IsMapped)];
|
||||
Instances = [.. Instances.OrderBy(ins => ins.IsMapped)];
|
||||
|
||||
CurrentFacilities = [.. Enumerable.OrderBy<EAMData, bool?>(CurrentFacilities, fa => fa.IsMapped)];
|
||||
Instances = [.. Enumerable.OrderBy<InstanceFacility, bool?>(Instances, ins => ins.IsMapped)];
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void ShowFacility(object obj)
|
||||
{
|
||||
@@ -109,7 +100,7 @@ namespace Szmedi.RvKits.InfoManager
|
||||
handler.Raise(uiapp =>
|
||||
{
|
||||
var uidoc = uiapp.ActiveUIDocument;
|
||||
Document doc = uidoc.Document;
|
||||
var doc = uidoc.Document;
|
||||
|
||||
if (!model.Instance.IsValidObject)
|
||||
{
|
||||
@@ -140,15 +131,19 @@ namespace Szmedi.RvKits.InfoManager
|
||||
uidoc.Selection.SetElementIds([model.Instance.Id]);
|
||||
});
|
||||
}
|
||||
|
||||
private static bool IsVisible(ElementId viewId, Element elem)
|
||||
{
|
||||
if (FilteredElementCollector.IsViewValidForElementIteration(elem.Document, viewId)) // 某类视图不能使用 FilteredElementCollector
|
||||
if (FilteredElementCollector.IsViewValidForElementIteration(elem.Document,
|
||||
viewId)) // 某类视图不能使用 FilteredElementCollector
|
||||
{
|
||||
var fec = new FilteredElementCollector(elem.Document, viewId).ToElementIds();
|
||||
return fec.Any(id => id == elem.Id);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Assembly CurrentDomainOnAssemblyResolve(object sender, ResolveEventArgs args)
|
||||
{
|
||||
if (!args.Name.Contains("ComponentModel.Annotations"))
|
||||
@@ -156,7 +151,7 @@ namespace Szmedi.RvKits.InfoManager
|
||||
return null;
|
||||
}
|
||||
|
||||
string assemblyFile = Path.Combine(GlobalVariables.DirAssembly, "System.ComponentModel.Annotations.dll");
|
||||
var assemblyFile = Path.Combine(GlobalVariables.DirAssembly, "System.ComponentModel.Annotations.dll");
|
||||
return File.Exists(assemblyFile) ? Assembly.LoadFrom(assemblyFile) : null;
|
||||
}
|
||||
|
||||
@@ -165,12 +160,13 @@ namespace Szmedi.RvKits.InfoManager
|
||||
if (!string.IsNullOrEmpty(newValue))
|
||||
{
|
||||
CurrentFacilities = Facilities.Where(fa => fa.StationName == newValue).ToList();
|
||||
var group = CurrentFacilities.GroupBy(fa => fa.System);
|
||||
var group = Enumerable.GroupBy<EAMData, string>(CurrentFacilities, fa => fa.System);
|
||||
|
||||
FacilitySystems = [.. group.Select(g => g.Key)];
|
||||
FacilitySystems.Insert(0, "<请选择系统>");
|
||||
}
|
||||
}
|
||||
|
||||
partial void OnSelectedSystemChanged(string oldValue, string newValue)
|
||||
{
|
||||
if (newValue == "<请选择系统>")
|
||||
@@ -178,15 +174,15 @@ namespace Szmedi.RvKits.InfoManager
|
||||
CurrentFacilities = Facilities.Where(fa => fa.System == newValue).ToList();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(newValue))
|
||||
{
|
||||
CurrentFacilities = CurrentFacilities.Where(fa => fa.System == newValue).ToList();
|
||||
CurrentFacilities = Enumerable.Where<EAMData>(CurrentFacilities, fa => fa.System == newValue).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<EAMData> Facilities { get; }
|
||||
public List<string> Stations { get; }
|
||||
|
||||
}
|
||||
|
||||
public class EAMData : ObservableObject
|
||||
@@ -195,6 +191,7 @@ namespace Szmedi.RvKits.InfoManager
|
||||
|
||||
[ExcelTableColumn("是否匹配", true)]
|
||||
public bool? IsMapped { get => isMapped; set => SetProperty(ref isMapped, value); }
|
||||
|
||||
/// <summary>
|
||||
/// 线路名称
|
||||
/// </summary>
|
||||
|
||||
@@ -397,7 +397,6 @@ public partial class EAMCodingViewModel : ObservableObject
|
||||
.OfClass(typeof(FamilyInstance))
|
||||
.Where(i =>
|
||||
i.Category.AllowsBoundParameters
|
||||
&& i.Category.CategoryType == CategoryType.Model
|
||||
&& !Enum.GetName(typeof(BuiltInCategory), i.Category.Id.IntegerValue)!.Contains("Fitting")
|
||||
&& i.Category.CategoryType == CategoryType.Model
|
||||
//风道末端
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
Width="1280"
|
||||
Height="700"
|
||||
d:DataContext="{d:DesignInstance Type=local1:EAMCodingViewModel}"
|
||||
|
||||
mc:Ignorable="d">
|
||||
<controls:MaterialWindow.Resources>
|
||||
<ResourceDictionary Source="pack://application:,,,/Szmedi.RvKits;component/WPFUI.xaml" />
|
||||
@@ -42,7 +41,10 @@
|
||||
</b:EventTrigger>
|
||||
</b:Interaction.Triggers>
|
||||
<DataGrid.Columns>
|
||||
<DataGridCheckBoxColumn Binding="{Binding IsMapped}" ElementStyle="{StaticResource MaterialDesignDataGridCheckBoxColumnStyle}" Header="是否匹配" />
|
||||
<DataGridCheckBoxColumn
|
||||
Binding="{Binding IsMapped}"
|
||||
ElementStyle="{StaticResource MaterialDesignDataGridCheckBoxColumnStyle}"
|
||||
Header="是否匹配" />
|
||||
<DataGridTextColumn Binding="{Binding Id}" Header="元素Id" />
|
||||
<DataGridTextColumn Binding="{Binding CategoryName}" Header="类别" />
|
||||
<DataGridTextColumn Binding="{Binding FamilyName}" Header="族名称" />
|
||||
@@ -75,7 +77,10 @@
|
||||
Width="2"
|
||||
HorizontalAlignment="Stretch" />
|
||||
|
||||
<GroupBox Grid.Row="0" Grid.Column="2" Header="EAM设备表">
|
||||
<GroupBox
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
Header="EAM设备表">
|
||||
<Grid>
|
||||
<DataGrid
|
||||
AutoGenerateColumns="False"
|
||||
@@ -88,7 +93,10 @@
|
||||
</b:EventTrigger>
|
||||
</b:Interaction.Triggers>
|
||||
<DataGrid.Columns>
|
||||
<DataGridCheckBoxColumn Binding="{Binding IsMapped}" ElementStyle="{StaticResource MaterialDesignDataGridCheckBoxColumnStyle}" Header="是否匹配" />
|
||||
<DataGridCheckBoxColumn
|
||||
Binding="{Binding IsMapped}"
|
||||
ElementStyle="{StaticResource MaterialDesignDataGridCheckBoxColumnStyle}"
|
||||
Header="是否匹配" />
|
||||
<DataGridTextColumn Binding="{Binding FixedAssetsName}" Header="固定资产名称" />
|
||||
<DataGridTextColumn Binding="{Binding Story}" Header="楼层" />
|
||||
<DataGridTextColumn Binding="{Binding FunctionLocation}" Header="功能位置" />
|
||||
@@ -102,7 +110,10 @@
|
||||
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3">
|
||||
<Grid
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
@@ -138,21 +149,45 @@
|
||||
Foreground="{DynamicResource MaterialDesign.Brush.Foreground}"
|
||||
IsReadOnly="True"
|
||||
Text="{Binding ExcelPath, Mode=OneWay}" />
|
||||
<Button Grid.Column="1" Command="{Binding OpenEAMFileCommand}" Style="{StaticResource MaterialDesignToolButton}">
|
||||
<md:PackIcon Kind="MicrosoftExcel" Opacity=".56" ToolTip="打开EAM设备表的Excel文件 Excel必须包含序号、功能位置、设备系统代码、楼层的列" />
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
Command="{Binding OpenEAMFileCommand}"
|
||||
Style="{StaticResource MaterialDesignToolButton}">
|
||||
<md:PackIcon
|
||||
Kind="MicrosoftExcel"
|
||||
Opacity=".56"
|
||||
ToolTip="打开EAM设备表的Excel文件 Excel必须包含序号、功能位置、设备系统代码、楼层的列" />
|
||||
</Button>
|
||||
</Grid>
|
||||
</md:Card>
|
||||
|
||||
<UniformGrid HorizontalAlignment="Center" Rows="1">
|
||||
<TextBlock Foreground="{DynamicResource MaterialDesign.Brush.Foreground}" Text="精确匹配" ToolTip="完全一样" />
|
||||
<TextBlock
|
||||
Foreground="{DynamicResource MaterialDesign.Brush.Foreground}"
|
||||
Text="精确匹配"
|
||||
ToolTip="完全一样" />
|
||||
<ToggleButton IsChecked="{Binding IsFuzzyMatch}" Style="{StaticResource MaterialDesignSwitchToggleButton}" />
|
||||
<TextBlock Foreground="{DynamicResource MaterialDesign.Brush.Foreground}" Text="模糊匹配" ToolTip="包含即可" />
|
||||
<TextBlock
|
||||
Foreground="{DynamicResource MaterialDesign.Brush.Foreground}"
|
||||
Text="模糊匹配"
|
||||
ToolTip="包含即可" />
|
||||
</UniformGrid>
|
||||
<Button Command="{Binding MapModelEAMCodeCommand}" Content="模型-编码匹配" ToolTip="通过匹配族实例名称与EAM设备表的设备编号 族实例 标记 与EAM编码 族实例 ID-100-编号 与EAM设备表的设备编号" />
|
||||
<Button Command="{Binding WriteCodeToInstancesMappedCommand}" Content="EAM编码写入" ToolTip="把匹配的EAM编码写入构件" />
|
||||
<Button Command="{Binding ExportExcelCommand}" Content="Excel表格导出" ToolTip="导出Excel族实例表和EAM设备表" />
|
||||
<Button Command="{Binding QuickWriteEAMToInstancesCommand}" Content="EAM编码批量写入" ToolTip="通过Excel第一个表格批量将EAM编码写入构件标记属性 Excel需包含“元素ID”,“EAM编码”的首行表头" />
|
||||
<Button
|
||||
Command="{Binding MapModelEAMCodeCommand}"
|
||||
Content="模型-编码匹配"
|
||||
ToolTip="通过匹配族实例名称与EAM设备表的设备编号 族实例 标记 与EAM编码 族实例 ID-100-编号 与EAM设备表的设备编号" />
|
||||
<Button
|
||||
Command="{Binding WriteCodeToInstancesMappedCommand}"
|
||||
Content="EAM编码写入"
|
||||
ToolTip="把匹配的EAM编码写入构件" />
|
||||
<Button
|
||||
Command="{Binding ExportExcelCommand}"
|
||||
Content="Excel表格导出"
|
||||
ToolTip="导出Excel族实例表和EAM设备表" />
|
||||
<Button
|
||||
Command="{Binding QuickWriteEAMToInstancesCommand}"
|
||||
Content="EAM编码批量写入"
|
||||
ToolTip="通过Excel第一个表格批量将EAM编码写入构件标记属性 Excel需包含“元素ID”,“EAM编码”的首行表头" />
|
||||
|
||||
</UniformGrid>
|
||||
<ToggleButton
|
||||
@@ -230,12 +265,18 @@
|
||||
CanUserAddRows="False"
|
||||
ItemsSource="{Binding StoryCodeMappers, Mode=TwoWay}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Binding="{Binding Story}" Header="楼层" IsReadOnly="True" />
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Story}"
|
||||
Header="楼层"
|
||||
IsReadOnly="True" />
|
||||
<DataGridTextColumn Binding="{Binding Code, UpdateSourceTrigger=PropertyChanged}" Header="楼层代码" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</GroupBox>
|
||||
<Button Grid.Row="1" Command="{Binding ApplyMappersCommand}" Content="应用" />
|
||||
<Button
|
||||
Grid.Row="1"
|
||||
Command="{Binding ApplyMappersCommand}"
|
||||
Content="应用" />
|
||||
<!--<Button
|
||||
HorizontalAlignment="Center"
|
||||
Command="{x:Static md:DrawerHost.CloseDrawerCommand}"
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace Szmedi.RvKits.InfoManager.EAMTools
|
||||
/// Revit执行命令
|
||||
/// </summary>
|
||||
[Transaction(TransactionMode.Manual)]
|
||||
[Regeneration(RegenerationOption.Manual)]
|
||||
public class EAMFacilityCodeCmd : ExternalCommand
|
||||
{
|
||||
public override void Execute()
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace Szmedi.RvKits.InfoManager
|
||||
/// Revit执行命令
|
||||
/// </summary>
|
||||
[Transaction(TransactionMode.Manual)]
|
||||
[Regeneration(RegenerationOption.Manual)]
|
||||
public class RemoveParamsCmd : ExternalCommand
|
||||
{
|
||||
public override void Execute()
|
||||
|
||||
@@ -9,7 +9,6 @@ namespace Szmedi.RvKits.InfoManager
|
||||
/// Revit执行命令
|
||||
/// </summary>
|
||||
[Transaction(TransactionMode.Manual)]
|
||||
[Regeneration(RegenerationOption.Manual)]
|
||||
public class ReplaceParamValueCmd : ExternalCommand
|
||||
{
|
||||
public override void Execute()
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Szmedi.RvKits.InfoManager
|
||||
private readonly ActionEventHandler handler = new();
|
||||
private readonly UIApplication uiapp;
|
||||
[ObservableProperty]
|
||||
private string searchText;
|
||||
public partial string SearchText { get; set; }
|
||||
|
||||
partial void OnSearchTextChanged(string value)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user