整理代码

This commit is contained in:
ShrlAlgo
2025-10-10 11:19:58 +08:00
parent 4722a4c881
commit 9d40762f03
111 changed files with 3238 additions and 3112 deletions

View File

@@ -4,15 +4,12 @@ namespace ShrlAlgoToolkit.RevitAddins.RvCommon;
internal class AlignModelElement
{
private readonly View ownerView;
public AlignModelElement(Element e)
{
Parent = e;
var doc = e.Document;
ownerView = doc.GetElement(e.OwnerViewId) != null ? doc.GetElement(e.OwnerViewId) as View : doc.ActiveView;
var ownerView = doc.GetElement(e.OwnerViewId) != null ? doc.GetElement(e.OwnerViewId) as View : doc.ActiveView;
//var viewPlane = Plane.CreateByNormalAndOrigin(ownerView is View3D ? XYZ.BasisZ : ownerView!.ViewDirection, ownerView.Origin);

View File

@@ -1,16 +1,18 @@
<ui:NeoWindow
Title="自动保存"
Width="300"
d:DataContext="{d:DesignInstance Type=rvCommon:AutoSaveViewModel}"
mc:Ignorable="d"
x:Class="ShrlAlgoToolkit.RevitAddins.RvCommon.AutoSaveView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:rvCommon="clr-namespace:ShrlAlgoToolkit.RevitAddins.RvCommon"
xmlns:ui="https://github.com/ShrlAlgo/NeoUI"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
Title="自动保存"
Width="300"
Height="100"
d:DataContext="{d:DesignInstance Type=rvCommon:AutoSaveViewModel}"
Icon="{DynamicResource RevitIcon}"
mc:Ignorable="d">
<b:Interaction.Triggers>
<b:EventTrigger EventName="Closing">
<b:InvokeCommandAction Command="{Binding ClosingCommand}" />
@@ -24,13 +26,13 @@
</ResourceDictionary>
</Window.Resources>
<ui:Grid Margin="5" VerticalAlignment="Center">
<CheckBox IsChecked="{Binding IsActiveAutoSave, UpdateSourceTrigger=PropertyChanged}" x:Name="CbAutoSave" />
<TextBlock Text="自动保存时间间隔(分钟)" VerticalAlignment="Center" />
<CheckBox x:Name="CbAutoSave" IsChecked="{Binding IsActiveAutoSave, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock VerticalAlignment="Center" Text="自动保存时间间隔(分钟)" />
<TextBox
x:Name="TbIntervalMinutes"
Width="80"
InputMethod.IsInputMethodEnabled="False"
IsEnabled="{Binding IsChecked, ElementName=CbAutoSave}"
Text="{Binding IntervalTime, UpdateSourceTrigger=PropertyChanged}"
Width="80"
x:Name="TbIntervalMinutes" />
Text="{Binding IntervalTime, UpdateSourceTrigger=PropertyChanged}" />
</ui:Grid>
</ui:NeoWindow>

View File

@@ -1,17 +1,18 @@
<ui:NeoWindow
Height="450"
Title="构件明细"
Width="800"
d:DataContext="{d:DesignInstance Type=local:DetailSelectFiltersViewModel}"
mc:Ignorable="d"
x:Class="ShrlAlgoToolkit.RevitAddins.RvCommon.DetailSelectFiltersView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ShrlAlgoToolkit.RevitAddins.RvCommon"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="https://github.com/ShrlAlgo/NeoUI"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
Title="构件明细"
Width="800"
Height="450"
d:DataContext="{d:DesignInstance Type=local:DetailSelectFiltersViewModel}"
Icon="{DynamicResource RevitIcon}"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@@ -40,9 +41,9 @@
<DataGridTextColumn Binding="{Binding Id}" Header="元素ID" />
<DataGridTextColumn Binding="{Binding CategoryName}" Header="类别名称" />
<DataGridTextColumn
Width="Auto"
Binding="{Binding Name}"
Header="名称"
Width="Auto" />
Header="名称" />
<!--<DataGridTextColumn Binding="{Binding ReferenceLevel?.Name}" Header="参照标高" />-->
<DataGridTextColumn Binding="{Binding LevelName}" Header="标高" />
<DataGridTextColumn Binding="{Binding ReferenceLevel}" Header="参照标高" />
@@ -71,15 +72,15 @@
</DataGrid>
<ui:StackPanel Grid.Row="1" Orientation="Horizontal">
<CheckBox
Margin="5"
Content="剖切"
IsChecked="{Binding IsCutting, UpdateSourceTrigger=PropertyChanged}"
Margin="5"
ToolTip="仅三维视图可用" />
<TextBox
Margin="5"
ui:InputAssist.Placeholder="请输入检索属性条目"
Text="{Binding SearchProp, UpdateSourceTrigger=PropertyChanged}"
ui:StackPanel.Fill="Fill" />
ui:StackPanel.Fill="Fill"
Text="{Binding SearchProp, UpdateSourceTrigger=PropertyChanged}" />
</ui:StackPanel>
</ui:Grid>
</ui:NeoWindow>

View File

@@ -1,17 +1,18 @@
<ui:NeoWindow
Height="340"
MinHeight="300"
Title="族实例布置"
Width="220"
d:DataContext="{d:DesignInstance local:InstanceCreatorViewModel}"
mc:Ignorable="d"
x:Class="ShrlAlgoToolkit.RevitAddins.RvCommon.InstanceCreatorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ShrlAlgoToolkit.RevitAddins.RvCommon"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="https://github.com/ShrlAlgo/NeoUI"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
Title="族实例布置"
Width="220"
Height="340"
MinHeight="300"
d:DataContext="{d:DesignInstance local:InstanceCreatorViewModel}"
Icon="{DynamicResource RevitIcon}"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@@ -21,21 +22,20 @@
</Window.Resources>
<ui:StackPanel Margin="5" Spacing="5">
<ComboBox
ui:SelectorAssist.Placeholder="选择族"
DisplayMemberPath="Name"
ItemsSource="{Binding Families}"
ui:InputAssist.Placeholder="选择族"
SelectedItem="{Binding SelectedFamily, UpdateSourceTrigger=PropertyChanged}" />
<ui:NeuComboBox
<ComboBox
ui:SelectorAssist.Placeholder="选择族类型"
DisplayMemberPath="Name"
ItemsSource="{Binding FamilySymbols, Mode=OneWay}"
ui:InputAssist.Placeholder="选择族类型"
SelectedItem="{Binding SelectedFamilySymbol, UpdateSourceTrigger=PropertyChanged}"
IsFilteringEnabled="False" />
SelectedItem="{Binding SelectedFamilySymbol, UpdateSourceTrigger=PropertyChanged}" />
<Image
Grid.Row="2"
Width="128"
Height="128"
Source="{Binding Image}"
Width="128" />
Source="{Binding Image}" />
<TextBox
Grid.Row="3"
ui:InputAssist.Prefix="偏移量:"
@@ -50,10 +50,10 @@
</TextBox.Text>-->
</TextBox>
<Button
Command="{Binding PlaceInstancesCommand}"
Content="布置"
Grid.Row="4"
HorizontalAlignment="Stretch"
Command="{Binding PlaceInstancesCommand}"
Content="布置"
ToolTip="选择dwg块并布置族实例" />
</ui:StackPanel>
</ui:NeoWindow>

View File

@@ -1,36 +1,38 @@
<ui:NeoWindow
Title="曲线布置"
Width="500"
d:DataContext="{d:DesignInstance Type=local:ModelByCurveCreatorViewModel}"
mc:Ignorable="d"
x:Class="ShrlAlgoToolkit.RevitAddins.RvCommon.ModelByCurveCreatorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ShrlAlgoToolkit.RevitAddins.RvCommon"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:rvCommon="clr-namespace:ShrlAlgoToolkit.RevitAddins.RvCommon"
xmlns:ui="https://github.com/ShrlAlgo/NeoUI"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
Title="曲线布置"
Width="500"
Height="400"
d:DataContext="{d:DesignInstance Type=local:ModelByCurveCreatorViewModel}"
Icon="{DynamicResource RevitIcon}"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary Source="pack://application:,,,/ShrlAlgoToolkit.RevitAddins;component/WPFUI.xaml" />
</Window.Resources>
<ui:Grid Columns="*" Rows="*,Auto,Auto">
<ui:Grid
Grid.Row="0"
ChildMargin="5"
Columns="*,*"
Grid.Row="0"
Rows="*">
<GroupBox
Grid.Column="0"
Grid.Row="0"
Header="沿线放样"
VerticalAlignment="Stretch">
Grid.Column="0"
VerticalAlignment="Stretch"
Header="沿线放样">
<ui:StackPanel Spacing="5">
<ComboBox
ui:SelectorAssist.Placeholder="请选择轮廓类型"
ItemTemplate="{StaticResource MultiDisplayMemberPath}"
ItemsSource="{Binding ProfileFamilyTypes, Mode=OneWay}"
ui:InputAssist.Placeholder="请选择轮廓类型"
SelectedItem="{Binding SelectedProfileFamilyType, UpdateSourceTrigger=PropertyChanged}"
ToolTip="选择轮廓类型,未选择则不创建,&#xA;右键点击清除选择">
<b:Interaction.Triggers>
@@ -40,9 +42,9 @@
</b:Interaction.Triggers>
</ComboBox>
<ComboBox
ui:SelectorAssist.Placeholder="请选择放样的材质"
DisplayMemberPath="Name"
ItemsSource="{Binding Materials, Mode=OneWay}"
ui:InputAssist.Placeholder="请选择放样的材质"
SelectedItem="{Binding SelectedMaterial, UpdateSourceTrigger=PropertyChanged}"
ToolTip="选择放样模型材质,未选择则为默认材质,&#xA;右键点击清除选择">
<b:Interaction.Triggers>
@@ -52,29 +54,29 @@
</b:Interaction.Triggers>
</ComboBox>
<TextBox
InputMethod.IsInputMethodEnabled="False"
ui:InputAssist.Prefix="偏移距离X"
ui:InputAssist.Suffix="mm"
InputMethod.IsInputMethodEnabled="False"
Text="{Binding OffsetX, StringFormat={}{0:N2}, UpdateSourceTrigger=PropertyChanged}"
ToolTip="向右偏移设置为正值,&#xA;向左偏移为负值" />
<TextBox
InputMethod.IsInputMethodEnabled="False"
ui:InputAssist.Prefix="偏移距离Y"
ui:InputAssist.Suffix="mm"
InputMethod.IsInputMethodEnabled="False"
Text="{Binding OffsetY, StringFormat={}{0:N2}, UpdateSourceTrigger=PropertyChanged}"
ToolTip="向上偏移设置为正值,&#xA;向下偏移为负值" />
</ui:StackPanel>
</GroupBox>
<GroupBox
Grid.Column="1"
Grid.Row="0"
Header="沿线布置"
VerticalAlignment="Stretch">
Grid.Column="1"
VerticalAlignment="Stretch"
Header="沿线布置">
<ui:StackPanel Spacing="5">
<ComboBox
ui:SelectorAssist.Placeholder="请选择实例类型"
ItemTemplate="{StaticResource MultiDisplayMemberPath}"
ItemsSource="{Binding FamilyTypes, Mode=OneWay}"
ui:InputAssist.Placeholder="请选择实例类型"
SelectedItem="{Binding SelectedFamilyType, UpdateSourceTrigger=PropertyChanged}"
ToolTip="选择需要布置的族实例,未选择则不创建,&#xA;右键点击清除选择">
<b:Interaction.Triggers>
@@ -84,20 +86,20 @@
</b:Interaction.Triggers>
</ComboBox>
<TextBox
InputMethod.IsInputMethodEnabled="False"
ui:InputAssist.Prefix="水平间距:"
ui:InputAssist.Suffix="mm"
InputMethod.IsInputMethodEnabled="False"
Text="{Binding Spacing, StringFormat={}{0:N2}, UpdateSourceTrigger=PropertyChanged}" />
<TextBox
InputMethod.IsInputMethodEnabled="False"
ui:InputAssist.Prefix="偏移距离X"
ui:InputAssist.Suffix="mm"
InputMethod.IsInputMethodEnabled="False"
Text="{Binding InstanceOffsetX, StringFormat={}{0:N2}, UpdateSourceTrigger=PropertyChanged}"
ToolTip="向右偏移设置为正值,&#xA;向左偏移为负值" />
<TextBox
InputMethod.IsInputMethodEnabled="False"
ui:InputAssist.Prefix="偏移距离Y"
ui:InputAssist.Suffix="mm"
InputMethod.IsInputMethodEnabled="False"
Text="{Binding InstanceOffsetY, StringFormat={}{0:N2}, UpdateSourceTrigger=PropertyChanged}"
ToolTip="向上偏移设置为正值,&#xA;向下偏移为负值" />
</ui:StackPanel>
@@ -105,9 +107,9 @@
</ui:Grid>
<GroupBox
Grid.Row="1"
Header="中心线类型"
Margin="5">
<UniformGrid Rows="1" VerticalAlignment="Center">
Margin="5"
Header="中心线类型">
<UniformGrid VerticalAlignment="Center" Rows="1">
<RadioButton
Content="模型线"
IsChecked="{Binding CenterCurveType, ConverterParameter={x:Static rvCommon:CenterCurveType.ModelCurve}, Converter={StaticResource ComparisonConverter}}"
@@ -127,20 +129,20 @@
Margin="5"
Rows="1">
<TextBox
InputMethod.IsInputMethodEnabled="False"
ui:InputAssist.Prefix="最小细分长度:"
ui:InputAssist.Suffix="m"
InputMethod.IsInputMethodEnabled="False"
Text="{Binding Precision, UpdateSourceTrigger=PropertyChanged}"
ToolTip="数值越小,越拟合原曲线,&#xA;建议模型线由于单条曲线较长取值小一些dwg的曲线由于单条曲线较短取值大一些" />
<CheckBox
Content="两侧布置"
HorizontalAlignment="Center"
Content="两侧布置"
IsChecked="{Binding IsTwoSides}"
ToolTip="在中心线两侧布置放样(会合并)和实例" />
<Button
HorizontalAlignment="Stretch"
Command="{Binding CreateTrackCommand}"
Content="创建"
HorizontalAlignment="Stretch" />
Content="创建" />
</UniformGrid>
</ui:Grid>
</ui:NeoWindow>

View File

@@ -1,19 +1,20 @@
<ui:NeoWindow
Height="180"
MinHeight="180"
MinWidth="250"
SizeToContent="Height"
Title="管道翻模"
Width="250"
d:DataContext="{d:DesignInstance Type=local:PipesCreatorViewModel}"
mc:Ignorable="d"
x:Class="ShrlAlgoToolkit.RevitAddins.RvCommon.PipesCreatorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ShrlAlgoToolkit.RevitAddins.RvCommon"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="https://github.com/ShrlAlgo/NeoUI"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
Title="管道翻模"
Width="250"
Height="180"
MinWidth="250"
MinHeight="180"
d:DataContext="{d:DesignInstance Type=local:PipesCreatorViewModel}"
Icon="{DynamicResource RevitIcon}"
SizeToContent="Height"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@@ -23,21 +24,21 @@
</Window.Resources>
<ui:Grid ChildMargin="5" Columns="*">
<ComboBox
DisplayMemberPath="Name"
Grid.Row="0"
ItemsSource="{Binding PipeTypes}"
ui:SelectorAssist.Placeholder="管线类型"
DisplayMemberPath="Name"
ItemsSource="{Binding PipeTypes}"
SelectedItem="{Binding SelectedPipeType}" />
<ComboBox
DisplayMemberPath="Name"
Grid.Row="1"
ItemsSource="{Binding PipingSystemTypes}"
ui:SelectorAssist.Placeholder="系统类型"
DisplayMemberPath="Name"
ItemsSource="{Binding PipingSystemTypes}"
SelectedItem="{Binding SelectedPipingSystemType}" />
<Button
Command="{Binding CreateCommand}"
Content="创建"
Grid.Row="2"
HorizontalAlignment="Stretch" />
HorizontalAlignment="Stretch"
Command="{Binding CreateCommand}"
Content="创建" />
</ui:Grid>
</ui:NeoWindow>

View File

@@ -1,4 +1,6 @@
using Autodesk.Revit.Attributes;
using System.Windows;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using eTransmitForRevitDB;
using Nice3point.Revit.Toolkit.External;
@@ -19,7 +21,11 @@ public class PureModelCmd : ExternalCommand
System.Windows.MessageBox.Show("请先保存文件");
return;
}
var result = MessageBox.Show("是否清理项目中的所有未使用项", "询问", MessageBoxButton.YesNo, MessageBoxImage.Question);
if(result == MessageBoxResult.No)
{
return;
}
var options = new SaveAsOptions()
{
Compact = true,
@@ -34,7 +40,6 @@ public class PureModelCmd : ExternalCommand
}
catch (Exception)
{
throw;
}

View File

@@ -1,14 +1,15 @@
<Window
Height="450"
Title="条件选择"
Width="800"
mc:Ignorable="d"
x:Class="ShrlAlgoToolkit.RevitAddins.RvCommon.QuickSelectionView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ShrlAlgoToolkit.RevitAddins.RvCommon"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
Title="条件选择"
Width="800"
Height="450"
Icon="{DynamicResource RevitIcon}"
mc:Ignorable="d">
<Grid>
<GroupBox Header="选项" />
</Grid>