diff --git a/.vscode/settings.json b/.vscode/settings.json index 444722ff71..f5bc003aa2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,10 +8,10 @@ }, "omnisharp.enableEditorConfigSupport": true, "omnisharp.enableRoslynAnalyzers": true, - "omnisharp.defaultLaunchSolution": "SDK.slnf", "[dotnet][xml]": { "editor.defaultFormatter": "ms-dotnettools.csharp", "editor.tabSize": 2 }, - "xml.format.spaceBeforeEmptyCloseTag": false + "xml.format.spaceBeforeEmptyCloseTag": false, + "dotnet.defaultSolution": "SDK.slnf" } diff --git a/ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs b/ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs index 7f032e2d07..fe2319801a 100644 --- a/ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs +++ b/ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/UI/MappingBindingsRhino.cs @@ -73,7 +73,10 @@ private List GetObjectSchemas(RhinoObject obj) result.Add(existingSchema); if (obj is InstanceObject) + { + result.Add(new BlockDefinitionViewModel()); result.Add(new RevitFamilyInstanceViewModel()); + } else switch (obj.Geometry) { diff --git a/DesktopUI2/DesktopUI2/ViewModels/MappingTool/MappingsViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/MappingTool/MappingsViewModel.cs index 60fc80505c..8434ff27bd 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/MappingTool/MappingsViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/MappingTool/MappingsViewModel.cs @@ -315,6 +315,7 @@ private void AddRevitInfoToSchema(List schemas) //no need to do extra stuff if ( schema is DirectShapeFreeformViewModel + || schema is BlockDefinitionViewModel || schema is RevitTopographyViewModel || schema is RevitDefaultWallViewModel || schema is RevitDefaultFloorViewModel diff --git a/DesktopUI2/DesktopUI2/ViewModels/MappingTool/Schemas.cs b/DesktopUI2/DesktopUI2/ViewModels/MappingTool/Schemas.cs index 92bfcdfbb4..99e52e0b2b 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/MappingTool/Schemas.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/MappingTool/Schemas.cs @@ -4,6 +4,7 @@ using System.Runtime.Serialization; using Objects.BuiltElements; using Objects.BuiltElements.Revit; +using Objects.Other; using Objects.BuiltElements.Revit.RevitRoof; using ReactiveUI; using Speckle.Core.Api; @@ -378,7 +379,6 @@ public DirectShapeFreeformViewModel() .Select(x => x.ToString()) .OrderBy(x => x) .ToList(); - ; } public override string Name => "DirectShape"; @@ -437,6 +437,57 @@ public override string GetSerializedSchema() } } +public class BlockDefinitionViewModel : Schema +{ + private List _categories; + + private string _selectedCategory = RevitCategory.GenericModel.ToString(); + + public BlockDefinitionViewModel() + { + Categories = Enum.GetValues(typeof(RevitCategory)) + .Cast() + .Select(x => x.ToString()) + .OrderBy(x => x) + .ToList(); + ; + } + + public override string Name => "New Revit Family"; + + public List Categories + { + get => _categories; + set => this.RaiseAndSetIfChanged(ref _categories, value); + } + + [DataMember] + public string SelectedCategory + { + get => _selectedCategory; + set + { + this.RaiseAndSetIfChanged(ref _selectedCategory, value); + this.RaisePropertyChanged(nameof(IsValid)); + } + } + public override string Summary => $"New Revit Family - {SelectedCategory}"; + + public override bool IsValid => !string.IsNullOrEmpty(SelectedCategory); + + public override string GetSerializedSchema() + { + var res = Enum.TryParse(SelectedCategory, out RevitCategory cat); + if (!res) + cat = RevitCategory.GenericModel; + + var ds = new MappedBlockWrapper(); //don't use the constructor + ds.category = cat.ToString(); + + return Operations.Serialize(ds); + } +} + public class RevitDefaultWallViewModel : Schema { public override string Name => "Default Wall"; diff --git a/DesktopUI2/DesktopUI2/Views/MappingsControl.xaml b/DesktopUI2/DesktopUI2/Views/MappingsControl.xaml index d160f47e97..6054bc9214 100644 --- a/DesktopUI2/DesktopUI2/Views/MappingsControl.xaml +++ b/DesktopUI2/DesktopUI2/Views/MappingsControl.xaml @@ -347,17 +347,25 @@ IsChecked="{Binding Freeform}" />--> - + + + + +