Skip to content
This repository was archived by the owner on Aug 28, 2021. It is now read-only.

Commit 4d43649

Browse files
authored
Merge pull request #10 from speckleworks/Matteo/dev
Matteo/dev
2 parents a74d12f + 4dad4a6 commit 4d43649

File tree

10 files changed

+491
-197
lines changed

10 files changed

+491
-197
lines changed

SpeckleRevitReboot/Entry.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,12 @@ public Result Execute( ExternalCommandData commandData, ref string message, Elem
8585

8686
// Initialise the window
8787
#if DEBUG
88-
//SpeckleWindow = new SpeckleUiWindow( bindings, @"http://localhost:8080/" );
89-
SpeckleWindow = new SpeckleUiWindow( bindings, @"https://matteo-dev.appui.speckle.systems/#/" );
88+
SpeckleWindow = new SpeckleUiWindow( bindings, @"http://localhost:8080/" );
89+
//SpeckleWindow = new SpeckleUiWindow( bindings, @"https://matteo-dev.appui.speckle.systems/#/" );
9090
#else
9191
SpeckleWindow = new SpeckleUiWindow( bindings, @"https://matteo-dev.appui.speckle.systems/#/" ); // On release, default to the latest ci-ed version from https://appui.speckle.systems
9292
#endif
93+
SpeckleUiBindingsRevit.SpeckleWindow = SpeckleWindow;
9394
var helper = new System.Windows.Interop.WindowInteropHelper( SpeckleWindow );
9495
helper.Owner = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
9596

SpeckleRevitReboot/ErrorEater.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,31 @@
88
using Autodesk.Revit.DB;
99
using Autodesk.Revit.UI;
1010
using SpeckleCore;
11+
using SpeckleCore.Data;
1112
using SpeckleRevit.Storage;
1213
using SpeckleUiBase;
1314

1415
namespace SpeckleRevit
1516
{
1617
public class ErrorEater : IFailuresPreprocessor
1718
{
18-
// TODO: gracefully save them somewhere, or do something about them - collect them and show them in the ui somehow?
1919
public FailureProcessingResult PreprocessFailures( FailuresAccessor failuresAccessor )
2020
{
21-
//var fails = failuresAccessor.GetFailureMessages();
21+
IList<FailureMessageAccessor> failList = new List<FailureMessageAccessor>();
22+
// Inside event handler, get all warnings
23+
failList = failuresAccessor.GetFailureMessages();
24+
foreach (FailureMessageAccessor failure in failList)
25+
{
26+
// check FailureDefinitionIds against ones that you want to dismiss,
27+
//FailureDefinitionId failID = failure.GetFailureDefinitionId();
28+
// prevent Revit from showing Unenclosed room warnings
29+
//if (failID == BuiltInFailures.RoomFailures.RoomNotEnclosed)
30+
//{
31+
var t = failure.GetDescriptionText();
32+
var r = failure.GetDefaultResolutionCaption();
2233

23-
//foreach(var f in fails)
24-
//{
25-
//}
34+
Globals.ConversionErrors.Add(new SpeckleError { Message = t });
35+
}
2636

2737
failuresAccessor.DeleteAllWarnings();
2838
return FailureProcessingResult.Continue;

SpeckleRevitReboot/Globals.cs

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Autodesk.Revit.DB;
2+
using SpeckleCore.Data;
23
using System;
34
using System.Collections.Generic;
45
using System.Linq;
@@ -10,6 +11,8 @@ namespace SpeckleRevit
1011
public static class Globals
1112
{
1213
private static List<string> _cachedParameters = null;
14+
private static List<string> _cachedViews = null;
15+
public static List<SpeckleError> ConversionErrors { get; set; }
1316

1417

1518
private static Dictionary<string, Category> _categories { get; set; }
@@ -37,8 +40,7 @@ private async static Task<List<string>> GetParameterNamesAsync(Document doc)
3740
var els = new FilteredElementCollector(doc)
3841
.WhereElementIsNotElementType()
3942
.WhereElementIsViewIndependent()
40-
.OfClass(typeof(FamilyInstance))
41-
.ToElements();
43+
.Where(x => x.IsPhysicalElement());
4244

4345
List<string> parameters = new List<string>();
4446

@@ -71,5 +73,70 @@ public static List<string> GetParameterNames(Document doc)
7173

7274
}
7375

76+
private async static Task<List<string>> GetViewNamesAsync(Document doc)
77+
{
78+
var els = new FilteredElementCollector(doc)
79+
.WhereElementIsNotElementType()
80+
.OfClass(typeof(View))
81+
.ToElements();
82+
83+
_cachedViews = els.Select(x => x.Name).OrderBy(x => x).ToList();
84+
return _cachedViews;
85+
}
86+
87+
/// <summary>
88+
/// Each time it's called the cached parameters are return, and a new copy is cached
89+
/// </summary>
90+
/// <param name="doc"></param>
91+
/// <returns></returns>
92+
public static List<string> GetViewNames(Document doc)
93+
{
94+
if (_cachedViews != null)
95+
{
96+
//don't wait for it to finish
97+
GetViewNamesAsync(doc);
98+
return _cachedViews;
99+
}
100+
return GetViewNamesAsync(doc).Result;
101+
102+
}
103+
104+
public static bool IsPhysicalElement(this Element e)
105+
{
106+
if (e.Category == null) return false;
107+
if (e.ViewSpecific) return false;
108+
// exclude specific unwanted categories
109+
if (((BuiltInCategory)e.Category.Id.IntegerValue) == BuiltInCategory.OST_HVAC_Zones) return false;
110+
return e.Category.CategoryType == CategoryType.Model && e.Category.CanAddSubcategory;
111+
}
112+
113+
private static List<string> SadFaces = new List<string>
114+
{
115+
"ಠ_ಠ",
116+
"(╯°□°)╯︵ ┻━┻",
117+
"ლ(`ー´ლ)",
118+
"ʕ •`ᴥ•´ʔ",
119+
\\_(ツ)_/¯",
120+
"ლ(ಠ益ಠლ)",
121+
"ಥ_ಥ",
122+
"ᕦ(ò_óˇ)ᕤ",
123+
"¿ⓧ_ⓧﮌ",
124+
"༼∵༽ ༼⍨༽ ༼⍢༽ ༼⍤༽",
125+
"ヽ༼ ಠ益ಠ ༽ノ",
126+
"(Ծ‸ Ծ)",
127+
"ح(•̀ж•́)ง",
128+
"(⩾﹏⩽)",
129+
"{ಠʖಠ}"
130+
};
131+
132+
public static string GetRandomSadFace()
133+
{
134+
var random = new Random();
135+
int index = random.Next(SadFaces.Count);
136+
return SadFaces[index];
137+
}
138+
139+
140+
74141
}
75142
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Window
2+
x:Class="SpeckleRevit.SpeckleProgressBar"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:SpeckleRevit"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
Title="Speckle is working..."
9+
SizeToContent="WidthAndHeight"
10+
mc:Ignorable="d">
11+
<Grid>
12+
<StackPanel HorizontalAlignment="Center" Orientation="Vertical">
13+
<ProgressBar
14+
Name="Progress"
15+
Width="500"
16+
Height="5"
17+
Margin="20,25,20,0" />
18+
<Label
19+
Name="ProgressText"
20+
Margin="20,20,20,20"
21+
HorizontalAlignment="Center"
22+
Content="I'm a a progress bar" />
23+
</StackPanel>
24+
</Grid>
25+
</Window>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Shapes;
14+
15+
namespace SpeckleRevit
16+
{
17+
/// <summary>
18+
/// Interaction logic for ProgressBar.xaml
19+
/// </summary>
20+
public partial class SpeckleProgressBar : Window
21+
{
22+
public SpeckleProgressBar()
23+
{
24+
InitializeComponent();
25+
}
26+
}
27+
}

SpeckleRevitReboot/SpeckleRevit.csproj

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
88
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
99
<ProjectGuid>{4937638C-8A51-4F50-9BD2-E7F7AC28DD01}</ProjectGuid>
10+
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1011
<OutputType>Library</OutputType>
1112
<AppDesignerFolder>Properties</AppDesignerFolder>
1213
<RootNamespace>SpeckleRevit</RootNamespace>
@@ -108,14 +109,14 @@
108109
<HintPath>..\packages\Revit.RevitApiUI.x64.2019.0.0\lib\net45\RevitAPIUI.dll</HintPath>
109110
<Private>False</Private>
110111
</Reference>
111-
<Reference Include="SpeckleCore, Version=1.6.9.0, Culture=neutral, processorArchitecture=AMD64">
112-
<HintPath>..\packages\SpeckleCore.1.6.9\lib\net45\SpeckleCore.dll</HintPath>
112+
<Reference Include="SpeckleCore, Version=1.6.17.0, Culture=neutral, processorArchitecture=AMD64">
113+
<HintPath>..\packages\SpeckleCore.1.6.17-wip\lib\net45\SpeckleCore.dll</HintPath>
113114
</Reference>
114115
<Reference Include="SpecklePopup, Version=1.6.13.0, Culture=neutral, processorArchitecture=MSIL">
115116
<HintPath>..\packages\SpecklePopup.1.6.13\lib\net45\SpecklePopup.dll</HintPath>
116117
</Reference>
117-
<Reference Include="SpeckleUiBase, Version=1.1.1.0, Culture=neutral, processorArchitecture=AMD64">
118-
<HintPath>..\packages\SpeckleUiBase.1.1.1-wip\lib\net452\SpeckleUiBase.dll</HintPath>
118+
<Reference Include="SpeckleUiBase, Version=1.1.4.0, Culture=neutral, processorArchitecture=AMD64">
119+
<HintPath>..\packages\SpeckleUiBase.1.1.4-wip\lib\net452\SpeckleUiBase.dll</HintPath>
119120
</Reference>
120121
<Reference Include="SQLite-net, Version=1.5.231.0, Culture=neutral, processorArchitecture=MSIL">
121122
<HintPath>..\packages\sqlite-net-pcl.1.5.231\lib\netstandard1.1\SQLite-net.dll</HintPath>
@@ -151,6 +152,9 @@
151152
<ItemGroup>
152153
<Compile Include="ErrorEater.cs" />
153154
<Compile Include="Globals.cs" />
155+
<Compile Include="SpeckleProgressBar.xaml.cs">
156+
<DependentUpon>SpeckleProgressBar.xaml</DependentUpon>
157+
</Compile>
154158
<Compile Include="Storage\HelperClasses.cs" />
155159
<Compile Include="Storage\SpeckleClientsStorage.cs" />
156160
<Compile Include="Entry.cs" />
@@ -171,6 +175,12 @@
171175
<None Include="app.config" />
172176
<None Include="packages.config" />
173177
</ItemGroup>
178+
<ItemGroup>
179+
<Page Include="SpeckleProgressBar.xaml">
180+
<SubType>Designer</SubType>
181+
<Generator>MSBuild:Compile</Generator>
182+
</Page>
183+
</ItemGroup>
174184
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
175185
<!-- <Target Name="BeforeBuild">
176186
<MakeDir Directories="$(TargetDir)\app" />

0 commit comments

Comments
 (0)