Skip to content

Commit

Permalink
Add New Snoop Support
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Mar 16, 2021
1 parent 95ed13c commit 9ccf498
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 11 deletions.
1 change: 1 addition & 0 deletions Command/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme

BipCheckerViewmodel vm = new BipCheckerViewmodel(uidoc);
MainWindows frMainWindows = new MainWindows(vm);
frMainWindows.WindowStartupLocation = WindowStartupLocation.CenterScreen;
frMainWindows.SetRevitAsWindowOwner();
frMainWindows.Show();
return Result.Succeeded;
Expand Down
61 changes: 59 additions & 2 deletions Model/PraUtils.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using RevitElementBipChecker.Viewmodel;
using GlobalParameter = Autodesk.Revit.DB.GlobalParameter;

namespace RevitElementBipChecker.Model
{
public static class PraUtils
{

public const string Caption = "Built-in Parameter Checker";
/// <summary>
/// Return Element Selected
Expand All @@ -33,7 +37,7 @@ public static List<Element> GetSelection(this UIDocument _uidoc)
{
value = ((System.Collections.IEnumerable)t.GetProperty("Elements").GetValue(_uidoc.Selection, null)).Cast<Element>().ToList();
}
return value.OrderBy(x=>x.Name).ToList();
return value.OrderBy(x => x.Name).ToList();
}

/// <summary>
Expand Down Expand Up @@ -83,7 +87,7 @@ public static string GetParameterType(this Autodesk.Revit.DB.Parameter parameter
/// <returns></returns>
public static string IsReadWrite(this Parameter parameter)
{
return parameter.IsReadOnly?"read-only" : "read-write";
return parameter.IsReadOnly ? "read-only" : "read-write";
}


Expand Down Expand Up @@ -270,5 +274,58 @@ public static string Guid(this Parameter parameter)
{
return parameter.IsShared ? parameter.GUID.ToString() : string.Empty;
}


/// <summary>
/// Return Global Parameter Name
/// </summary>
/// <param name="parameter"></param>
/// <param name="doc"></param>
/// <returns></returns>
public static string GetAssGlobalParameter(this Parameter parameter, Document doc)
{
Dictionary<string, string> gloDictionary = new Dictionary<string, string>();
ElementId elementId = parameter.GetAssociatedGlobalParameter();
if (elementId != null)
{
if (doc.GetElement(elementId) is GlobalParameter globalParameter)
{
return globalParameter.GetDefinition().Name;
}
}
return string.Empty;
}

/// <summary>
/// Return Global Parameter Value
/// </summary>
/// <param name="parameter"></param>
/// <param name="doc"></param>
/// <returns></returns>
public static string GetAssGlobalParameterValue(this Parameter parameter, Document doc)
{
Dictionary<string, string> gloDictionary = new Dictionary<string, string>();
ElementId elementId = parameter.GetAssociatedGlobalParameter();
if (elementId != null)
{
if (doc.GetElement(elementId) is GlobalParameter globalParameter)
{
DoubleParameterValue doublevalue = globalParameter.GetValue() as DoubleParameterValue;
StringParameterValue strpra = globalParameter.GetValue() as StringParameterValue;
if (doublevalue != null)
{
return RealString(doublevalue.Value);
}
if (strpra != null)
{
return strpra.Value;
}
return string.Empty;

}
}
return string.Empty;
}

}
}
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,14 @@ git clone https://github.com/chuongmep/RevitElementBipChecker.git
<a href="https://github.com/jeremytammik/BipChecker">jeremytammik</a>

<a href="https://github.com/ottosson/BipChecker-WPF">ottosson</a>


### Log Change

1.0.1 : First Release

1.0.2 : Fix Parameter Value String

1.0.3 :

- [x] Add Check Snoop Associated Global Parameter
14 changes: 13 additions & 1 deletion View/MainWindows.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="Revit Element Bip Checker"
Width="Auto"
MinHeight="420"
MinWidth="700"
d:DesignHeight="450"
d:DesignWidth="800"
SizeToContent="Width"
ResizeMode="CanResize"
mc:Ignorable="d">
<Grid>
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -92,6 +94,8 @@
Name="lsBipChecker"
Grid.Row="1"
Grid.Column="1"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible"
Margin="10"
ItemsSource="{Binding Data}">
<ListView.View>
Expand Down Expand Up @@ -144,6 +148,14 @@
Width="150"
DisplayMemberBinding="{Binding GUID}"
Header="GUID" />
<GridViewColumn
Width="200"
DisplayMemberBinding="{Binding AssGlobalPara}"
Header="Global Parameter Associated " />
<GridViewColumn
Width="200"
DisplayMemberBinding="{Binding AssGlobalParaValue}"
Header="Associated Global Parameter Value " />
</GridView>
</ListView.View>
<ListView.ContextMenu>
Expand Down
7 changes: 0 additions & 7 deletions Viewmodel/BipCheckerViewmodel.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
#region NameSpace
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using Autodesk.Revit.DB;
Expand Down Expand Up @@ -287,8 +282,6 @@ private void Copy_Guid()

#endregion



void ExportData()
{
try
Expand Down
7 changes: 6 additions & 1 deletion Viewmodel/ParameterData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Autodesk.Revit.DB;
using System.Linq;
using Autodesk.Revit.DB;
using RevitElementBipChecker.Model;

namespace RevitElementBipChecker.Viewmodel
Expand All @@ -22,6 +23,8 @@ public ParameterData(Parameter parameter,Document doc,bool isinstance=true)
this.Shared = parameter.Shared();
this.GUID = parameter.Guid();
this.TypeOrInstance = isinstance?"Instance":"Type";
this.AssGlobalPara = parameter.GetAssGlobalParameter(doc);
this.AssGlobalParaValue = parameter.GetAssGlobalParameterValue(doc);
}

public Autodesk.Revit.DB.Parameter Parameter { get; set; }
Expand All @@ -38,6 +41,8 @@ public ParameterData(Parameter parameter,Document doc,bool isinstance=true)
public string Shared { get; set; }
public string GUID { get; set; }

public string AssGlobalPara { get; set; }
public string AssGlobalParaValue { get; set; }

}
}

0 comments on commit 9ccf498

Please sign in to comment.