-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
346 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Collections.Generic; | ||
using System.Windows; | ||
using Autodesk.Revit.Attributes; | ||
using Autodesk.Revit.DB; | ||
using Autodesk.Revit.UI; | ||
using Autodesk.Revit.UI.Selection; | ||
using RevitElementBipChecker.Model; | ||
using RevitElementBipChecker.View; | ||
|
||
namespace RevitElementBipChecker.Command; | ||
|
||
[Transaction(TransactionMode.Manual)] | ||
public class CompareCommand : IExternalCommand | ||
{ | ||
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) | ||
{ | ||
UIApplication uiapp = commandData.Application; | ||
UIDocument uidoc = uiapp.ActiveUIDocument; | ||
Document doc = uidoc.Document; | ||
Reference r1 = uidoc.Selection.PickObject(ObjectType.Element,"Select first element"); | ||
Element element1 = doc.GetElement(r1); | ||
Reference r2 = uidoc.Selection.PickObject(ObjectType.Element,"Select second element"); | ||
Element element2 = doc.GetElement(r2); | ||
FrmCompareBip frmCompareBip = new FrmCompareBip(element1,element2); | ||
|
||
frmCompareBip.WindowStartupLocation = WindowStartupLocation.CenterScreen; | ||
frmCompareBip.SetRevitAsWindowOwner(); | ||
frmCompareBip.Show(); | ||
return Result.Succeeded; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using System.Windows.Media; | ||
|
||
namespace RevitElementBipChecker.Model; | ||
|
||
public class ParameterComparer | ||
{ | ||
public static List<ParameterDifference> CompareParameters(List<ParameterBase> list1, List<ParameterBase> list2) | ||
{ | ||
var differences = new List<ParameterDifference>(); | ||
|
||
// Find parameters in list1 that are not in list2 | ||
foreach (var parameter1 in list1) | ||
{ | ||
var parameter2 = list2.FirstOrDefault(p => p.Name == parameter1.Name); | ||
|
||
if (parameter2 == null) | ||
{ | ||
differences.Add(new ParameterDifference | ||
{ | ||
Name = parameter1.Name, | ||
Type = parameter1.Type, | ||
Value1 = parameter1.Value, | ||
Value2 = null // Not found in list2 | ||
}); | ||
} | ||
else if (parameter1.Type != parameter2.Type || parameter1.Value != parameter2.Value) | ||
{ | ||
differences.Add(new ParameterDifference | ||
{ | ||
Name = parameter1.Name, | ||
Type = parameter1.Type, | ||
Value1 = parameter1.Value, | ||
Value2 = parameter2.Value | ||
}); | ||
} | ||
} | ||
|
||
// Find parameters in list2 that are not in list1 | ||
foreach (var parameter2 in list2) | ||
{ | ||
var parameter1 = list1.FirstOrDefault(p => p.Name == parameter2.Name); | ||
|
||
if (parameter1 == null) | ||
{ | ||
differences.Add(new ParameterDifference | ||
{ | ||
Name = parameter2.Name, | ||
Type = parameter2.Type, | ||
Value1 = null, // Not found in list1 | ||
Value2 = parameter2.Value | ||
}); | ||
} | ||
} | ||
return differences; | ||
} | ||
} | ||
public class ParameterBase | ||
{ | ||
public string Name { get; set; } | ||
public string Value { get; set; } | ||
public string Type { get; set; } | ||
} | ||
public class ParameterDifference: INotifyPropertyChanged | ||
{ | ||
public string Name { get; set; } | ||
public string Type { get; set; } | ||
public string Value1 { get; set; } | ||
public string Value2 { get; set; } | ||
private Brush _backgroundColor = Brushes.Transparent; | ||
public Brush BackgroundColor | ||
{ | ||
get { return _backgroundColor; } | ||
set | ||
{ | ||
_backgroundColor = value; | ||
OnPropertyChanged(nameof(BackgroundColor)); | ||
} | ||
} | ||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
|
||
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null) | ||
{ | ||
if (EqualityComparer<T>.Default.Equals(field, value)) return false; | ||
field = value; | ||
OnPropertyChanged(propertyName); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<Window x:Class="RevitElementBipChecker.View.FrmCompareBip" | ||
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
Title="Mini Compare Two Element" Height="600" Width="400"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="*" /> | ||
<RowDefinition Height="35" /> | ||
</Grid.RowDefinitions> | ||
<DataGrid | ||
x:Name="dataGrid" | ||
Background="WhiteSmoke" | ||
AlternatingRowBackground="Transparent" | ||
AlternationCount="2" | ||
IsReadOnly="True" | ||
AutoGenerateColumns="False"> | ||
<DataGrid.RowStyle> | ||
<Style TargetType="DataGridRow"> | ||
<Setter Property="Background" Value="{Binding BackgroundColor}" /> | ||
</Style> | ||
</DataGrid.RowStyle> | ||
<DataGrid.Columns> | ||
<DataGridTextColumn Width="100" Header="Parameter Name" Binding="{Binding Name}" /> | ||
<DataGridTextColumn Width="70" Header="Type" Binding="{Binding Type}" /> | ||
<DataGridTextColumn Width="*" Header="Value Element1" Binding="{Binding Value1}" /> | ||
<DataGridTextColumn Width="*" Header="Value Element2" Binding="{Binding Value2}" /> | ||
</DataGrid.Columns> | ||
</DataGrid> | ||
<Grid Grid.Row="1" Margin="2,2,2,2"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="50" /> | ||
<ColumnDefinition /> | ||
</Grid.ColumnDefinitions> | ||
<Button Content="Toggle" | ||
Margin="1,1,1,1" | ||
Background="WhiteSmoke" | ||
ToolTip="Toggle to check different parameters between two elements invert" | ||
Click="ToggleClick"> | ||
</Button> | ||
<Button IsCancel="True" | ||
Background="WhiteSmoke" | ||
Margin="1,1,1,1" | ||
Click="CloseClick" Grid.Column="1" Grid.Row="0" Content="Close"> | ||
</Button> | ||
</Grid> | ||
|
||
</Grid> | ||
</Window> |
Oops, something went wrong.