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

Commit

Permalink
Merge pull request #10 from speckleworks/Matteo/dev
Browse files Browse the repository at this point in the history
Matteo/dev
teocomi authored Dec 4, 2019
2 parents a74d12f + 4dad4a6 commit 4d43649
Showing 10 changed files with 491 additions and 197 deletions.
5 changes: 3 additions & 2 deletions SpeckleRevitReboot/Entry.cs
Original file line number Diff line number Diff line change
@@ -85,11 +85,12 @@ public Result Execute( ExternalCommandData commandData, ref string message, Elem

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

20 changes: 15 additions & 5 deletions SpeckleRevitReboot/ErrorEater.cs
Original file line number Diff line number Diff line change
@@ -8,21 +8,31 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using SpeckleCore;
using SpeckleCore.Data;
using SpeckleRevit.Storage;
using SpeckleUiBase;

namespace SpeckleRevit
{
public class ErrorEater : IFailuresPreprocessor
{
// TODO: gracefully save them somewhere, or do something about them - collect them and show them in the ui somehow?
public FailureProcessingResult PreprocessFailures( FailuresAccessor failuresAccessor )
{
//var fails = failuresAccessor.GetFailureMessages();
IList<FailureMessageAccessor> failList = new List<FailureMessageAccessor>();
// Inside event handler, get all warnings
failList = failuresAccessor.GetFailureMessages();
foreach (FailureMessageAccessor failure in failList)
{
// check FailureDefinitionIds against ones that you want to dismiss,
//FailureDefinitionId failID = failure.GetFailureDefinitionId();
// prevent Revit from showing Unenclosed room warnings
//if (failID == BuiltInFailures.RoomFailures.RoomNotEnclosed)
//{
var t = failure.GetDescriptionText();
var r = failure.GetDefaultResolutionCaption();

//foreach(var f in fails)
//{
//}
Globals.ConversionErrors.Add(new SpeckleError { Message = t });
}

failuresAccessor.DeleteAllWarnings();
return FailureProcessingResult.Continue;
71 changes: 69 additions & 2 deletions SpeckleRevitReboot/Globals.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Autodesk.Revit.DB;
using SpeckleCore.Data;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -10,6 +11,8 @@ namespace SpeckleRevit
public static class Globals
{
private static List<string> _cachedParameters = null;
private static List<string> _cachedViews = null;
public static List<SpeckleError> ConversionErrors { get; set; }


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

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

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

}

private async static Task<List<string>> GetViewNamesAsync(Document doc)
{
var els = new FilteredElementCollector(doc)
.WhereElementIsNotElementType()
.OfClass(typeof(View))
.ToElements();

_cachedViews = els.Select(x => x.Name).OrderBy(x => x).ToList();
return _cachedViews;
}

/// <summary>
/// Each time it's called the cached parameters are return, and a new copy is cached
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
public static List<string> GetViewNames(Document doc)
{
if (_cachedViews != null)
{
//don't wait for it to finish
GetViewNamesAsync(doc);
return _cachedViews;
}
return GetViewNamesAsync(doc).Result;

}

public static bool IsPhysicalElement(this Element e)
{
if (e.Category == null) return false;
if (e.ViewSpecific) return false;
// exclude specific unwanted categories
if (((BuiltInCategory)e.Category.Id.IntegerValue) == BuiltInCategory.OST_HVAC_Zones) return false;
return e.Category.CategoryType == CategoryType.Model && e.Category.CanAddSubcategory;
}

private static List<string> SadFaces = new List<string>
{
"ಠ_ಠ",
"(╯°□°)╯︵ ┻━┻",
"ლ(`ー´ლ)",
"ʕ •`ᴥ•´ʔ",
\\_(ツ)_/¯",
"ლ(ಠ益ಠლ)",
"ಥ_ಥ",
"ᕦ(ò_óˇ)ᕤ",
"¿ⓧ_ⓧﮌ",
"༼∵༽ ༼⍨༽ ༼⍢༽ ༼⍤༽",
"ヽ༼ ಠ益ಠ ༽ノ",
"(Ծ‸ Ծ)",
"ح(•̀ж•́)ง",
"(⩾﹏⩽)",
"{ಠʖಠ}"
};

public static string GetRandomSadFace()
{
var random = new Random();
int index = random.Next(SadFaces.Count);
return SadFaces[index];
}



}
}
25 changes: 25 additions & 0 deletions SpeckleRevitReboot/SpeckleProgressBar.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Window
x:Class="SpeckleRevit.SpeckleProgressBar"
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:SpeckleRevit"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="Speckle is working..."
SizeToContent="WidthAndHeight"
mc:Ignorable="d">
<Grid>
<StackPanel HorizontalAlignment="Center" Orientation="Vertical">
<ProgressBar
Name="Progress"
Width="500"
Height="5"
Margin="20,25,20,0" />
<Label
Name="ProgressText"
Margin="20,20,20,20"
HorizontalAlignment="Center"
Content="I'm a a progress bar" />
</StackPanel>
</Grid>
</Window>
27 changes: 27 additions & 0 deletions SpeckleRevitReboot/SpeckleProgressBar.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SpeckleRevit
{
/// <summary>
/// Interaction logic for ProgressBar.xaml
/// </summary>
public partial class SpeckleProgressBar : Window
{
public SpeckleProgressBar()
{
InitializeComponent();
}
}
}
18 changes: 14 additions & 4 deletions SpeckleRevitReboot/SpeckleRevit.csproj
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4937638C-8A51-4F50-9BD2-E7F7AC28DD01}</ProjectGuid>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SpeckleRevit</RootNamespace>
@@ -108,14 +109,14 @@
<HintPath>..\packages\Revit.RevitApiUI.x64.2019.0.0\lib\net45\RevitAPIUI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="SpeckleCore, Version=1.6.9.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\SpeckleCore.1.6.9\lib\net45\SpeckleCore.dll</HintPath>
<Reference Include="SpeckleCore, Version=1.6.17.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\SpeckleCore.1.6.17-wip\lib\net45\SpeckleCore.dll</HintPath>
</Reference>
<Reference Include="SpecklePopup, Version=1.6.13.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SpecklePopup.1.6.13\lib\net45\SpecklePopup.dll</HintPath>
</Reference>
<Reference Include="SpeckleUiBase, Version=1.1.1.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\SpeckleUiBase.1.1.1-wip\lib\net452\SpeckleUiBase.dll</HintPath>
<Reference Include="SpeckleUiBase, Version=1.1.4.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\SpeckleUiBase.1.1.4-wip\lib\net452\SpeckleUiBase.dll</HintPath>
</Reference>
<Reference Include="SQLite-net, Version=1.5.231.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\sqlite-net-pcl.1.5.231\lib\netstandard1.1\SQLite-net.dll</HintPath>
@@ -151,6 +152,9 @@
<ItemGroup>
<Compile Include="ErrorEater.cs" />
<Compile Include="Globals.cs" />
<Compile Include="SpeckleProgressBar.xaml.cs">
<DependentUpon>SpeckleProgressBar.xaml</DependentUpon>
</Compile>
<Compile Include="Storage\HelperClasses.cs" />
<Compile Include="Storage\SpeckleClientsStorage.cs" />
<Compile Include="Entry.cs" />
@@ -171,6 +175,12 @@
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Page Include="SpeckleProgressBar.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- <Target Name="BeforeBuild">
<MakeDir Directories="$(TargetDir)\app" />
Loading

0 comments on commit 4d43649

Please sign in to comment.