Skip to content

Commit

Permalink
I think I fixed the bug causing a datagrid parameter column to remain…
Browse files Browse the repository at this point in the history
… after the selection has been changed. More testing is needed. Most likely seperate buttons will be needed to delete or clear parameters and their resepective columns.
  • Loading branch information
Carson-McCombs committed Feb 14, 2024
1 parent c8843c5 commit 106ec86
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Template/ComplexFilterDockablePane.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
</Border>
</Grid>
<UniformGrid Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,36,12,0" Rows="8">
<Button Content="Load Selection" Click="RefreshButtonPress" Style="{StaticResource CheckButtonsStyle}"/>
<Button Content="Load Selection" Click="LoadSelectionButtonPress" Style="{StaticResource CheckButtonsStyle}"/>

<Button Content="Select From List" Click="SelectHighlightedElements" Style="{StaticResource CheckButtonsStyle}"/>

Expand Down
42 changes: 18 additions & 24 deletions Template/ComplexFilterDockablePane.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ public void Init(UIDocument uidoc)
this.uidoc = uidoc;
new ParametersByTypeId(uidoc);

Definition definition;
Transaction transaction = new Transaction(uidoc.Document);
transaction.Start("DummyGetParameterDefinition");
//Definition definition;
//Transaction transaction = new Transaction(uidoc.Document);
//transaction.Start("DummyGetParameterDefinition");

Pipe pipe = Pipe.Create(uidoc.Document, ElementId.InvalidElementId, new ElementId(4646900), ElementId.InvalidElementId, new XYZ(0,0,0), new XYZ(5,5,5));
definition = pipe.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).Definition;
transaction.RollBack();
//Pipe pipe = Pipe.Create(uidoc.Document, ElementId.InvalidElementId, new ElementId(4646900), ElementId.InvalidElementId, new XYZ(0,0,0), new XYZ(5,5,5));
//definition = pipe.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).Definition;
//transaction.RollBack();

table.AddParameter(definition);
//table.AddParameter(definition);
}
public PushButtonData RegisterButton(Assembly assembly)
{
Expand All @@ -86,17 +86,16 @@ public PushButtonData RegisterButton(Assembly assembly)
return pushButtonData;
}

private void RefreshButtonPress(object sender, RoutedEventArgs e)
private void LoadSelectionButtonPress(object sender, RoutedEventArgs e)
{
RefreshSelection();
LoadSelection();
}
public void RefreshSelection()
public void LoadSelection()
{
if (uidoc == null) return;
table.Clear();
//filterableElements.Clear();


ParameterGroupComboBox.SelectedItem = null;
ParameterNameControl.Text = "";
List<ElementId> elementIds = uidoc.Selection.GetElementIds() as List<ElementId>;
if (elementIds.Count == 0)
{
Expand All @@ -109,13 +108,10 @@ public void RefreshSelection()
{
Element elem = uidoc.Document.GetElement(id);
if (elem == null) continue;
//filterableElements.Add(new FilterableElement(elem));
table.AddElement(elem);
}
}

//private void RefreshSelectedCount(object sender, RoutedEventArgs e) => TotalSelectedLabel.Content = "Total Selected Items: " + CalculateTotalSelectedCount().ToString();

public void SetupDockablePane(DockablePaneProviderData data)
{
data.FrameworkElement = this;
Expand All @@ -131,7 +127,6 @@ public void SetupDockablePane(DockablePaneProviderData data)

private void AddParameterButton(object sender, RoutedEventArgs e)
{

try
{
if (ParameterNameControl.Text == "") return;
Expand All @@ -145,17 +140,13 @@ private void AddParameterButton(object sender, RoutedEventArgs e)

private void ApplyButtonPress(object sender, RoutedEventArgs e)
{
//Transaction transaction = new Transaction(uidoc.Document);
//transaction.Start("ApplyParameterChanges");
try
{
table.PushUpdatesToElements();
//transaction.Commit();
}
catch (Exception ex)
{
TaskDialog.Show("Complex Filter Apply Parameter Changes Error", ex.Message);
//transaction.RollBack();
}
}

Expand Down Expand Up @@ -191,7 +182,8 @@ private void AddGroupButton(object sender, RoutedEventArgs e)

}


// CURRENTLY UNUSED
// Purpose: to act as a buffer for retrieving element parameters. Will attempt to retrieve the a via parameter if no definition is saved, otherwise retrieving the parameter through the definition.
class ParametersByTypeId
{
public static ParametersByTypeId instance;
Expand Down Expand Up @@ -259,10 +251,12 @@ public void Clear()
columnNames.Clear();
parameterDefinitions.Clear();
parameterReadOnly.Clear();

CollectionViewSource.GetDefaultView(rows).GroupDescriptions.Clear();
for (int i = 1; i < dataGrid.Columns.Count; i++)
{
for (int i = dataGrid.Columns.Count - 1; i >= 1; i--)
{
dataGrid.Columns.RemoveAt(i);

}
}
public void AddElement(Element element)
Expand Down

0 comments on commit 106ec86

Please sign in to comment.