diff --git a/CarsonsAddins/Shared/Updaters/PipeEndPrepBCUpdater.cs b/CarsonsAddins/Automation/PipeEndPrep/Models/PipeEndPrepBCUpdater.cs
similarity index 100%
rename from CarsonsAddins/Shared/Updaters/PipeEndPrepBCUpdater.cs
rename to CarsonsAddins/Automation/PipeEndPrep/Models/PipeEndPrepBCUpdater.cs
diff --git a/CarsonsAddins/Shared/Updaters/PipeEndPrepUpdater.cs b/CarsonsAddins/Automation/PipeEndPrep/Models/PipeEndPrepUpdater.cs
similarity index 100%
rename from CarsonsAddins/Shared/Updaters/PipeEndPrepUpdater.cs
rename to CarsonsAddins/Automation/PipeEndPrep/Models/PipeEndPrepUpdater.cs
diff --git a/CarsonsAddins/Automation/PipeEndPrep/ViewModels/PipeEndPrepBCWindow.xaml.cs b/CarsonsAddins/Automation/PipeEndPrep/ViewModels/PipeEndPrepBCWindow.xaml.cs
index eeab83d..b382805 100644
--- a/CarsonsAddins/Automation/PipeEndPrep/ViewModels/PipeEndPrepBCWindow.xaml.cs
+++ b/CarsonsAddins/Automation/PipeEndPrep/ViewModels/PipeEndPrepBCWindow.xaml.cs
@@ -3,7 +3,6 @@
using Autodesk.Revit.UI;
using CarsonsAddins.Properties;
using CarsonsAddins.Utils;
-using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
diff --git a/CarsonsAddins/Automation/PipeEndPrep/ViewModels/PipeEndPrepWindow.xaml.cs b/CarsonsAddins/Automation/PipeEndPrep/ViewModels/PipeEndPrepWindow.xaml.cs
index c2fe7cf..a004de4 100644
--- a/CarsonsAddins/Automation/PipeEndPrep/ViewModels/PipeEndPrepWindow.xaml.cs
+++ b/CarsonsAddins/Automation/PipeEndPrep/ViewModels/PipeEndPrepWindow.xaml.cs
@@ -234,7 +234,7 @@ public PipeEndPrepPreferences(string pipeTypeId, string pipeTypeName)
this.pipeTypeId = pipeTypeId;
this.pipeTypeName = pipeTypeName;
}
- [JsonConstructor]
+ [System.Text.Json.Serialization.JsonConstructor]
public PipeEndPrepPreferences(string pipeTypeId, string pipeTypeName, string bellEndPrep, string spigotEndPrep)
{
this.pipeTypeId = pipeTypeId;
diff --git a/CarsonsAddins/CarsonsAddins.csproj b/CarsonsAddins/CarsonsAddins.csproj
index 28ae44b..bf6368a 100644
--- a/CarsonsAddins/CarsonsAddins.csproj
+++ b/CarsonsAddins/CarsonsAddins.csproj
@@ -50,6 +50,10 @@
CarsonsAddins
+
+ enable
+ 8.0
+
@@ -60,22 +64,19 @@
true
-
- False
- ..\..\..\..\..\..\Program Files\Autodesk\Revit 2021\AdWindows.dll
+
+ E:\Revit\Product\Revit 2023\AdWindows.dll
-
- ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll
+
+ E:\Revit\Product\Revit 2023\AddIns\PnIDModeler\Newtonsoft.Json.dll
-
- False
- ..\..\..\..\..\..\Program Files\Autodesk\Revit 2021\RevitAPI.dll
+
+ E:\Revit\Product\Revit 2023\RevitAPI.dll
-
- False
- ..\..\..\..\..\..\Program Files\Autodesk\Revit 2021\RevitAPIUI.dll
+
+ E:\Revit\Product\Revit 2023\RevitAPIUI.dll
@@ -87,11 +88,7 @@
3.5
-
- ..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll
- True
- True
-
+
@@ -103,20 +100,44 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DimensionSettingsControl.xaml
+
+
+ DimensionTypeSelectorControl.xaml
+
+
+ FlangeModeSelectorControl.xaml
+
-
-
-
-
-
+
+
+
+
+
+
+
+ ParameterManagerDockablePane.xaml
+
+
+
+
+
+ SettingsPluginControl.xaml
+
@@ -133,37 +154,51 @@
CarsonsAddinsApplication.cs
-
-
+
+
+ GraphicsStylesSelectorControl.xaml
+
+
+
+ MyApplicationSettingsWindow.xaml
+
-
+
-
+
+
+ CopyTaskDialog.xaml
+
+
-
-
-
-
-
-
-
+
+ TextBoxWithLabel.xaml
+
+
+ ToggleableTextBox.xaml
+
+
+
+
+
+
-
+
+
-
@@ -176,7 +211,6 @@
-
SettingsSingleFileGenerator
MySettings.Designer.cs
@@ -191,62 +225,65 @@
MSBuild:Compile
Designer
-
+
MSBuild:Compile
Designer
-
-
+
+
MSBuild:Compile
Designer
-
-
+
+
MSBuild:Compile
Designer
-
-
+
+
Designer
MSBuild:Compile
-
- MSBuild:Compile
+
Designer
-
-
MSBuild:Compile
- Designer
-
- MSBuild:Compile
+
Designer
+ MSBuild:Compile
MSBuild:Compile
Designer
-
+
+ Designer
MSBuild:Compile
+
+
Designer
+ MSBuild:Compile
-
+
+ Designer
MSBuild:Compile
+
+
Designer
+ MSBuild:Compile
-
+
+ Designer
MSBuild:Compile
+
+
Designer
+ MSBuild:Compile
- MSBuild:Compile
Designer
+ MSBuild:Compile
-
-
-
-
-
-
+
@@ -257,5 +294,40 @@
+
+
+
+
+
+ 8.0.0
+
+
+ 4.5.1
+
+
+ 4.5.5
+
+
+ 4.5.0
+
+
+ 4.3.1
+
+
+ 6.0.0
+
+
+ 8.0.0
+
+
+ 8.0.4
+
+
+ 4.5.4
+
+
+ 4.5.0
+
+
\ No newline at end of file
diff --git a/CarsonsAddins/CarsonsAddinsApplication.cs b/CarsonsAddins/CarsonsAddinsApplication.cs
index cfd33f0..35279db 100644
--- a/CarsonsAddins/CarsonsAddinsApplication.cs
+++ b/CarsonsAddins/CarsonsAddinsApplication.cs
@@ -33,6 +33,10 @@
using Newtonsoft.Json;
using System.Windows.Forms;
using System.Runtime.InteropServices;
+using CarsonsAddins.GenericCommands;
+using CarsonsAddins.Settings.ComponentStates.Models;
+using CarsonsAddins.Settings.Main.Views;
+using CarsonsAddins.Settings.Dimensioning.Models;
namespace CarsonsAddins
{
@@ -43,8 +47,6 @@ public partial class CarsonsAddinsApplication : IExternalApplication
public static string tmplog = string.Empty;
private List componentStates = new List();
private readonly List settingsComponents = new List();
- public static CarsonsAddinsApplication instance { get; private set; }
- public CarsonsAddinsApplication() { instance = this; }
public Result OnStartup(UIControlledApplication app)
{
ApplicationIds.Init();
@@ -52,46 +54,69 @@ public Result OnStartup(UIControlledApplication app)
RibbonPanel panel = app.CreateRibbonPanel("Carsons Addins", "Tools");
Assembly assembly = Assembly.GetExecutingAssembly();
- MyApplicationSettings.Instance = new MyApplicationSettings();
+
+ ComponentStatePreferences.Instance = new ComponentStatePreferences();
// Always loads in the Application Settings Window
panel.AddItem(MyApplicationSettingsWindow.RegisterButton(assembly));
// Then loads in ComponentStates based on the user's saved preference on which Component should be enabled at launch ( or loads in whichever is not a work in progress component by default )
- componentStates = MyApplicationSettings.Instance.InitComponentStates(assembly);
+ componentStates = ComponentStatePreferences.Instance.InitComponentStates(assembly);
Dictionary pulldownButtonDictionary = new Dictionary();
-
- PulldownButtonData automationPullDownButtonData = new PulldownButtonData("AutomationPullDownButton", "Automation")
+ if (componentStates.Any(component => component.FolderName == "Automation" && component.IsEnabled))
+ {
+ PulldownButtonData automationPullDownButtonData = new PulldownButtonData("AutomationPullDownButton", "Automation")
+ {
+ ToolTip = "All tools for automating tasks.",
+ Image = Utils.MediaUtils.GetImage(assembly, "CarsonsAddins.Resources.automation_icon_32.png"),
+ LargeImage = Utils.MediaUtils.GetImage(assembly, "CarsonsAddins.Resources.automation_icon_32.png")
+ };
+ PulldownButton automationPullDownButton = panel.AddItem(automationPullDownButtonData) as PulldownButton;
+ pulldownButtonDictionary.Add("Automation", automationPullDownButton);
+ }
+ if (componentStates.Any(component => component.FolderName == "Dimensioning" && component.IsEnabled))
{
- ToolTip = "All tools with their own dedicated window or dockable pane.",
- Image = Utils.MediaUtils.GetImage(assembly, "CarsonsAddins.Resources.automation_icon_32.png"),
- LargeImage = Utils.MediaUtils.GetImage(assembly, "CarsonsAddins.Resources.automation_icon_32.png")
- };
- PulldownButton automationPullDownButton = panel.AddItem(automationPullDownButtonData) as PulldownButton;
- pulldownButtonDictionary.Add("Automation", automationPullDownButton);
- // Includes all components with UI, such as Windows and DockablePanes
- PulldownButtonData dimensioningPulldownButtonData = new PulldownButtonData("UIComponentsPullDownButton", "Dimensioning")
+ PulldownButtonData dimensioningPulldownButtonData = new PulldownButtonData("UIComponentsPullDownButton", "Dimensioning")
+ {
+ ToolTip = "All tools for creating or manipulating dimensions.",
+ Image = Utils.MediaUtils.GetImage(assembly, "CarsonsAddins.Resources.dimension_icon_32.png"),
+ LargeImage = Utils.MediaUtils.GetImage(assembly, "CarsonsAddins.Resources.dimension_icon_32.png")
+ };
+ PulldownButton dimensioningPulldownButton = panel.AddItem(dimensioningPulldownButtonData) as PulldownButton;
+ pulldownButtonDictionary.Add("Dimensioning", dimensioningPulldownButton);
+ }
+ if (componentStates.Any(component => component.FolderName == "Debug" && component.IsEnabled))
{
- ToolTip = "All tools with their own dedicated window or dockable pane.",
- Image = Utils.MediaUtils.GetImage(assembly, "CarsonsAddins.Resources.dimension_icon_32.png"),
- LargeImage = Utils.MediaUtils.GetImage(assembly, "CarsonsAddins.Resources.dimension_icon_32.png")
- };
- PulldownButton dimensioningPulldownButton = panel.AddItem(dimensioningPulldownButtonData) as PulldownButton;
- pulldownButtonDictionary.Add("Dimensioning", dimensioningPulldownButton);
- // Includes all components without UI
- PulldownButtonData miscComponentsPulldownButtonData = new PulldownButtonData("MiscComponentsPullDownButton", "Misc")
+ PulldownButtonData debugPulldownButtonData = new PulldownButtonData("DebugPullDownButton", "Debug")
+ {
+ ToolTip = "All tools for development purposes.",
+ };
+ PulldownButton debugPulldownButton = panel.AddItem(debugPulldownButtonData) as PulldownButton;
+ pulldownButtonDictionary.Add("Debug", debugPulldownButton);
+ }
+ if (componentStates.Any(component => component.FolderName == "Misc" && component.IsEnabled))
{
- ToolTip = "All tools without their own dedicated window or dockable pane.",
-
- };
- PulldownButton miscComponentsPulldownButton = panel.AddItem(miscComponentsPulldownButtonData) as PulldownButton;
- pulldownButtonDictionary.Add("Misc", miscComponentsPulldownButton);
+ PulldownButtonData miscComponentsPulldownButtonData = new PulldownButtonData("MiscComponentsPullDownButton", "Misc")
+ {
+ ToolTip = "All tools without their own dedicated window or dockable pane.",
+
+ };
+ PulldownButton miscComponentsPulldownButton = panel.AddItem(miscComponentsPulldownButtonData) as PulldownButton;
+ pulldownButtonDictionary.Add("Misc", miscComponentsPulldownButton);
+ }
RegisterComponentPushButtons(assembly, panel, pulldownButtonDictionary);
app.ControlledApplication.ApplicationInitialized += RegisterDockablePanes;
+ app.ViewActivated += CheckIfFocusingOnNewDocument;
return Result.Succeeded;
}
-
+ private void CheckIfFocusingOnNewDocument(object sender, ViewActivatedEventArgs e)
+ {
+ if (e.CurrentActiveView?.Document == null || e.CurrentActiveView?.Document == e.PreviousActiveView?.Document) return;
+
+ DimensionPreferences.Instance = DimensionPreferences.CreateFromPreferences(e.CurrentActiveView.Document);
+ }
+
public Result OnShutdown(UIControlledApplication app)
{
return Result.Succeeded;
@@ -125,9 +150,9 @@ private void RegisterComponentPushButtons(Assembly assembly, RibbonPanel panel,
}
}
- ///
- /// Registers all of the classes with a SettingsComponent that contain a DockablePane via reflection.
- ///
+ ///
+ /// Registers all of the classes with a SettingsComponent that contain a DockablePane via reflection.
+ ///
private void RegisterDockablePanes(object sender, ApplicationInitializedEventArgs e)
{
UIApplication uiapp = new UIApplication(sender as Autodesk.Revit.ApplicationServices.Application);
@@ -136,9 +161,9 @@ private void RegisterDockablePanes(object sender, ApplicationInitializedEventArg
if (!(component is IDockablePaneProvider)) continue;
if (component is ISettingsUIComponent uiComponent)
{
- Type registerCommandType = typeof( GenericCommands.RegisterDockablePane<>).MakeGenericType(uiComponent.GetType());
+ Type registerCommandType = typeof( RegisterDockablePane<>).MakeGenericType(uiComponent.GetType());
var registerCommand = Activator.CreateInstance(registerCommandType);
- if (registerCommand is GenericCommands.IExecuteWithUIApplication command) command.Execute(uiapp);
+ if (registerCommand is IExecuteWithUIApplication command) command.Execute(uiapp);
}
}
}
diff --git a/CarsonsAddins/Shared/Updaters/PipingLCUpdater.cs b/CarsonsAddins/Deprecated/PipingLC/Models/PipingLCUpdater.cs
similarity index 100%
rename from CarsonsAddins/Shared/Updaters/PipingLCUpdater.cs
rename to CarsonsAddins/Deprecated/PipingLC/Models/PipingLCUpdater.cs
diff --git a/CarsonsAddins/Deprecated/SimpleFilter/ViewModels/SimpleFilterDockablePane.xaml.cs b/CarsonsAddins/Deprecated/SimpleFilter/ViewModels/SimpleFilterDockablePane.xaml.cs
index a046b92..8604a71 100644
--- a/CarsonsAddins/Deprecated/SimpleFilter/ViewModels/SimpleFilterDockablePane.xaml.cs
+++ b/CarsonsAddins/Deprecated/SimpleFilter/ViewModels/SimpleFilterDockablePane.xaml.cs
@@ -136,7 +136,7 @@ private void CheckNoneButtonPress(object sender, RoutedEventArgs e)
SetAllCategoriesToSelectionState(false);
foreach (CategorySelectionItem item in categorySelectionItems) b += item.ToString() + '\n';
- TaskDialog.Show("Comparing Check None Action", "BEFORE: \n " + a + "\n\nAFTER: \n" + b);
+ TaskDialog.Show("Comparing Check Default Action", "BEFORE: \n " + a + "\n\nAFTER: \n" + b);
}
private void ApplySelectionButtonPress(object sender, RoutedEventArgs e)
diff --git a/CarsonsAddins/Pipeline/Models/DimensionPipeLineCommand.cs b/CarsonsAddins/Dimensioning/DimensionPipeline/DimensionPipeLineCommand.cs
similarity index 100%
rename from CarsonsAddins/Pipeline/Models/DimensionPipeLineCommand.cs
rename to CarsonsAddins/Dimensioning/DimensionPipeline/DimensionPipeLineCommand.cs
diff --git a/CarsonsAddins/Pipeline/Models/DimensionPipeline.cs b/CarsonsAddins/Dimensioning/DimensionPipeline/DimensionPipeline.cs
similarity index 84%
rename from CarsonsAddins/Pipeline/Models/DimensionPipeline.cs
rename to CarsonsAddins/Dimensioning/DimensionPipeline/DimensionPipeline.cs
index b95f403..4b67d94 100644
--- a/CarsonsAddins/Pipeline/Models/DimensionPipeline.cs
+++ b/CarsonsAddins/Dimensioning/DimensionPipeline/DimensionPipeline.cs
@@ -10,6 +10,7 @@
using Autodesk.Revit.UI;
using System.Runtime.ExceptionServices;
using System.Windows.Controls;
+using CarsonsAddins.Settings.Dimensioning.Models;
namespace CarsonsAddins.Pipeline.Models
{
@@ -60,8 +61,8 @@ public static void CreateDimensions(Document doc, Element[] elements, Element se
View activeView = doc.ActiveView;
Plane plane = GeometryUtils.GetOrCreatePlane(doc);
- DimensionStyles dimensionStyles = DimensionSettingsWindow.DimensionStylesSettings ?? new DimensionStyles();
- ElementId[] validStyleIds = dimensionStyles.centerlineStyles.Select(style => style.Id).ToArray();
+ DimensionPreferences dimensionPreferences = DimensionPreferences.Instance ?? new DimensionPreferences();
+ ElementId[] validStyleIds = dimensionPreferences.linesStyles.Select(style => style.Id).ToArray();
ElementId defaultDimensionTypeId = doc.GetDefaultElementTypeId(ElementTypeGroup.LinearDimensionType);
DimensionType defaultDimensionType = (defaultDimensionTypeId != ElementId.InvalidElementId) ? doc.GetElement(defaultDimensionTypeId) as DimensionType : default;
@@ -90,49 +91,78 @@ public static void CreateDimensions(Document doc, Element[] elements, Element se
//Calculates the secondary dimension line by creating a line parallel to the primary dimension line but offset a distance based on the dimension type settings
//( right now it only checks the pipe dimension type settings, but it should choose the type with the largest text and text offset )
- Line secondaryDimensionLine = CreateSecondaryDimensionLine(doc.ActiveView, dimensionStyles.secondaryPipeDimensionType ?? defaultDimensionType, projectedElementLine, primaryDimensionLine);
+ Line secondaryDimensionLine = CreateSecondaryDimensionLine(doc.ActiveView, dimensionPreferences.secondaryPipeDimensionType ?? defaultDimensionType, projectedElementLine, primaryDimensionLine);
//Creates a reference array for the primary dimension based on its end point references.
ReferenceArray primaryReferenceArray = new ReferenceArray();
//ReferenceArray secondaryReferenceArray = new ReferenceArray();
- PipingElementReferenceOrderedList referenceSets = new PipingElementReferenceOrderedList(validStyleIds, doc.ActiveView, elements);
- referenceSets.SubtractFlanges();
+ DimensionReferences referenceSets = new DimensionReferences(validStyleIds, doc.ActiveView, dimensionPreferences, elements);
ReferenceArray secondaryReferenceArray = new ReferenceArray();
bool matchesPrimary = true;
for (int i = 0; i < referenceSets.nodes.Length; i++)
{
- if (referenceSets.nodes[i].isNonConnector) continue;
- PipingElementReferenceOrderedList.ReferenceNode node = referenceSets.nodes[i];
+ DimensionReferences.ReferenceNode node = referenceSets.nodes[i];
+ if (node.ignore) continue;
- AddReferences(ref primaryReferenceArray, ref secondaryReferenceArray, node, secondaryDimension);
- if (node.firstReference != null || node.lastReference != null) matchesPrimary = false;
- bool splitDimension = (i == referenceSets.nodes.Length - 1) || (node.mode == PipingElementReferenceOrderedList.FlangeDimensionMode.Ignore || (node.mode == PipingElementReferenceOrderedList.FlangeDimensionMode.Partial && (node.isEdge || node.adjacentNonLinear)));
- if (splitDimension && secondaryReferenceArray.Size > 1)
+ matchesPrimary = AddReferences(ref primaryReferenceArray, ref secondaryReferenceArray, node, secondaryDimension, matchesPrimary);
+ bool splitDimension = node.isEnd || node.mode == FlangeDimensionMode.Exact || (node.mode == FlangeDimensionMode.Partial && (node.isEdge || node.adjacentNonLinear));
+ if (splitDimension)
{
+
BuiltInCategory builtInCategory = (node.referenceCount == secondaryReferenceArray.Size) ? node.builtInCategory : BuiltInCategory.OST_PipeCurves;
- if (!matchesPrimary) doc.Create.NewDimension(activeView, secondaryDimensionLine, secondaryReferenceArray, dimensionStyles.GetSecondaryDimensionType(builtInCategory) ?? defaultDimensionType);
- secondaryReferenceArray.Clear();
- matchesPrimary = true;
+ if (!matchesPrimary)
+ {
+ if (secondaryReferenceArray.Size > 1) doc.Create.NewDimension(activeView, secondaryDimensionLine, secondaryReferenceArray, dimensionPreferences.GetSecondaryDimensionType(builtInCategory) ?? defaultDimensionType);
+ secondaryReferenceArray.Clear();
+ matchesPrimary = true;
+ }
+ else if (node.centerReference != null)
+ {
+ secondaryReferenceArray.Clear();
+ matchesPrimary = true;
+ }
}
}
- doc.Create.NewDimension(activeView, primaryDimensionLine, primaryReferenceArray, dimensionStyles.primaryDimensionType ?? defaultDimensionType);
+ doc.Create.NewDimension(activeView, primaryDimensionLine, primaryReferenceArray, dimensionPreferences.primaryDimensionType ?? defaultDimensionType);
}
- private static void AddReferences(ref ReferenceArray primaryReferenceArray, ref ReferenceArray secondaryReferenceArray, PipingElementReferenceOrderedList.ReferenceNode node, bool secondaryDimension)
- {
- if (node.isStart && node.centerReference == null && node.lastReference != null) primaryReferenceArray.Append(node.lastReference);
- if (node.centerReference != null) primaryReferenceArray.Append(node.centerReference);
- if (node.isEnd && node.centerReference == null && node.firstReference != null) primaryReferenceArray.Append(node.firstReference);
+ private static bool AddReferences(ref ReferenceArray primaryReferenceArray, ref ReferenceArray secondaryReferenceArray, DimensionReferences.ReferenceNode node, bool secondaryDimension, bool matchesPrimary)
+ {
+ int addedFirst = 0;
+ int addedCenter = 0;
+ int addedLast = 0;
+ if (node.isEdge)
+ {
+ if (node.isLinear)
+ {
+ if (node.isEnd) AddReferenceIfNotNull(ref primaryReferenceArray, node.lastReference, ref addedLast);
+ else if (node.isStart) AddReferenceIfNotNull(ref primaryReferenceArray, node.firstReference, ref addedFirst);
+ }
+ else if (node.centerReference == null)
+ {
+ if (node.isStart) AddReferenceIfNotNull(ref primaryReferenceArray, node.lastReference, ref addedLast);
+ else if (node.isEnd) AddReferenceIfNotNull(ref primaryReferenceArray, node.firstReference, ref addedFirst);
+ }
+ }
+ AddReferenceIfNotNull(ref primaryReferenceArray, node.centerReference, ref addedCenter);
+
if (secondaryDimension)
{
- if (node.firstReference != null) secondaryReferenceArray.Append(node.firstReference);
- if (node.centerReference != null) secondaryReferenceArray.Append(node.centerReference);
- if (node.lastReference != null) secondaryReferenceArray.Append(node.lastReference);
+ AddReferenceIfNotNull(ref secondaryReferenceArray, node.firstReference, ref addedFirst);
+ AddReferenceIfNotNull(ref secondaryReferenceArray, node.centerReference, ref addedCenter);
+ AddReferenceIfNotNull(ref secondaryReferenceArray, node.lastReference, ref addedLast);
}
+ return !(!matchesPrimary || node.mode == FlangeDimensionMode.Exact || addedFirst > 0 || addedLast > 0);
}
+ private static void AddReferenceIfNotNull(ref ReferenceArray referenceArray, Reference reference, ref int counter)
+ {
+ if (referenceArray == null || reference == null) return;
+ referenceArray.Append(reference);
+ counter ++;
+ }
}
}
diff --git a/CarsonsAddins/Dimensioning/DimensionPipeline/DimensionReferences.cs b/CarsonsAddins/Dimensioning/DimensionPipeline/DimensionReferences.cs
new file mode 100644
index 0000000..e178e5c
--- /dev/null
+++ b/CarsonsAddins/Dimensioning/DimensionPipeline/DimensionReferences.cs
@@ -0,0 +1,288 @@
+using Autodesk.Revit.DB;
+using CarsonsAddins.Utils;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using static CarsonsAddins.Utils.DimensioningUtils;
+
+namespace CarsonsAddins.Settings.Dimensioning.Models
+{
+ class DimensionReferences
+ {
+
+ public Element[] orderedElements;
+ public ReferenceNode[] nodes;
+ private DimensionPreferences dimensionPreferences;
+ public DimensionReferences(ElementId[] validStyleIds, View activeView, DimensionPreferences dimensionPreferences, Element[] orderedElements)
+ {
+ this.orderedElements = orderedElements;
+ this.dimensionPreferences = dimensionPreferences;
+ nodes = new ReferenceNode[orderedElements.Length];
+ PopulateNodes(validStyleIds, activeView);
+ }
+
+ private void PopulateNodes(ElementId[] validStyleIds, View activeView)
+ {
+ Plane plane = activeView.SketchPlane.GetPlane();
+ for (int i = 0; i < orderedElements.Length; i++)
+ {
+ CreateReferenceNode(i);
+ }
+ if (nodes.Length > 1)
+ {
+ SetFirstConnector();
+ SetLastConnector();
+
+ }
+ else if (nodes[0].isLinear)
+ {
+ SetSingleElementConnectors();
+ }
+ PopulateNodeReferences(validStyleIds, activeView);
+ FillAdjacentNodeReferences();
+ SetAdjacentNonLinear();
+ MoveEdges();
+ SubtractFlanges();
+ }
+ private void SetFirstConnector()
+ {
+ if (!nodes[0].isLinear) return;
+ Connector connector = ConnectionUtils.GetParallelConnector(ConnectionUtils.GetConnectors(orderedElements[0]).Where(con => ConnectionUtils.IsConnectedTo(orderedElements[1], con)).FirstOrDefault());
+ nodes[0].firstConnector = connector;
+ }
+ private void SetLastConnector()
+ {
+ if (!nodes[nodes.Length - 1].isLinear) return;
+ Connector connector = ConnectionUtils.GetParallelConnector(ConnectionUtils.GetConnectors(orderedElements[nodes.Length - 1]).Where(con => ConnectionUtils.IsConnectedTo(orderedElements[nodes.Length - 2], con)).FirstOrDefault());
+ nodes[nodes.Length - 1].lastConnector = connector;
+ }
+ private void SetSingleElementConnectors()
+ {
+ Connector[] connectors = ConnectionUtils.GetConnectors(orderedElements[0]);
+ nodes[0].firstConnector = connectors[0];
+ nodes[0].lastConnector = connectors[1];
+ }
+ private void CreateReferenceNode(int index)
+ {
+ Element element = orderedElements[index];
+ Connector firstConnector = null;
+ if (index > 0)
+ {
+ (Connector, Connector) connection = ConnectionUtils.TryGetConnection(orderedElements[index - 1], element);
+ firstConnector = connection.Item2;
+ nodes[index - 1].lastConnector = connection.Item1;
+ }
+ bool isLinear = ConnectionUtils.IsLinearElement(element);
+ bool isStart = index == 0;
+ bool isEnd = index == orderedElements.Length - 1;
+ bool isNonConnector = IsNonConnector(element);
+ FlangeDimensionMode mode = dimensionPreferences.GetMode(element);
+ nodes[index] = new ReferenceNode
+ {
+ builtInCategory = (BuiltInCategory)element.Category.Id.IntegerValue,
+ mode = mode,
+ origin = GeometryUtils.GetOrigin(element.Location),
+ isStart = isStart,
+ isEnd = isEnd,
+ isLinear = isLinear,
+ adjacentNonLinear = false,
+ isNonConnector = isNonConnector,
+ ignore = isNonConnector,
+ firstConnector = firstConnector
+ };
+ }
+ private bool IsNonConnector(Element element)
+ {
+ if (element == null) return false;
+ if (!(element is FamilyInstance familyInstance)) return false;
+ return (familyInstance.Symbol.FamilyName == "Non-Connector");
+
+ }
+ private void MoveEdges()
+ {
+ if (nodes[0].isNonConnector || nodes[0].isFlange)
+ {
+ int nextIndex = GetAdjacentElementIndex(1, 1, false, false);
+ if (nextIndex > 0)
+ {
+ for (int i = 0; i < nextIndex; i++) nodes[i].ignore = true;
+ nodes[nextIndex].isStart = true;
+ }
+ }
+ if (nodes[nodes.Length - 1].isNonConnector || nodes[nodes.Length - 1].isFlange)
+ {
+ int previousIndex = GetAdjacentElementIndex(nodes.Length - 2, -1, false, false);
+ if (previousIndex >= 0)
+ {
+ for (int i = nodes.Length - 1; i > previousIndex; i--) nodes[i].ignore = true;
+ nodes[previousIndex].isEnd = true;
+ }
+ }
+ }
+
+ private Reference GetPseudoConnectorReference(ElementId[] validStyleIds, View activeView, Plane plane, Connector connector)
+ {
+ return GeometryUtils.GetPseudoReferenceOfConnector(validStyleIds, GeometryUtils.GetGeometryOptions(activeView), plane, connector) ??
+ GeometryUtils.GetPseudoReferenceOfConnector(validStyleIds, GeometryUtils.GetGeometryOptions(), plane, connector);
+ }
+
+ private Reference FindReference(GeometryUtils.XYZWithReference[] xyzReferences, Plane plane, XYZ xyz)
+ {
+ Reference reference = xyzReferences.Where(xyzReference => xyz.IsAlmostEqualTo(xyzReference.xyz)).FirstOrDefault().reference;
+ if (reference != null) return reference;
+ XYZ projectedXYZ = GeometryUtils.ProjectPointOntoPlane(plane, xyz);
+ Reference projectedReference = xyzReferences.Where(xyzReference => xyz.IsAlmostEqualTo(GeometryUtils.ProjectPointOntoPlane(plane, xyzReference.xyz))).FirstOrDefault().reference;
+ return projectedReference;
+ }
+
+ private void PopulateNodeReferences(ElementId[] validStyleIds, View activeView)
+ {
+ Plane plane = activeView.SketchPlane.GetPlane();
+ GeometryUtils.XYZWithReference[][] nodeReferencesWithView = Enumerable.Range(0,nodes.Length).Select(i => GeometryUtils.XYZWithReference.StripGeometryObjectsWithReferences(validStyleIds, GeometryUtils.GetGeometryOptions(activeView), orderedElements[i])).ToArray();
+ GeometryUtils.XYZWithReference[][] nodeReferencesWithoutView = Enumerable.Range(0, nodes.Length).Select(i => GeometryUtils.XYZWithReference.StripGeometryObjectsWithReferences(validStyleIds, GeometryUtils.GetGeometryOptions(), orderedElements[i])).ToArray();
+ for (int i = 0; i < nodes.Length; i++)
+ {
+ if (nodes[i].firstConnector != null)
+ {
+ XYZ firstConnectorOrigin = nodes[i].firstConnector.Origin;
+ nodes[i].firstReference = FindReference(nodeReferencesWithView[i], plane, firstConnectorOrigin) ?? FindReference(nodeReferencesWithoutView[i], plane, firstConnectorOrigin);
+ }
+ if (!nodes[i].isLinear)
+ {
+ XYZ origin = nodes[i].origin;
+ nodes[i].centerReference = FindReference(nodeReferencesWithView[i], plane, origin) ?? FindReference(nodeReferencesWithoutView[i], plane, origin);
+ }
+ if (nodes[i].lastConnector != null)
+ {
+ XYZ lastConnectorOrigin = nodes[i].lastConnector.Origin;
+ nodes[i].lastReference = FindReference(nodeReferencesWithView[i], plane, lastConnectorOrigin) ?? FindReference(nodeReferencesWithoutView[i], plane, lastConnectorOrigin);
+ }
+
+ }
+ }
+ private void FillAdjacentNodeReferences()
+ {
+ for (int i = 0; i < nodes.Length - 1; i++)
+ {
+ if ((nodes[i].firstReference == null) != (nodes[i + 1].lastReference == null))
+ {
+ Reference reference = nodes[i].lastReference ?? nodes[i + 1].firstReference;
+ nodes[i].lastReference = reference;
+ nodes[i + 1].firstReference = reference;
+ }
+
+ }
+ }
+ private void SetAdjacentNonLinear()
+ {
+ for (int i = 0; i < nodes.Length; i++)
+ {
+ if (nodes[i].isLinear) continue;
+ nodes[i].adjacentNonLinear = true;
+ if (i > 0) nodes[i - 1].adjacentNonLinear = true;
+ if (i < nodes.Length - 1) nodes[i + 1].adjacentNonLinear = true;
+ }
+ }
+
+
+ public void SubtractFlanges()
+ {
+ for (int i = 0; i < nodes.Length; i++)
+ {
+ if (nodes[i].isNonConnector) continue;
+ switch(nodes[i].mode)
+ {
+ case (FlangeDimensionMode.None):
+ break;
+ case (FlangeDimensionMode.Exact):
+ IgnoreFlange(i);
+ break;
+ case (FlangeDimensionMode.Partial):
+ PartialFlange(i);
+ break;
+ case (FlangeDimensionMode.Negate):
+ NegateFlange(i);
+ break;
+
+ }
+ }
+ }
+ private void IgnoreFlange(int index)
+ {
+ if (index < 0 || index >= nodes.Length) return;
+ nodes[index].firstReference = null;
+ nodes[index].lastReference = null;
+ }
+ private void NegateFlange(int index)
+ {
+ if (index < 0 || index >= nodes.Length) return;
+ nodes[index].firstReference = null;
+ nodes[index].lastReference = null;
+ RemoveLastReference(index - 1);
+ RemoveFirstReference(index + 1);
+ }
+ private void PartialFlange(int index)
+ {
+ if (index < 0 || index >= nodes.Length) return;
+ else if (nodes[index].isStart || nodes[index].isEnd || NextToNonLinear(index)) IgnoreFlange(index);
+ else NegateFlange(index);
+ }
+ private int GetAdjacentElementIndex(int index, int direction, bool allowNonConnectors, bool allowFlanges)
+ {
+ if (direction == 0 || index < 0 || index >= nodes.Length) return -1;
+ bool passesFlangeFilter = (allowFlanges || (!allowFlanges && !nodes[index].isFlange));
+ bool passesNonConnectorFilter = (allowNonConnectors || (!allowNonConnectors && !nodes[index].isNonConnector));
+ if (passesFlangeFilter && passesNonConnectorFilter) return index;
+ return GetAdjacentElementIndex(index + direction, direction, allowNonConnectors, allowFlanges);
+ }
+ private bool NextToNonLinear(int index)
+ {
+ if (index < 0 || index >= nodes.Length) return false;
+ int previousIndex = GetAdjacentElementIndex(index - 1, -1, false, true);
+ int nextIndex = GetAdjacentElementIndex(index + 1, 1, false, true);
+ if (previousIndex >= 0 && !nodes[previousIndex].isLinear) return true;
+ if (nextIndex >= 0 && !nodes[nextIndex].isLinear) return true;
+ return false;
+ }
+
+ private void RemoveLastReference(int index)
+ {
+ if (index < 0 || index >= nodes.Length) return;
+ if (nodes[index].isNonConnector) RemoveLastReference(index - 1);
+ nodes[index].lastReference = null;
+ }
+ private void RemoveFirstReference(int index)
+ {
+ if (index < 0 || index >= nodes.Length) return;
+ if (nodes[index].isNonConnector) RemoveFirstReference(index + 1);
+ nodes[index].firstReference = null;
+ }
+ public struct ReferenceNode
+ {
+ public BuiltInCategory builtInCategory;
+ public FlangeDimensionMode mode;
+ public bool isFlange => mode != FlangeDimensionMode.Default;
+ public XYZ origin;
+ public bool isStart;
+ public bool isEnd;
+ public bool isEdge => isStart || isEnd;
+ public int referenceCount => ((firstReference != null) ? 1 : 0) + ((lastReference != null) ? 1 : 0) + ((centerReference != null) ? 1 : 0);
+ public bool isLinear;
+ public bool adjacentNonLinear;
+ public bool isNonConnector;
+ public bool ignore;
+ public Reference firstReference;
+ public Reference centerReference;
+ public Reference lastReference;
+ public Connector firstConnector;
+ public Connector lastConnector;
+ }
+ }
+
+
+}
+
diff --git a/CarsonsAddins/Dimensioning/DimensionSettings/ViewModels/DimensionSettingsWindow.xaml.cs b/CarsonsAddins/Dimensioning/DimensionSettings/ViewModels/DimensionSettingsWindow.xaml.cs
deleted file mode 100644
index a890bba..0000000
--- a/CarsonsAddins/Dimensioning/DimensionSettings/ViewModels/DimensionSettingsWindow.xaml.cs
+++ /dev/null
@@ -1,193 +0,0 @@
-using Autodesk.Revit.DB;
-using Autodesk.Revit.UI;
-using CarsonsAddins.Properties;
-using CarsonsAddins.Utils;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Globalization;
-using System.Linq;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-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.Markup;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-using static CarsonsAddins.Utils.DimensioningUtils;
-
-namespace CarsonsAddins
-{
- ///
- /// Interaction logic for DimensionSettingsWindow.xaml
- ///
- public partial class DimensionSettingsWindow : Window, ISettingsUIComponent, INotifyPropertyChanged
- {
- public const string FolderName = "Dimensioning";
- public const bool IsWIP = false;
- public event PropertyChangedEventHandler PropertyChanged;
- private DimensionType[] dimensionTypes;
- private GraphicsStyle[] graphicStyles;
- public static DimensionStyles DimensionStylesSettings;
-
-
- public DimensionSettingsWindow()
- {
-
- InitializeComponent();
- }
-
- public void Init(UIDocument uidoc)
- {
- DimensionStylesSettings = new DimensionStyles();
- BuiltInCategory[] pipingCategories = new BuiltInCategory[] {BuiltInCategory.OST_PipeCurves, BuiltInCategory.OST_PipeFitting, BuiltInCategory.OST_PipeAccessory, BuiltInCategory.OST_MechanicalEquipment, BuiltInCategory.OST_PipeCurvesCenterLine, BuiltInCategory.OST_PipeFittingCenterLine, BuiltInCategory.OST_CenterLines};
- dimensionTypes = new FilteredElementCollector(uidoc.Document).WhereElementIsElementType().OfClass(typeof(DimensionType)).ToElements().Cast().Where(dt => DimensionStyleType.Linear.Equals(dt.StyleType)).ToArray();
- graphicStyles = new FilteredElementCollector(uidoc.Document).OfClass(typeof(GraphicsStyle)).Cast().Where(gs => pipingCategories.Contains((BuiltInCategory)gs.GraphicsStyleCategory.Id.IntegerValue) || ((gs.GraphicsStyleCategory.Parent != null) && pipingCategories.Contains((BuiltInCategory)gs.GraphicsStyleCategory.Parent.Id.IntegerValue))).ToArray();
- LoadFromDB();
- DimensionTypeSelector.Init(dimensionTypes, ref DimensionStylesSettings);
- GraphicsStyleList.Init(graphicStyles, ref DimensionStylesSettings.centerlineStyles);
- //DimensionPreviewControl.AddPreviewControlWithCustomView(uidoc.Document);
- }
- public PushButtonData RegisterButton(Assembly assembly)
- {
- return new PushButtonData("Dimension Pipeline Settings", "Dimension Pipeline Settings", assembly.Location, typeof(GenericCommands.ShowWindow).FullName)
- {
- AvailabilityClassName = typeof(Setup.Availablity.Availability_ProjectDocumentsOnly).FullName,
- ToolTip = "Settings Window for the Dimension Pipeline Command"
- };
- }
- private void LoadFromDB() //requires that Load Dimension Types has been called first
- {
- DimensionStylesSettings = new DimensionStyles();
-
- if (dimensionTypes == null || dimensionTypes.Length == 0) return;
- if (string.IsNullOrWhiteSpace(MySettings.Default.DimensionStyles_Preferences)) return;
-
- try
- {
- DimensionStyleNames dimensionStyleNames = JsonConvert.DeserializeObject(MySettings.Default.DimensionStyles_Preferences);
-
-
- foreach (DimensionType dimensionType in dimensionTypes)
- {
- if (dimensionType.Name == dimensionStyleNames.primaryDimensionTypeName) DimensionStylesSettings.primaryDimensionType = dimensionType;
- if (dimensionType.Name == dimensionStyleNames.secondaryPipeDimensionTypeName) DimensionStylesSettings.secondaryPipeDimensionType = dimensionType;
- if (dimensionType.Name == dimensionStyleNames.secondaryAccessoryDimensionTypeName) DimensionStylesSettings.secondaryAccessoryDimensionType = dimensionType;
- if (dimensionType.Name == dimensionStyleNames.secondaryFittingDimensionTypeName) DimensionStylesSettings.secondaryFittingDimensionType = dimensionType;
- if (dimensionType.Name == dimensionStyleNames.secondaryOtherDimensionTypeName) DimensionStylesSettings.secondaryOtherDimensionType = dimensionType;
- if (DimensionStylesSettings.foundAllDimensionTypes) break;
- }
- if (dimensionStyleNames.centerlineStyleNames != null)
- {
-
- foreach (GraphicsStyle graphicsStyle in graphicStyles)
- {
- if (dimensionStyleNames.centerlineStyleNames.Contains(graphicsStyle.Name)) DimensionStylesSettings.centerlineStyles.Add(graphicsStyle);
- }
- };
-
- }
- catch (Exception ex)
- {
- TaskDialog.Show("Error Loading Dimension Styles from DB", ex.Message);
- }
-
-
- }
-
-
- private void SaveToDB()
- {
- if (DimensionStylesSettings == null) return;
- DimensionStyleNames dimensionStyleNames = DimensionStylesSettings.GetDimensionStyleNames(GraphicsStyleList.SelectedGraphicStyleNames.ToArray());
- try
- {
- MySettings.Default.DimensionStyles_Preferences = JsonConvert.SerializeObject(dimensionStyleNames);
- MySettings.Default.Save();
- } catch (Exception ex)
- {
- TaskDialog.Show("Error Saving Dimension Settings", ex.Message);
- }
-
- }
-
- protected override void OnClosing(CancelEventArgs e)
- {
- Hide();
- SaveToDB();
- e.Cancel = true;
- }
-
- protected void OnNotifyPropertyChanged([CallerMemberName] string memberName = "")
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(memberName));
- }
- }
-
-
- public class DimensionStyles
- {
- public bool foundAllDimensionTypes => primaryDimensionType != null && secondaryPipeDimensionType != null && secondaryAccessoryDimensionType != null && secondaryFittingDimensionType != null && secondaryOtherDimensionType != null;
- public DimensionType primaryDimensionType;
- public DimensionType secondaryPipeDimensionType;
- public DimensionType secondaryAccessoryDimensionType;
- public DimensionType secondaryFittingDimensionType;
- public DimensionType secondaryOtherDimensionType;
- public List centerlineStyles = new List();
- public DimensionType GetSecondaryDimensionType(BuiltInCategory builtInCategory)
- {
- switch (builtInCategory)
- {
- case BuiltInCategory.OST_PipeCurves: return secondaryPipeDimensionType;
- case BuiltInCategory.OST_PipeFitting: return secondaryFittingDimensionType;
- case BuiltInCategory.OST_PipeAccessory: return secondaryAccessoryDimensionType;
- default: return secondaryOtherDimensionType;
- }
- }
- public DimensionStyleNames GetDimensionStyleNames()
- {
- return new DimensionStyleNames
- {
- primaryDimensionTypeName = primaryDimensionType?.Name ?? string.Empty,
- secondaryPipeDimensionTypeName = secondaryPipeDimensionType?.Name ?? string.Empty,
- secondaryAccessoryDimensionTypeName = secondaryAccessoryDimensionType?.Name ?? string.Empty,
- secondaryFittingDimensionTypeName = secondaryFittingDimensionType?.Name ?? string.Empty,
- secondaryOtherDimensionTypeName = secondaryOtherDimensionType?.Name ?? string.Empty,
- centerlineStyleNames = centerlineStyles?.Select(style => style.Name).Distinct().ToArray()
- };
- }
- public DimensionStyleNames GetDimensionStyleNames(string[] graphicStyleNames)
- {
- return new DimensionStyleNames
- {
- primaryDimensionTypeName = primaryDimensionType?.Name ?? string.Empty,
- secondaryPipeDimensionTypeName = secondaryPipeDimensionType?.Name ?? string.Empty,
- secondaryAccessoryDimensionTypeName = secondaryAccessoryDimensionType?.Name ?? string.Empty,
- secondaryFittingDimensionTypeName = secondaryFittingDimensionType?.Name ?? string.Empty,
- secondaryOtherDimensionTypeName = secondaryOtherDimensionType?.Name ?? string.Empty,
- centerlineStyleNames = graphicStyleNames
- };
- }
-
- }
-
- public struct DimensionStyleNames
- {
- public string primaryDimensionTypeName;
- public string secondaryPipeDimensionTypeName;
- public string secondaryAccessoryDimensionTypeName;
- public string secondaryFittingDimensionTypeName;
- public string secondaryOtherDimensionTypeName;
- public string[] centerlineStyleNames;
- }
-
-}
diff --git a/CarsonsAddins/Dimensioning/DimensionSettings/ViewModels/DimensionTypeSelectorControl.xaml.cs b/CarsonsAddins/Dimensioning/DimensionSettings/ViewModels/DimensionTypeSelectorControl.xaml.cs
deleted file mode 100644
index 0a9f30c..0000000
--- a/CarsonsAddins/Dimensioning/DimensionSettings/ViewModels/DimensionTypeSelectorControl.xaml.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-using Autodesk.Revit.DB;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Linq;
-using System.Runtime.CompilerServices;
-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.Navigation;
-using System.Windows.Shapes;
-using static CarsonsAddins.Utils.DimensioningUtils;
-
-namespace CarsonsAddins
-{
- ///
- /// Interaction logic for DimensionTypeSelectorControl.xaml
- ///
- public partial class DimensionTypeSelectorControl : UserControl, INotifyPropertyChanged
- {
- public event PropertyChangedEventHandler PropertyChanged;
-
- private DimensionStyles dimensionStyles = new DimensionStyles();
-
- public DimensionType PrimaryDimensionType
- {
- get => dimensionStyles.primaryDimensionType;
- set
- {
- if (value == null || value == dimensionStyles.primaryDimensionType) return;
- dimensionStyles.primaryDimensionType = value;
- OnNotifyPropertyChanged();
- }
- }
- public DimensionType SecondaryPipeDimensionType
- {
- get => dimensionStyles.secondaryPipeDimensionType;
- set
- {
- if (value == null || value == dimensionStyles.secondaryPipeDimensionType) return;
- dimensionStyles.secondaryPipeDimensionType = value;
- OnNotifyPropertyChanged();
- }
- }
- public DimensionType SecondaryFittingDimensionType
- {
- get => dimensionStyles.secondaryFittingDimensionType;
- set
- {
- if (value == null || value == dimensionStyles.secondaryFittingDimensionType) return;
- dimensionStyles.secondaryFittingDimensionType = value;
- OnNotifyPropertyChanged();
- }
- }
- public DimensionType SecondaryAccessoryDimensionType
- {
- get => dimensionStyles.secondaryAccessoryDimensionType;
- set
- {
- if (value == null || value == dimensionStyles.secondaryAccessoryDimensionType) return;
- dimensionStyles.secondaryAccessoryDimensionType = value;
- OnNotifyPropertyChanged();
- }
- }
- public DimensionType SecondaryOtherDimensionType
- {
- get => dimensionStyles.secondaryOtherDimensionType;
- set
- {
- if (value == null || value == dimensionStyles.secondaryOtherDimensionType) return;
- dimensionStyles.secondaryOtherDimensionType = value;
- OnNotifyPropertyChanged();
- }
- }
-
- public ObservableCollection dimensionTypes = new ObservableCollection();
- public ObservableCollection DimensionTypes { get => dimensionTypes; set => dimensionTypes = value; }
-
- public DimensionTypeSelectorControl()
- {
- InitializeComponent();
- DataContext = this;
- }
-
- public void Init(DimensionType[] dimensionTypes, ref DimensionStyles currentPreferences)
- {
- DimensionTypes = new ObservableCollection(dimensionTypes);
- dimensionStyles = currentPreferences;
- NotifyIntialized();
- }
-
- private void NotifyIntialized()
- {
- if (dimensionStyles == null) return;
- OnNotifyPropertyChanged(nameof(PrimaryDimensionType));
- OnNotifyPropertyChanged(nameof(SecondaryPipeDimensionType));
- OnNotifyPropertyChanged(nameof(SecondaryFittingDimensionType));
- OnNotifyPropertyChanged(nameof(SecondaryAccessoryDimensionType));
- OnNotifyPropertyChanged(nameof(SecondaryOtherDimensionType));
- }
-
- protected void OnNotifyPropertyChanged([CallerMemberName] string memberName = "")
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(memberName));
- }
- }
-}
diff --git a/CarsonsAddins/Dimensioning/DimensionSettings/ViewModels/PreviewControlWrapper.xaml.cs b/CarsonsAddins/Dimensioning/DimensionSettings/ViewModels/PreviewControlWrapper.xaml.cs
deleted file mode 100644
index f2c2323..0000000
--- a/CarsonsAddins/Dimensioning/DimensionSettings/ViewModels/PreviewControlWrapper.xaml.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-using Autodesk.Revit.DB;
-using Autodesk.Revit.UI;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-
-
-namespace CarsonsAddins
-{
- ///
- /// Interaction logic for PreviewControlWrapper.xaml
- ///
- public partial class PreviewControlWrapper : UserControl
- {
- public PreviewControl previewControl;
- /*
- private Document previewDocument;
- public Document PreviewDocument
- {
- get => previewDocument;
- set => previewDocument = value;
- }
- private ElementId viewId = ElementId.InvalidElementId;
- public ElementId ViewId
- {
- get => viewId;
- set => viewId = value;
- }*/
-
- public PreviewControlWrapper()
- {
- InitializeComponent();
- //AddPreviewControl(previewDocument, ViewId);
- }
- public void AddPreviewControlWithCustomView(Document doc)
- {
- if (doc == null) return;
- Transaction transaction = new Transaction(doc);
- transaction.Start("Create Dimension View");
- try
- {
- Level level = Level.Create(doc, 0.0);
- ElementId floorPlanId = doc.GetDefaultElementTypeId(ElementTypeGroup.ViewTypeFloorPlan);
- if (level == null || floorPlanId == ElementId.InvalidElementId)
- {
- transaction.RollBack();
- return;
- }
- ViewPlan viewPlan = ViewPlan.Create(doc, floorPlanId, level.Id);
-
- previewControl = new PreviewControl(doc, viewPlan.Id)
- {
- IsEnabled = false
- };
-
- PreviewControlGrid.Children.Add(previewControl);
-
-
-
- transaction.Commit();
- }
- catch(Exception ex)
- {
- transaction.RollBack();
- TaskDialog.Show("Error Creating Dimension View", ex.Message);
- }
- }
- public void AddPreviewControl(Document doc, ElementId viewId)
- {
- if (doc == null || viewId == ElementId.InvalidElementId) return;
- previewControl = new PreviewControl(doc, viewId);
- PreviewControlGrid.Children.Add(previewControl);
- previewControl.IsHitTestVisible = false;
-
- }
- }
-}
diff --git a/CarsonsAddins/Dimensioning/DimensionSettings/Views/DimensionSettingsWindow.xaml b/CarsonsAddins/Dimensioning/DimensionSettings/Views/DimensionSettingsWindow.xaml
deleted file mode 100644
index 4e0f908..0000000
--- a/CarsonsAddins/Dimensioning/DimensionSettings/Views/DimensionSettingsWindow.xaml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/CarsonsAddins/Dimensioning/DimensionSettings/Views/PreviewControlWrapper.xaml b/CarsonsAddins/Dimensioning/DimensionSettings/Views/PreviewControlWrapper.xaml
deleted file mode 100644
index b1ba4aa..0000000
--- a/CarsonsAddins/Dimensioning/DimensionSettings/Views/PreviewControlWrapper.xaml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/CarsonsAddins/Deprecated/SimpleFilter/Models/SetDimensionTextEventHandler.cs b/CarsonsAddins/Dimensioning/DimensionText/Models/SetDimensionTextEventHandler.cs
similarity index 92%
rename from CarsonsAddins/Deprecated/SimpleFilter/Models/SetDimensionTextEventHandler.cs
rename to CarsonsAddins/Dimensioning/DimensionText/Models/SetDimensionTextEventHandler.cs
index a537faa..9f18119 100644
--- a/CarsonsAddins/Deprecated/SimpleFilter/Models/SetDimensionTextEventHandler.cs
+++ b/CarsonsAddins/Dimensioning/DimensionText/Models/SetDimensionTextEventHandler.cs
@@ -12,10 +12,10 @@ namespace CarsonsAddins
public class SetDimensionsTextEventHandler : IExternalEventHandler
{
private List<(Dimension, DimensionSegment)> dimensionsAndSegments = new List<(Dimension, DimensionSegment)>();
-
- private string above, below, valueOverride, prefix, suffix;
+#nullable enable
+ private string? above, below, valueOverride, prefix, suffix;
public void Inject(List<(Dimension, DimensionSegment)> dimensionsAndSegments) => this.dimensionsAndSegments = dimensionsAndSegments;
- public void Inject(string above = null, string below = null, string valueOverride = null, string prefix = null, string suffix = null)
+ public void Inject(string above = "", string below = "", string valueOverride = "", string prefix = "", string suffix = "")
{
this.above = above;
this.below = below;
diff --git a/CarsonsAddins/Pipeline/Models/PipingElementReferenceOrderedList.cs b/CarsonsAddins/Pipeline/Models/PipingElementReferenceOrderedList.cs
deleted file mode 100644
index 22d1051..0000000
--- a/CarsonsAddins/Pipeline/Models/PipingElementReferenceOrderedList.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-using Autodesk.Revit.DB;
-using CarsonsAddins.Utils;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace CarsonsAddins.Pipeline.Models
-{
- class PipingElementReferenceOrderedList
- {
- public enum FlangeDimensionMode { None, Ignore, Partial, Negate }
- public Element[] orderedElements;
- public ReferenceNode[] nodes;
-
- public PipingElementReferenceOrderedList(ElementId[] validStyleIds, View activeView, Element[] orderedElements)
- {
- this.orderedElements = orderedElements;
- nodes = new ReferenceNode[orderedElements.Length];
- PopulateNodes(validStyleIds, activeView);
- }
-
- private void PopulateNodes(ElementId[] validStyleIds, View activeView)
- {
- Plane plane = activeView.SketchPlane.GetPlane();
- nodes[0] = new ReferenceNode
- {
- builtInCategory = (BuiltInCategory)orderedElements[0].Category.Id.IntegerValue,
- mode = GetMode(orderedElements[0]),
- origin = GeometryUtils.GetOrigin(orderedElements[0].Location),
- isStart = true,
- isEnd = false,
- adjacentNonLinear = false,
- isLinear = ConnectionUtils.IsLinearElement(orderedElements[0]),
- centerReference = (!ElementCheckUtils.IsPipeFlange(orderedElements[0])) ? DimensioningUtils.GetEndReference(activeView, validStyleIds, orderedElements[0]) : null
- };
- nodes[0].adjacentNonLinear = nodes[0].isLinear;
- for (int i = 1; i < orderedElements.Length; i++)
- {
- CreateReferenceNode(validStyleIds, activeView, plane, i);
- }
- SetAdjacentNonLinear();
- }
- private void CreateReferenceNode(ElementId[] validStyleIds, View activeView, Plane plane, int index)
- {
- Element element = orderedElements[index];
-
- (Connector, Connector) connection = ConnectionUtils.TryGetConnection(orderedElements[index - 1], element);
- Reference currentFirstReference = GeometryUtils.GetPseudoReferenceOfConnector(GeometryUtils.GetGeometryOptions(), plane, connection.Item2)
- ?? GeometryUtils.GetPseudoReferenceOfConnector(GeometryUtils.GetGeometryOptions(activeView), plane, connection.Item2);
-
- nodes[index - 1].lastReference = GeometryUtils.GetPseudoReferenceOfConnector(GeometryUtils.GetGeometryOptions(), plane, connection.Item1)
- ?? GeometryUtils.GetPseudoReferenceOfConnector(GeometryUtils.GetGeometryOptions(activeView), plane, connection.Item1) ?? currentFirstReference;
- bool isLinear = ConnectionUtils.IsLinearElement(element);
- bool isEnd = index == orderedElements.Length - 1;
- bool isFlange = ElementCheckUtils.IsPipeFlange(element);
- nodes[index] = new ReferenceNode
- {
- builtInCategory = (BuiltInCategory)element.Category.Id.IntegerValue,
- mode = GetMode(element),
- origin = GeometryUtils.GetOrigin(element.Location),
- isStart = false,
- isEnd = isEnd,
- isLinear = isLinear,
- adjacentNonLinear = false,
- centerReference = isFlange ? null : (isEnd) ? DimensioningUtils.GetEndReference(activeView, validStyleIds, element) : (!isLinear) ? DimensioningUtils.GetCenterReference(validStyleIds, element) : null,
- firstReference = currentFirstReference ?? nodes[index - 1].lastReference,
- };
- }
- private void SetAdjacentNonLinear()
- {
- for (int i = 0; i < nodes.Length; i++)
- {
- if (nodes[i].isLinear) continue;
- nodes[i].adjacentNonLinear = true;
- if (i > 0) nodes[i - 1].adjacentNonLinear = true;
- if (i < nodes.Length - 1) nodes[i + 1].adjacentNonLinear = true;
- }
- }
-
-
- public void SubtractFlanges()
- {
- for (int i = 0; i < nodes.Length; i++)
- {
- if (nodes[i].isNonConnector) continue;
- switch(nodes[i].mode)
- {
- case (FlangeDimensionMode.None):
- break;
- case (FlangeDimensionMode.Ignore):
- IgnoreFlange(i);
- break;
- case (FlangeDimensionMode.Partial):
- PartialFlange(i);
- break;
- case (FlangeDimensionMode.Negate):
- NegateFlange(i);
- break;
-
- }
- }
- }
- private FlangeDimensionMode GetMode(Element element)
- {
- if (!ElementCheckUtils.IsPipeFlange(element)) return FlangeDimensionMode.None;
-
- string familyName = (element as FamilyInstance).Symbol.FamilyName;
- if (familyName.Contains("FLG")) return FlangeDimensionMode.Ignore;
- if (familyName.Contains("MJ") || familyName.Contains("PO")) return FlangeDimensionMode.Negate;
- return FlangeDimensionMode.Partial;
- }
- private void IgnoreFlange(int index)
- {
- if (index < 0 && index >= nodes.Length) return;
- nodes[index].firstReference = null;
- nodes[index].lastReference = null;
- }
- private void NegateFlange(int index)
- {
- if (index < 0 && index >= nodes.Length) return;
- nodes[index].firstReference = null;
- nodes[index].lastReference = null;
- RemoveLastReference(index - 1);
- RemoveFirstReference(index + 1);
- }
- private void PartialFlange(int index)
- {
- if (index < 0 && index >= nodes.Length) return;
- if (nodes[index].isStart || nodes[index].isEnd || NextToNonLinear(index)) IgnoreFlange(index);
- else NegateFlange(index);
- }
- private bool NextToNonLinear(int index) => IsPreviousNonLinear(index) || IsNextNonLinear(index);
- private bool IsNextNonLinear(int index)
- {
- if (index < 0 || index >= nodes.Length - 1) return false;
- if (nodes[index + 1].isNonConnector) return IsNextNonLinear(index + 1);
- return !nodes[index + 1].isLinear;
- }
- private bool IsPreviousNonLinear(int index)
- {
- if (index < 1 || index > nodes.Length - 1) return false;
- if (nodes[index - 1].isNonConnector) return IsNextNonLinear(index - 1);
- return !nodes[index - 1].isLinear;
- }
- private void RemoveLastReference(int index)
- {
- if (index < 0 && index >= nodes.Length) return;
- if (nodes[index].isNonConnector) RemoveLastReference(index - 1);
- nodes[index].lastReference = null;
- }
- private void RemoveFirstReference(int index)
- {
- if (index < 0 && index >= nodes.Length) return;
- if (nodes[index].isNonConnector) RemoveFirstReference(index + 1);
- nodes[index].firstReference = null;
- }
- public struct ReferenceNode
- {
- //public ElementCheckUtils.PipingCategory pipingCategory;
- public BuiltInCategory builtInCategory;
- public FlangeDimensionMode mode;
- public XYZ origin;
- public bool isStart;
- public bool isEnd;
- public bool isEdge => isStart || isEnd;
- public int referenceCount => ((firstReference != null) ? 1 : 0) + ((lastReference != null) ? 1 : 0) + ((centerReference != null) ? 1 : 0);
- public bool isLinear;
- public bool adjacentNonLinear;
- public bool isNonConnector;
- public Reference firstReference;
- public Reference centerReference;
- public Reference lastReference;
-
- }
- }
-
-
-}
-
diff --git a/CarsonsAddins/Properties/MySettings.Designer.cs b/CarsonsAddins/Properties/MySettings.Designer.cs
index 12536b2..9ebe463 100644
--- a/CarsonsAddins/Properties/MySettings.Designer.cs
+++ b/CarsonsAddins/Properties/MySettings.Designer.cs
@@ -12,7 +12,7 @@ namespace CarsonsAddins.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")]
internal sealed partial class MySettings : global::System.Configuration.ApplicationSettingsBase {
private static MySettings defaultInstance = ((MySettings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new MySettings())));
@@ -37,19 +37,7 @@ public string PEP_Preferences {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("")]
- public string LC_Preferences {
- get {
- return ((string)(this["LC_Preferences"]));
- }
- set {
- this["LC_Preferences"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("")]
+ [global::System.Configuration.DefaultSettingValueAttribute(@"{""PipeEndPrepBCWindow"":true,""PipeEndPrepWindow"":false,""DebugSettingsCommand"":false,""DimensionTextWindow"":true,""DimensionPipeLineCommand"":true,""SelectPipeLineCommand"":true,""DebugGeometryCommand"":false,""FilterPipingElementsCommand"":true,""GetTotalPipeLengthCommand"":true,""ParameterManagerDockablePane"":true,""SelectAllElementsOfSystemCommand"":true,""SmartFlipCommand"":true}")]
public string ComponentState_Preferences {
get {
return ((string)(this["ComponentState_Preferences"]));
@@ -61,7 +49,42 @@ public string ComponentState_Preferences {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("")]
+ [global::System.Configuration.DefaultSettingValueAttribute("{\"primaryDimensionTypeName\":\"C & B\",\"secondaryPipeDimensionTypeName\":\"C & B PIPE " +
+ "w/dot\",\"secondaryAccessoryDimensionTypeName\":\"C & B FITTING w/dot\",\"secondaryFit" +
+ "tingDimensionTypeName\":\"C & B FITTING w/dot\",\"secondaryOtherDimensionTypeName\":\"" +
+ "C & B FITTING w/dot\",\"graphicsStyleNames\":[\"\",\"Pipes\",\"Pipe Fittings" +
+ "\",\"zLines\"],\"flangeModeItems\":[{\"elementId\":7465461,\"Name\":\"DI FLG DBL\",\"Mode\":2" +
+ "},{\"elementId\":7151319,\"Name\":\"DI FCA\",\"Mode\":2},{\"elementId\":4634124,\"Name\":\"Co" +
+ "upling - Generic\",\"Mode\":0},{\"elementId\":7047513,\"Name\":\"DI CMJ LONG SLEEVE C153" +
+ "\",\"Mode\":4},{\"elementId\":7230174,\"Name\":\"CS WELD GAP MP\",\"Mode\":0},{\"elementId\":" +
+ "7230980,\"Name\":\"CS WELD GAP\",\"Mode\":0},{\"elementId\":7316050,\"Name\":\"DI FLG DBL f" +
+ "or fillers\",\"Mode\":2},{\"elementId\":7316874,\"Name\":\"DI FLG DBL MP\",\"Mode\":2},{\"el" +
+ "ementId\":7317685,\"Name\":\"DI FLG DBL UN LINKED\",\"Mode\":2},{\"elementId\":7320961,\"N" +
+ "ame\":\"DI FLG SINGLE MP\",\"Mode\":2},{\"elementId\":7322565,\"Name\":\"DI FLG SINGLE\",\"M" +
+ "ode\":2},{\"elementId\":7303217,\"Name\":\"DI FLG GASKET DO NOT SCHEDULE\",\"Mode\":2},{\"" +
+ "elementId\":7315853,\"Name\":\"DI FLG GASKET\",\"Mode\":2},{\"elementId\":7319339,\"Name\":" +
+ "\"DI FLG DBL WITH STUDS\",\"Mode\":2},{\"elementId\":7237273,\"Name\":\"SS WELD GAP\",\"Mod" +
+ "e\":0},{\"elementId\":7252261,\"Name\":\"SS WELD GAP MP\",\"Mode\":0},{\"elementId\":458413" +
+ "5,\"Name\":\"Non-Connector\",\"Mode\":0},{\"elementId\":7030191,\"Name\":\"Victaulic-Groove" +
+ "d Coupling OGS-AGS_Face\",\"Mode\":2},{\"elementId\":7036679,\"Name\":\"DI HP LOK FITTIN" +
+ "G BELL\",\"Mode\":3},{\"elementId\":7039212,\"Name\":\"DI MJ BELL\",\"Mode\":4},{\"elementId" +
+ "\":7040062,\"Name\":\"DI PO BELL\",\"Mode\":4},{\"elementId\":7062627,\"Name\":\"Victaulic-A" +
+ "WWA-Grooved Coupling\",\"Mode\":2},{\"elementId\":7063762,\"Name\":\"DI MJ LONG SLEEVE C" +
+ "110\",\"Mode\":4},{\"elementId\":7105299,\"Name\":\"DI TRFLEX SLEEVE DOMESTIC\",\"Mode\":3}" +
+ ",{\"elementId\":7123588,\"Name\":\"DI TRFLEX SLEEVE IMPORT\",\"Mode\":3},{\"elementId\":72" +
+ "56569,\"Name\":\"DI TR FLEX FITTING BELL MP\",\"Mode\":3},{\"elementId\":7273137,\"Name\":" +
+ "\"DI HP LOK FITTING BELL MP\",\"Mode\":3},{\"elementId\":7275670,\"Name\":\"DI MJ BELL MP" +
+ "\",\"Mode\":4},{\"elementId\":7276520,\"Name\":\"DI PO BELL MP WITH FIELD LOK GASKET\",\"M" +
+ "ode\":2},{\"elementId\":7279034,\"Name\":\"DI PO BELL MP\",\"Mode\":4},{\"elementId\":72844" +
+ "98,\"Name\":\"Victaulic-AWWA-Coupling Style 31_MP\",\"Mode\":2},{\"elementId\":7286104,\"" +
+ "Name\":\"DI VIC STYLE 31 CPLG_MP\",\"Mode\":2},{\"elementId\":7289129,\"Name\":\"DI VIC ST" +
+ "YLE 31 CPLG\",\"Mode\":2},{\"elementId\":7292332,\"Name\":\"DI FLG GASKET w- STUDS\",\"Mod" +
+ "e\":2},{\"elementId\":7306393,\"Name\":\"FLG PACK w TWO GASKETS & EX LONG STUDS w DBL " +
+ "NUTS EA\",\"Mode\":2},{\"elementId\":7309215,\"Name\":\"DI HDSS BELL\",\"Mode\":3},{\"elemen" +
+ "tId\":7311748,\"Name\":\"DI HDSS BELL MP\",\"Mode\":3},{\"elementId\":7314281,\"Name\":\"DI " +
+ "FLG x VIC FLG STYLE 341\",\"Mode\":2},{\"elementId\":7321771,\"Name\":\"DI FLG SINGLE wo" +
+ " GASKET\",\"Mode\":2},{\"elementId\":7466331,\"Name\":\"DI TR FLEX FITTING BELL\",\"Mode\":" +
+ "3}]}")]
public string DimensionStyles_Preferences {
get {
return ((string)(this["DimensionStyles_Preferences"]));
diff --git a/CarsonsAddins/Properties/MySettings.settings b/CarsonsAddins/Properties/MySettings.settings
index b524813..687ed96 100644
--- a/CarsonsAddins/Properties/MySettings.settings
+++ b/CarsonsAddins/Properties/MySettings.settings
@@ -5,14 +5,11 @@
-
-
-
-
+ {"PipeEndPrepBCWindow":true,"PipeEndPrepWindow":false,"DebugSettingsCommand":false,"DimensionTextWindow":true,"DimensionPipeLineCommand":true,"SelectPipeLineCommand":true,"DebugGeometryCommand":false,"FilterPipingElementsCommand":true,"GetTotalPipeLengthCommand":true,"ParameterManagerDockablePane":true,"SelectAllElementsOfSystemCommand":true,"SmartFlipCommand":true}
-
+ {"primaryDimensionTypeName":"C & B","secondaryPipeDimensionTypeName":"C & B PIPE w/dot","secondaryAccessoryDimensionTypeName":"C & B FITTING w/dot","secondaryFittingDimensionTypeName":"C & B FITTING w/dot","secondaryOtherDimensionTypeName":"C & B FITTING w/dot","graphicsStyleNames":["<Centerline>","Pipes","Pipe Fittings","zLines"],"flangeModeItems":[{"elementId":7465461,"Name":"DI FLG DBL","Mode":2},{"elementId":7151319,"Name":"DI FCA","Mode":2},{"elementId":4634124,"Name":"Coupling - Generic","Mode":0},{"elementId":7047513,"Name":"DI CMJ LONG SLEEVE C153","Mode":4},{"elementId":7230174,"Name":"CS WELD GAP MP","Mode":0},{"elementId":7230980,"Name":"CS WELD GAP","Mode":0},{"elementId":7316050,"Name":"DI FLG DBL for fillers","Mode":2},{"elementId":7316874,"Name":"DI FLG DBL MP","Mode":2},{"elementId":7317685,"Name":"DI FLG DBL UN LINKED","Mode":2},{"elementId":7320961,"Name":"DI FLG SINGLE MP","Mode":2},{"elementId":7322565,"Name":"DI FLG SINGLE","Mode":2},{"elementId":7303217,"Name":"DI FLG GASKET DO NOT SCHEDULE","Mode":2},{"elementId":7315853,"Name":"DI FLG GASKET","Mode":2},{"elementId":7319339,"Name":"DI FLG DBL WITH STUDS","Mode":2},{"elementId":7237273,"Name":"SS WELD GAP","Mode":0},{"elementId":7252261,"Name":"SS WELD GAP MP","Mode":0},{"elementId":4584135,"Name":"Non-Connector","Mode":0},{"elementId":7030191,"Name":"Victaulic-Grooved Coupling OGS-AGS_Face","Mode":2},{"elementId":7036679,"Name":"DI HP LOK FITTING BELL","Mode":3},{"elementId":7039212,"Name":"DI MJ BELL","Mode":4},{"elementId":7040062,"Name":"DI PO BELL","Mode":4},{"elementId":7062627,"Name":"Victaulic-AWWA-Grooved Coupling","Mode":2},{"elementId":7063762,"Name":"DI MJ LONG SLEEVE C110","Mode":4},{"elementId":7105299,"Name":"DI TRFLEX SLEEVE DOMESTIC","Mode":3},{"elementId":7123588,"Name":"DI TRFLEX SLEEVE IMPORT","Mode":3},{"elementId":7256569,"Name":"DI TR FLEX FITTING BELL MP","Mode":3},{"elementId":7273137,"Name":"DI HP LOK FITTING BELL MP","Mode":3},{"elementId":7275670,"Name":"DI MJ BELL MP","Mode":4},{"elementId":7276520,"Name":"DI PO BELL MP WITH FIELD LOK GASKET","Mode":2},{"elementId":7279034,"Name":"DI PO BELL MP","Mode":4},{"elementId":7284498,"Name":"Victaulic-AWWA-Coupling Style 31_MP","Mode":2},{"elementId":7286104,"Name":"DI VIC STYLE 31 CPLG_MP","Mode":2},{"elementId":7289129,"Name":"DI VIC STYLE 31 CPLG","Mode":2},{"elementId":7292332,"Name":"DI FLG GASKET w- STUDS","Mode":2},{"elementId":7306393,"Name":"FLG PACK w TWO GASKETS & EX LONG STUDS w DBL NUTS EA","Mode":2},{"elementId":7309215,"Name":"DI HDSS BELL","Mode":3},{"elementId":7311748,"Name":"DI HDSS BELL MP","Mode":3},{"elementId":7314281,"Name":"DI FLG x VIC FLG STYLE 341","Mode":2},{"elementId":7321771,"Name":"DI FLG SINGLE wo GASKET","Mode":2},{"elementId":7466331,"Name":"DI TR FLEX FITTING BELL","Mode":3}]}
\ No newline at end of file
diff --git a/CarsonsAddins/Setup/ComponentState.cs b/CarsonsAddins/Settings/ComponentStates/Models/ComponentState.cs
similarity index 100%
rename from CarsonsAddins/Setup/ComponentState.cs
rename to CarsonsAddins/Settings/ComponentStates/Models/ComponentState.cs
diff --git a/CarsonsAddins/Settings/Models/MyApplicationSettings.cs b/CarsonsAddins/Settings/ComponentStates/Models/ComponentStatePreferences.cs
similarity index 97%
rename from CarsonsAddins/Settings/Models/MyApplicationSettings.cs
rename to CarsonsAddins/Settings/ComponentStates/Models/ComponentStatePreferences.cs
index bdf5ea0..5b18db9 100644
--- a/CarsonsAddins/Settings/Models/MyApplicationSettings.cs
+++ b/CarsonsAddins/Settings/ComponentStates/Models/ComponentStatePreferences.cs
@@ -9,14 +9,14 @@
using System.Text;
using System.Threading.Tasks;
-namespace CarsonsAddins
+namespace CarsonsAddins.Settings.ComponentStates.Models
{
///
/// Stores the Settings state, either by loading it in from the user's preferences or setting the state to their default values. Manipulates the SettingsState of the Addin.
///
- public class MyApplicationSettings
+ public class ComponentStatePreferences
{
- public static MyApplicationSettings Instance;
+ public static ComponentStatePreferences Instance;
public ObservableCollection settingsState = new ObservableCollection();
///
@@ -45,7 +45,7 @@ private Dictionary GetNameIsEnabledDictionary()
///
/// Saves the current settingsState as a JSON within the user preferences in Revit.
///
- public void SaveToDB()
+ public void Save()
{
if (settingsState == null || settingsState.Count == 0) return;
MySettings.Default.ComponentState_Preferences = JsonConvert.SerializeObject(GetNameIsEnabledDictionary());
diff --git a/CarsonsAddins/Settings/ComponentStates/ViewModels/SettingsPluginViewModel.cs b/CarsonsAddins/Settings/ComponentStates/ViewModels/SettingsPluginViewModel.cs
new file mode 100644
index 0000000..ae0be9b
--- /dev/null
+++ b/CarsonsAddins/Settings/ComponentStates/ViewModels/SettingsPluginViewModel.cs
@@ -0,0 +1,18 @@
+using CarsonsAddins.Settings.ComponentStates.Models;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CarsonsAddins.Settings.ComponentStates.ViewModels
+{
+ public class SettingsPluginViewModel
+ {
+ public ObservableCollection componentStates => ComponentStatePreferences.Instance.settingsState;
+ public void Save() => ComponentStatePreferences.Instance.Save();
+ public void LoadFromDB() => ComponentStatePreferences.Instance.LoadFromDB(Assembly.GetExecutingAssembly());
+ }
+}
diff --git a/CarsonsAddins/Settings/Views/MyApplicationSettingsWindow.xaml b/CarsonsAddins/Settings/ComponentStates/Views/SettingsPluginControl.xaml
similarity index 85%
rename from CarsonsAddins/Settings/Views/MyApplicationSettingsWindow.xaml
rename to CarsonsAddins/Settings/ComponentStates/Views/SettingsPluginControl.xaml
index fe34dc6..8da1d17 100644
--- a/CarsonsAddins/Settings/Views/MyApplicationSettingsWindow.xaml
+++ b/CarsonsAddins/Settings/ComponentStates/Views/SettingsPluginControl.xaml
@@ -1,11 +1,11 @@
-
+ d:Background="White" d:DesignHeight="450" d:DesignWidth="800">
@@ -16,7 +16,6 @@
-
@@ -24,6 +23,6 @@
-
+
-
+
diff --git a/CarsonsAddins/Settings/ComponentStates/Views/SettingsPluginControl.xaml.cs b/CarsonsAddins/Settings/ComponentStates/Views/SettingsPluginControl.xaml.cs
new file mode 100644
index 0000000..8e42c8a
--- /dev/null
+++ b/CarsonsAddins/Settings/ComponentStates/Views/SettingsPluginControl.xaml.cs
@@ -0,0 +1,60 @@
+using Autodesk.Revit.DB;
+using Autodesk.Revit.UI;
+using CarsonsAddins.Settings.ComponentStates.Models;
+using CarsonsAddins.Settings.ComponentStates.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Reflection;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace CarsonsAddins.Settings.ComponentStates.Views
+{
+ ///
+ /// Interaction logic for SettingsPluginControl.xaml
+ ///
+ public partial class SettingsPluginControl : UserControl
+ {
+ private SettingsPluginViewModel viewModel;
+ public SettingsPluginControl()
+ {
+ InitializeComponent();
+ }
+
+ public void Init(SettingsPluginViewModel viewModel)
+ {
+ this.viewModel = viewModel;
+ SettingsDataGrid.ItemsSource = viewModel.componentStates;
+ }
+
+ ///
+ /// When the "Apply" button is pressed, saves the current SettingState to Revit.
+ ///
+ private void ApplyButtonClick(object sender, RoutedEventArgs e)
+ {
+ viewModel.Save();
+ TaskDialog.Show("Preferences Updated", "Please restart Revit to apply changes to preferences.");
+
+ }
+
+ ///
+ /// When the "Revert" button is pressed, reloads SettingsState to the state which is saved within Revit.
+ ///
+ private void RevertButtonClick(object sender, RoutedEventArgs e)
+ {
+ viewModel.LoadFromDB();
+ }
+
+ }
+}
diff --git a/CarsonsAddins/Settings/Dimensioning/Models/DimensionPreferences.cs b/CarsonsAddins/Settings/Dimensioning/Models/DimensionPreferences.cs
new file mode 100644
index 0000000..aea0421
--- /dev/null
+++ b/CarsonsAddins/Settings/Dimensioning/Models/DimensionPreferences.cs
@@ -0,0 +1,163 @@
+using Autodesk.Revit.DB;
+using Autodesk.Revit.UI;
+using CarsonsAddins.Properties;
+using CarsonsAddins.Settings.Dimensioning.ViewModels;
+using CarsonsAddins.Utils;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace CarsonsAddins.Settings.Dimensioning.Models
+{
+ public class DimensionPreferences
+ {
+ public static DimensionPreferences Instance;
+ public bool foundAllDimensionTypes => primaryDimensionType != null && secondaryPipeDimensionType != null && secondaryAccessoryDimensionType != null && secondaryFittingDimensionType != null && secondaryOtherDimensionType != null;
+ public DimensionType primaryDimensionType;
+ public DimensionType secondaryPipeDimensionType;
+ public DimensionType secondaryAccessoryDimensionType;
+ public DimensionType secondaryFittingDimensionType;
+ public DimensionType secondaryOtherDimensionType;
+ public List linesStyles = new List();
+ public List flangeModeItems = new List();
+ private Lookup flangeModeLookup => flangeModeItems.ToLookup(item => item.elementId, item => item.Mode) as Lookup;
+ public FlangeDimensionMode defaultFlangeMode = FlangeDimensionMode.Exact;
+ public DimensionType GetSecondaryDimensionType(BuiltInCategory builtInCategory)
+ {
+ switch (builtInCategory)
+ {
+ case BuiltInCategory.OST_PipeCurves: return secondaryPipeDimensionType;
+ case BuiltInCategory.OST_PipeFitting: return secondaryFittingDimensionType;
+ case BuiltInCategory.OST_PipeAccessory: return secondaryAccessoryDimensionType;
+ default: return secondaryOtherDimensionType;
+ }
+ }
+ public DimensionPreferencesSave GetDimensionStyleNames()
+ {
+ return new DimensionPreferencesSave
+ {
+ primaryDimensionTypeName = primaryDimensionType?.Name ?? string.Empty,
+ secondaryPipeDimensionTypeName = secondaryPipeDimensionType?.Name ?? string.Empty,
+ secondaryAccessoryDimensionTypeName = secondaryAccessoryDimensionType?.Name ?? string.Empty,
+ secondaryFittingDimensionTypeName = secondaryFittingDimensionType?.Name ?? string.Empty,
+ secondaryOtherDimensionTypeName = secondaryOtherDimensionType?.Name ?? string.Empty,
+ graphicsStyleNames = linesStyles?.Select(style => style.Name).Distinct().ToArray(),
+ flangeModeItems = flangeModeItems?.Where(item => item.Mode != FlangeDimensionMode.Default).ToArray()
+ };
+ }
+ public DimensionPreferencesSave GetDimensionStyleNames(string[] graphicStyleNames)
+ {
+ return new DimensionPreferencesSave
+ {
+ primaryDimensionTypeName = primaryDimensionType?.Name ?? string.Empty,
+ secondaryPipeDimensionTypeName = secondaryPipeDimensionType?.Name ?? string.Empty,
+ secondaryAccessoryDimensionTypeName = secondaryAccessoryDimensionType?.Name ?? string.Empty,
+ secondaryFittingDimensionTypeName = secondaryFittingDimensionType?.Name ?? string.Empty,
+ secondaryOtherDimensionTypeName = secondaryOtherDimensionType?.Name ?? string.Empty,
+ graphicsStyleNames = graphicStyleNames,
+ flangeModeItems = flangeModeItems?.Where(item => item.Mode != FlangeDimensionMode.Default).ToArray()
+ };
+ }
+ public FlangeDimensionMode GetMode(Element element)
+ {
+ if (!(element is FamilyInstance familyInstance) || !ElementCheckUtils.IsPipeFlange(familyInstance)) return FlangeDimensionMode.None;
+ int familyId = familyInstance?.Symbol?.Family?.Id.IntegerValue ?? -1;
+ if (familyId == -1) return FlangeDimensionMode.None;
+ return flangeModeLookup[familyId].FirstOrDefault();
+ }
+ public static DimensionPreferences CreateFromPreferences(Document doc)
+ {
+ BuiltInCategory[] pipingCategories = new BuiltInCategory[] {
+ BuiltInCategory.OST_PipeCurves,
+ BuiltInCategory.OST_PipeFitting,
+ BuiltInCategory.OST_PipeAccessory,
+ BuiltInCategory.OST_MechanicalEquipment,
+ BuiltInCategory.OST_PipeCurvesCenterLine,
+ BuiltInCategory.OST_PipeFittingCenterLine,
+ BuiltInCategory.OST_CenterLines,
+ BuiltInCategory.OST_ReferenceLines
+ };
+ DimensionType[] dimensionTypes = new FilteredElementCollector(doc)
+ .WhereElementIsElementType().OfClass(typeof(DimensionType))
+ .ToElements().Cast()
+ .Where(dt => DimensionStyleType.Linear.Equals(dt.StyleType))
+ .ToArray();
+ GraphicsStyle[] allGraphicStyles = new FilteredElementCollector(doc)
+ .OfClass(typeof(GraphicsStyle))
+ .Cast()
+ .Where(gs => pipingCategories.Contains((BuiltInCategory)gs.GraphicsStyleCategory.Id.IntegerValue) || ((gs.GraphicsStyleCategory.Parent != null) && pipingCategories.Contains((BuiltInCategory)gs.GraphicsStyleCategory.Parent.Id.IntegerValue)))
+ .ToArray();
+ Family[] familes = new FilteredElementCollector(doc)
+ .OfClass(typeof(Family))
+ .ToElements().Cast()
+ .ToArray();
+ Family[] allFlangeFamilySymbols = new FilteredElementCollector(doc)
+ .OfClass(typeof(Family)).Cast()
+ .Where(family => (BuiltInCategory.OST_PipeFitting == (BuiltInCategory)family.FamilyCategory.Id.IntegerValue) && ElementCheckUtils.FlangePartTypes.Contains((PartType)family.get_Parameter(BuiltInParameter.FAMILY_CONTENT_PART_TYPE).AsInteger()))
+ .ToArray();
+ return LoadFromPreferences(dimensionTypes, allGraphicStyles, allFlangeFamilySymbols);
+ }
+ public static DimensionPreferences LoadFromPreferences(DimensionType[] dimensionTypes, GraphicsStyle[] allGraphicStyles, Family[] allFlangeFamilySymbols) //requires that Load Dimension Types has been called first
+ {
+
+ DimensionPreferences dimensionPreferences = new DimensionPreferences();
+ if (dimensionTypes == null || dimensionTypes.Length == 0) return dimensionPreferences;
+
+ try
+ {
+ if (!string.IsNullOrWhiteSpace(MySettings.Default.DimensionStyles_Preferences))
+ {
+ DimensionPreferencesSave dimensionStyleNames = JsonConvert.DeserializeObject(MySettings.Default.DimensionStyles_Preferences);
+
+
+ foreach (DimensionType dimensionType in dimensionTypes)
+ {
+ if (dimensionType.Name == dimensionStyleNames.primaryDimensionTypeName) dimensionPreferences.primaryDimensionType = dimensionType;
+ if (dimensionType.Name == dimensionStyleNames.secondaryPipeDimensionTypeName) dimensionPreferences.secondaryPipeDimensionType = dimensionType;
+ if (dimensionType.Name == dimensionStyleNames.secondaryAccessoryDimensionTypeName) dimensionPreferences.secondaryAccessoryDimensionType = dimensionType;
+ if (dimensionType.Name == dimensionStyleNames.secondaryFittingDimensionTypeName) dimensionPreferences.secondaryFittingDimensionType = dimensionType;
+ if (dimensionType.Name == dimensionStyleNames.secondaryOtherDimensionTypeName) dimensionPreferences.secondaryOtherDimensionType = dimensionType;
+ if (dimensionPreferences.foundAllDimensionTypes) break;
+ }
+ if (dimensionStyleNames.graphicsStyleNames != null)
+ {
+
+ foreach (GraphicsStyle graphicsStyle in allGraphicStyles)
+ {
+ if (dimensionStyleNames.graphicsStyleNames.Contains(graphicsStyle.Name)) dimensionPreferences.linesStyles.Add(graphicsStyle);
+ }
+ };
+ if (dimensionStyleNames.flangeModeItems != null) dimensionPreferences.flangeModeItems = new List(dimensionStyleNames.flangeModeItems);
+ }
+
+
+ int[] flangeIds = dimensionPreferences.flangeModeItems.Select(item => item.elementId).ToArray();
+ FlangeModeItem[] defaultFlangeModeItems = allFlangeFamilySymbols.Where(family => !flangeIds.Contains(family.Id.IntegerValue)).Select(family => new FlangeModeItem(family.Id.IntegerValue, family.Name, FlangeDimensionMode.Default)).ToArray();
+ dimensionPreferences.flangeModeItems.AddRange(defaultFlangeModeItems);
+ return dimensionPreferences;
+
+ }
+ catch (Exception ex)
+ {
+ TaskDialog.Show("Error Loading Dimension Styles from DB", ex.Message);
+ return new DimensionPreferences();
+ }
+ }
+
+ public void Save()
+ {
+ DimensionPreferencesSave dimensionStyleNames = GetDimensionStyleNames();
+ try
+ {
+ MySettings.Default.DimensionStyles_Preferences = JsonConvert.SerializeObject(dimensionStyleNames);
+ MySettings.Default.Save();
+ }
+ catch (Exception ex)
+ {
+ TaskDialog.Show("Error Saving Dimension Settings", ex.Message);
+ }
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/CarsonsAddins/Settings/Dimensioning/Models/DimensionPreferencesSave.cs b/CarsonsAddins/Settings/Dimensioning/Models/DimensionPreferencesSave.cs
new file mode 100644
index 0000000..2c5ada8
--- /dev/null
+++ b/CarsonsAddins/Settings/Dimensioning/Models/DimensionPreferencesSave.cs
@@ -0,0 +1,20 @@
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CarsonsAddins.Settings.Dimensioning.Models
+{
+ public struct DimensionPreferencesSave
+ {
+ public string primaryDimensionTypeName;
+ public string secondaryPipeDimensionTypeName;
+ public string secondaryAccessoryDimensionTypeName;
+ public string secondaryFittingDimensionTypeName;
+ public string secondaryOtherDimensionTypeName;
+ public string[] graphicsStyleNames;
+ public FlangeModeItem[] flangeModeItems;
+ }
+}
diff --git a/CarsonsAddins/Settings/Dimensioning/Models/FlangedModeItem.cs b/CarsonsAddins/Settings/Dimensioning/Models/FlangedModeItem.cs
new file mode 100644
index 0000000..13e909d
--- /dev/null
+++ b/CarsonsAddins/Settings/Dimensioning/Models/FlangedModeItem.cs
@@ -0,0 +1,30 @@
+using Autodesk.Revit.DB;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Text.Json.Serialization;
+using System.Threading.Tasks;
+
+
+namespace CarsonsAddins.Settings.Dimensioning.Models
+{
+ public enum FlangeDimensionMode { None, Default, Exact, Partial, Negate }
+ public class FlangeModeItem
+ {
+ public int elementId = -1;
+ public string Name { get; set; } = "";
+ public FlangeDimensionMode Mode { get; set; } = FlangeDimensionMode.Default;
+
+
+ [JsonConstructor]
+ public FlangeModeItem(int elementId, string name, FlangeDimensionMode mode)
+ {
+ this.elementId = elementId;
+ Name = name;
+ Mode = mode;
+ }
+ }
+}
diff --git a/CarsonsAddins/Settings/Dimensioning/ViewModels/DimensionSettingsViewModel.cs b/CarsonsAddins/Settings/Dimensioning/ViewModels/DimensionSettingsViewModel.cs
new file mode 100644
index 0000000..0357e82
--- /dev/null
+++ b/CarsonsAddins/Settings/Dimensioning/ViewModels/DimensionSettingsViewModel.cs
@@ -0,0 +1,61 @@
+using Autodesk.Revit.DB;
+using Autodesk.Revit.UI;
+using CarsonsAddins.Properties;
+using CarsonsAddins.Settings.Dimensioning.Models;
+using CarsonsAddins.Utils;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace CarsonsAddins.Settings.Dimensioning.ViewModels
+{
+ public class DimensionSettingsViewModel : INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public DimensionTypeSelectorViewModel dimensionTypeSelectorViewModel;
+ public GraphicStylesSelectorViewModel graphicStylesSelectorViewModel;
+ public FlangeModeSelectorViewModel flangeModeSelectorViewModel;
+
+ private UIDocument uidoc;
+
+ public DimensionType[] dimensionTypes;
+ private GraphicsStyle[] allGraphicStyles;
+ private Family[] allFlangeFamilySymbols;
+ public DimensionSettingsViewModel(UIDocument uidoc)
+ {
+ this.uidoc = uidoc;
+ Refresh();
+ dimensionTypeSelectorViewModel = new DimensionTypeSelectorViewModel(ref dimensionTypes, ref DimensionPreferences.Instance);
+ graphicStylesSelectorViewModel = new GraphicStylesSelectorViewModel(ref allGraphicStyles, ref DimensionPreferences.Instance.linesStyles);
+ flangeModeSelectorViewModel = new FlangeModeSelectorViewModel(ref DimensionPreferences.Instance.flangeModeItems);
+ }
+ public void Refresh()
+ {
+ if (uidoc == null) return;
+
+ LoadFromRevit();
+ DimensionPreferences.Instance = DimensionPreferences.LoadFromPreferences(dimensionTypes, allGraphicStyles, allFlangeFamilySymbols);
+ }
+ public void LoadFromRevit()
+ {
+ BuiltInCategory[] pipingCategories = new BuiltInCategory[] { BuiltInCategory.OST_PipeCurves, BuiltInCategory.OST_PipeFitting, BuiltInCategory.OST_PipeAccessory, BuiltInCategory.OST_MechanicalEquipment, BuiltInCategory.OST_PipeCurvesCenterLine, BuiltInCategory.OST_PipeFittingCenterLine, BuiltInCategory.OST_CenterLines, BuiltInCategory.OST_ReferenceLines };
+ dimensionTypes = new FilteredElementCollector(uidoc.Document).WhereElementIsElementType().OfClass(typeof(DimensionType)).ToElements().Cast().Where(dt => DimensionStyleType.Linear.Equals(dt.StyleType)).ToArray();
+ allGraphicStyles = new FilteredElementCollector(uidoc.Document).OfClass(typeof(GraphicsStyle)).Cast().Where(gs => pipingCategories.Contains((BuiltInCategory)gs.GraphicsStyleCategory.Id.IntegerValue) || ((gs.GraphicsStyleCategory.Parent != null) && pipingCategories.Contains((BuiltInCategory)gs.GraphicsStyleCategory.Parent.Id.IntegerValue))).ToArray();
+ Family[] familes = new FilteredElementCollector(uidoc.Document).OfClass(typeof(Family)).ToElements().Cast().ToArray();
+ allFlangeFamilySymbols = new FilteredElementCollector(uidoc.Document).OfClass(typeof(Family)).Cast().Where(family => (BuiltInCategory.OST_PipeFitting == (BuiltInCategory)family.FamilyCategory.Id.IntegerValue) && ElementCheckUtils.FlangePartTypes.Contains((PartType)family.get_Parameter(BuiltInParameter.FAMILY_CONTENT_PART_TYPE).AsInteger())).ToArray();
+ }
+ public void Save() => DimensionPreferences.Instance.Save();
+
+ protected void OnNotifyPropertyChanged([CallerMemberName] string memberName = "")
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(memberName));
+ }
+ }
+}
diff --git a/CarsonsAddins/Settings/Dimensioning/ViewModels/DimensionTypeSelectorViewModel.cs b/CarsonsAddins/Settings/Dimensioning/ViewModels/DimensionTypeSelectorViewModel.cs
new file mode 100644
index 0000000..f7258db
--- /dev/null
+++ b/CarsonsAddins/Settings/Dimensioning/ViewModels/DimensionTypeSelectorViewModel.cs
@@ -0,0 +1,115 @@
+using Autodesk.Revit.DB;
+using CarsonsAddins.Settings.Dimensioning.Models;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+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.Navigation;
+using System.Windows.Shapes;
+
+
+namespace CarsonsAddins.Settings.Dimensioning.ViewModels
+{
+ public partial class DimensionTypeSelectorViewModel : INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ private DimensionPreferences dimensionPreferences;
+
+ public DimensionType PrimaryDimensionType
+ {
+ get => dimensionPreferences?.primaryDimensionType;
+ set
+ {
+ if (value == null || value == dimensionPreferences.primaryDimensionType) return;
+ dimensionPreferences.primaryDimensionType = value;
+ OnNotifyPropertyChanged();
+ }
+ }
+ public DimensionType SecondaryPipeDimensionType
+ {
+ get => dimensionPreferences?.secondaryPipeDimensionType;
+ set
+ {
+ if (value == null || value == dimensionPreferences.secondaryPipeDimensionType) return;
+ dimensionPreferences.secondaryPipeDimensionType = value;
+ OnNotifyPropertyChanged();
+ }
+ }
+ public DimensionType SecondaryFittingDimensionType
+ {
+ get => dimensionPreferences?.secondaryFittingDimensionType;
+ set
+ {
+ if (value == null || value == dimensionPreferences.secondaryFittingDimensionType) return;
+ dimensionPreferences.secondaryFittingDimensionType = value;
+ OnNotifyPropertyChanged();
+ }
+ }
+ public DimensionType SecondaryAccessoryDimensionType
+ {
+ get => dimensionPreferences?.secondaryAccessoryDimensionType;
+ set
+ {
+ if (value == null || value == dimensionPreferences.secondaryAccessoryDimensionType) return;
+ dimensionPreferences.secondaryAccessoryDimensionType = value;
+ OnNotifyPropertyChanged();
+ }
+ }
+ public DimensionType SecondaryOtherDimensionType
+ {
+ get => dimensionPreferences?.secondaryOtherDimensionType;
+ set
+ {
+ if (value == null || value == dimensionPreferences.secondaryOtherDimensionType) return;
+ dimensionPreferences.secondaryOtherDimensionType = value;
+ OnNotifyPropertyChanged();
+ }
+ }
+
+ public DimensionType[] dimensionTypes = new DimensionType[0];
+ public DimensionType[] DimensionTypes
+ {
+ get => dimensionTypes;
+ set
+ {
+ if (value == null || dimensionTypes == value) return;
+ dimensionTypes = value;
+ OnNotifyPropertyChanged();
+ }
+
+ }
+ public DimensionTypeSelectorViewModel(ref DimensionType[] dimensionTypes, ref DimensionPreferences currentPreferences)
+ {
+ DimensionTypes = dimensionTypes;
+ dimensionPreferences = currentPreferences;
+ NotifyIntialized();
+ }
+
+ private void NotifyIntialized()
+ {
+ if (dimensionPreferences == null) return;
+ OnNotifyPropertyChanged(nameof(PrimaryDimensionType));
+ OnNotifyPropertyChanged(nameof(SecondaryPipeDimensionType));
+ OnNotifyPropertyChanged(nameof(SecondaryFittingDimensionType));
+ OnNotifyPropertyChanged(nameof(SecondaryAccessoryDimensionType));
+ OnNotifyPropertyChanged(nameof(SecondaryOtherDimensionType));
+ }
+
+ protected void OnNotifyPropertyChanged([CallerMemberName] string memberName = "")
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(memberName));
+ }
+ }
+}
diff --git a/CarsonsAddins/Settings/Dimensioning/ViewModels/FlangeModeSelectorViewModel.cs b/CarsonsAddins/Settings/Dimensioning/ViewModels/FlangeModeSelectorViewModel.cs
new file mode 100644
index 0000000..5efef50
--- /dev/null
+++ b/CarsonsAddins/Settings/Dimensioning/ViewModels/FlangeModeSelectorViewModel.cs
@@ -0,0 +1,55 @@
+using Autodesk.Revit.DB;
+using Autodesk.Revit.UI;
+using CarsonsAddins.Properties;
+using CarsonsAddins.Settings.Dimensioning.Models;
+using CarsonsAddins.Utils;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CarsonsAddins.Settings.Dimensioning.ViewModels
+{
+ public class FlangeModeSelectorViewModel: INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+ private FlangeDimensionMode defaultMode = FlangeDimensionMode.Exact;
+ public FlangeDimensionMode DefaultMode
+ {
+ get => defaultMode;
+ set
+ {
+ if (value == FlangeDimensionMode.Default || value == defaultMode) return;
+ defaultMode = value;
+ OnNotifyPropertyChanged();
+ }
+ }
+ private List items = new List();
+ public List Items
+ {
+ get => items;
+ set
+ {
+ if (value == null || items == value) return;
+ items = value;
+ OnNotifyPropertyChanged();
+ }
+ }
+
+ public FlangeModeSelectorViewModel(ref List items)
+ {
+ Items = items;
+ }
+
+
+ protected void OnNotifyPropertyChanged([CallerMemberName] string memberName = "")
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(memberName));
+ }
+ }
+
+}
diff --git a/CarsonsAddins/Dimensioning/DimensionSettings/ViewModels/GraphicsStyleListControl.xaml.cs b/CarsonsAddins/Settings/Dimensioning/ViewModels/GraphicsStylesSelectorViewModel.cs
similarity index 70%
rename from CarsonsAddins/Dimensioning/DimensionSettings/ViewModels/GraphicsStyleListControl.xaml.cs
rename to CarsonsAddins/Settings/Dimensioning/ViewModels/GraphicsStylesSelectorViewModel.cs
index d73be16..734f9bb 100644
--- a/CarsonsAddins/Dimensioning/DimensionSettings/ViewModels/GraphicsStyleListControl.xaml.cs
+++ b/CarsonsAddins/Settings/Dimensioning/ViewModels/GraphicsStylesSelectorViewModel.cs
@@ -18,14 +18,14 @@
using System.Windows.Navigation;
using System.Windows.Shapes;
-namespace CarsonsAddins
+namespace CarsonsAddins.Settings.Dimensioning.ViewModels
{
- ///
- /// Interaction logic for GraphicsStyleListControl.xaml
- ///
- public partial class GraphicsStyleListControl : UserControl, INotifyPropertyChanged
+ public partial class GraphicStylesSelectorViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
+
+ private GraphicsStyle[] allGraphicStyles;
+
private string[] allGraphicStyleNames = new string[0];
public string[] AllGraphicStyleNames
{
@@ -70,21 +70,17 @@ public string ComboboxSelectedGraphicStyleName
OnNotifyPropertyChanged();
}
}
+
private Dictionary graphicStylesNameDictionary = new Dictionary();
private List selectedGraphicStyles = new List();
- public GraphicsStyleListControl()
- {
- InitializeComponent();
- DataContext = this;
- }
- public void Init(GraphicsStyle[] allGraphicStyles, ref List selectedGraphicStyles)
+ public GraphicStylesSelectorViewModel(ref GraphicsStyle[] allGraphicStyles, ref List selectedGraphicStyles)
{
+ this.allGraphicStyles = allGraphicStyles;
this.selectedGraphicStyles = selectedGraphicStyles;
-
- Populate(allGraphicStyles);
+ Refresh();
}
- private void Populate(GraphicsStyle[] allGraphicStyles)
+ public void Refresh()
{
List nameList = allGraphicStyles.Select(gs => gs.Name).ToList();
nameList.Sort();
@@ -93,33 +89,32 @@ private void Populate(GraphicsStyle[] allGraphicStyles)
SelectedGraphicStyleNames = new ObservableCollection(selectedGraphicStyles.Select(gs => gs.Name).Distinct());
NotSelectedGraphicStyleNames = new ObservableCollection(graphicStylesNameDictionary.Keys.Where(name => !SelectedGraphicStyleNames.Contains(name)).OrderBy(s => s));
}
- private void AddStyle_Click(object sender, RoutedEventArgs e)
+ public void AddStyle(string styleName)
{
- if (string.IsNullOrWhiteSpace(ComboboxSelectedGraphicStyleName)) return;
- if (graphicStylesNameDictionary.ContainsKey(ComboboxSelectedGraphicStyleName))
+ if (string.IsNullOrWhiteSpace(styleName)) return;
+ if (graphicStylesNameDictionary.ContainsKey(styleName))
{
- selectedGraphicStyles.AddRange(graphicStylesNameDictionary[ComboboxSelectedGraphicStyleName]);
+ selectedGraphicStyles.AddRange(graphicStylesNameDictionary[styleName]);
}
- SelectedGraphicStyleNames.Add(ComboboxSelectedGraphicStyleName);
- NotSelectedGraphicStyleNames.Remove(ComboboxSelectedGraphicStyleName);
+ SelectedGraphicStyleNames.Add(styleName);
+ NotSelectedGraphicStyleNames.Remove(styleName);
}
- private void RemoveStyle_Click(object sender, RoutedEventArgs e)
+
+
+ public void RemoveStyle(string styleName)
{
- Button button = sender as Button;
- if (!(button.DataContext is string name)) return;
- if (graphicStylesNameDictionary.ContainsKey(name))
+ if (graphicStylesNameDictionary.ContainsKey(styleName))
{
- foreach (GraphicsStyle style in graphicStylesNameDictionary[name]) selectedGraphicStyles.Remove(style);
+ foreach (GraphicsStyle style in graphicStylesNameDictionary[styleName]) selectedGraphicStyles.Remove(style);
}
List names = NotSelectedGraphicStyleNames.ToList();
- names.Add(name);
+ names.Add(styleName);
names.Sort();
NotSelectedGraphicStyleNames = new ObservableCollection(names);
- //NotSelectedGraphicStyleNames.Add(name);
- //NotSelectedGraphicStyleNames = new ObservableCollection(NotSelectedGraphicStyleNames.OrderBy(s => s));
- SelectedGraphicStyleNames.Remove(name);
+ SelectedGraphicStyleNames.Remove(styleName);
}
+
protected void OnNotifyPropertyChanged([CallerMemberName] string memberName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(memberName));
diff --git a/CarsonsAddins/Settings/Dimensioning/Views/DimensionSettingsControl.xaml b/CarsonsAddins/Settings/Dimensioning/Views/DimensionSettingsControl.xaml
new file mode 100644
index 0000000..15c7f1b
--- /dev/null
+++ b/CarsonsAddins/Settings/Dimensioning/Views/DimensionSettingsControl.xaml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CarsonsAddins/Settings/Dimensioning/Views/DimensionSettingsControl.xaml.cs b/CarsonsAddins/Settings/Dimensioning/Views/DimensionSettingsControl.xaml.cs
new file mode 100644
index 0000000..9960de6
--- /dev/null
+++ b/CarsonsAddins/Settings/Dimensioning/Views/DimensionSettingsControl.xaml.cs
@@ -0,0 +1,39 @@
+using Autodesk.Revit.DB;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace CarsonsAddins.Settings.Dimensioning.Views
+{
+ ///
+ /// Interaction logic for DimensionSettingsControl.xaml
+ ///
+ public partial class DimensionSettingsControl : UserControl
+ {
+ private ViewModels.DimensionSettingsViewModel viewModel;
+
+ public DimensionSettingsControl()
+ {
+ InitializeComponent();
+ }
+ public void Init(ViewModels.DimensionSettingsViewModel viewModel)
+ {
+ this.viewModel = viewModel;
+ if (viewModel == null) return;
+ DimensionTypeSelector.Init(viewModel.dimensionTypeSelectorViewModel);
+ GraphicsStyleList.Init(viewModel.graphicStylesSelectorViewModel);
+ FlangeModeSelector.Init(viewModel.flangeModeSelectorViewModel);
+ }
+ }
+}
diff --git a/CarsonsAddins/Dimensioning/DimensionSettings/Views/DimensionTypeSelectorControl.xaml b/CarsonsAddins/Settings/Dimensioning/Views/DimensionTypeSelectorControl.xaml
similarity index 70%
rename from CarsonsAddins/Dimensioning/DimensionSettings/Views/DimensionTypeSelectorControl.xaml
rename to CarsonsAddins/Settings/Dimensioning/Views/DimensionTypeSelectorControl.xaml
index 572db8d..2b27ff2 100644
--- a/CarsonsAddins/Dimensioning/DimensionSettings/Views/DimensionTypeSelectorControl.xaml
+++ b/CarsonsAddins/Settings/Dimensioning/Views/DimensionTypeSelectorControl.xaml
@@ -1,11 +1,11 @@
-
+ Width="auto" Height="auto">
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CarsonsAddins/Settings/Dimensioning/Views/FlangeModeSelectorControl.xaml.cs b/CarsonsAddins/Settings/Dimensioning/Views/FlangeModeSelectorControl.xaml.cs
new file mode 100644
index 0000000..6961672
--- /dev/null
+++ b/CarsonsAddins/Settings/Dimensioning/Views/FlangeModeSelectorControl.xaml.cs
@@ -0,0 +1,83 @@
+using Autodesk.Revit.UI;
+using CarsonsAddins;
+using CarsonsAddins.Utils;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace CarsonsAddins.Settings.Dimensioning.Views
+{
+ ///
+ /// Interaction logic for FlangeModeSelectorControl.xaml
+ ///
+ public partial class FlangeModeSelectorControl : UserControl
+ {
+ private CollectionViewSource collectionViewSource;
+ private ViewModels.FlangeModeSelectorViewModel viewModel;
+ public FlangeModeSelectorControl()
+ {
+ InitializeComponent();
+ collectionViewSource = FindResource("FlangeItemsCollection") as CollectionViewSource;
+ collectionViewSource.GroupDescriptions.Add(new GroupByFlangeModeProperty(Models.FlangeDimensionMode.Exact));
+ collectionViewSource.SortDescriptions.Add(new System.ComponentModel.SortDescription("Mode", System.ComponentModel.ListSortDirection.Descending));
+ collectionViewSource.SortDescriptions.Add(new System.ComponentModel.SortDescription("Name", System.ComponentModel.ListSortDirection.Ascending));
+ ModeTextColumn.ItemsSource = Enum.GetValues(typeof(Models.FlangeDimensionMode));
+
+ }
+ public void Init(ViewModels.FlangeModeSelectorViewModel viewModel)
+ {
+ this.viewModel = viewModel;
+ DataContext = viewModel;
+ collectionViewSource.Source = viewModel.Items;
+ collectionViewSource.GroupDescriptions.Clear();
+ collectionViewSource.GroupDescriptions.Add(new GroupByFlangeModeProperty(viewModel.DefaultMode));
+ }
+
+ private void SetDefaultMode_Click(object sender, RoutedEventArgs e)
+ {
+ if (!(sender is MenuItem menuItem)) return;
+ if (!(menuItem.Parent is ContextMenu contextMenu)) return;
+ if (!(contextMenu.DataContext is CollectionViewGroup viewGroup)) return;
+ string groupName = viewGroup.Name.ToString();
+ Models.FlangeDimensionMode mode;
+ if (Enum.TryParse(groupName, out mode) && viewModel.DefaultMode != mode)
+ {
+ viewModel.DefaultMode = mode;
+ collectionViewSource.GroupDescriptions.Clear();
+ collectionViewSource.GroupDescriptions.Add(new GroupByFlangeModeProperty(mode));
+ }
+ }
+ class GroupByFlangeModeProperty : PropertyGroupDescription
+ {
+ private Models.FlangeDimensionMode defaultMode = Models.FlangeDimensionMode.Exact;
+ public GroupByFlangeModeProperty(Models.FlangeDimensionMode defaultMode) : base("Mode")
+ {
+ this.defaultMode = defaultMode;
+ }
+ public override object GroupNameFromItem(object item, int level, CultureInfo culture)
+ {
+ var baseItem = base.GroupNameFromItem(item, level, culture);
+ if (!(baseItem is Models.FlangeDimensionMode mode)) return "Null";
+ return GetGroupName(mode);
+ }
+ public string GetGroupName(Models.FlangeDimensionMode mode)
+ {
+ if (mode != Models.FlangeDimensionMode.Default) return mode.ToString();
+ return "Default ( " + defaultMode.ToString() + " )";
+ }
+ }
+ }
+
+}
diff --git a/CarsonsAddins/Dimensioning/DimensionSettings/Views/GraphicsStyleListControl.xaml b/CarsonsAddins/Settings/Dimensioning/Views/GraphicsStylesSelectorControl.xaml
similarity index 97%
rename from CarsonsAddins/Dimensioning/DimensionSettings/Views/GraphicsStyleListControl.xaml
rename to CarsonsAddins/Settings/Dimensioning/Views/GraphicsStylesSelectorControl.xaml
index 52c0c1d..45cd418 100644
--- a/CarsonsAddins/Dimensioning/DimensionSettings/Views/GraphicsStyleListControl.xaml
+++ b/CarsonsAddins/Settings/Dimensioning/Views/GraphicsStylesSelectorControl.xaml
@@ -1,4 +1,4 @@
-
-
+
@@ -48,7 +48,7 @@
-
+
diff --git a/CarsonsAddins/Settings/Dimensioning/Views/GraphicsStylesSelectorControl.xaml.cs b/CarsonsAddins/Settings/Dimensioning/Views/GraphicsStylesSelectorControl.xaml.cs
new file mode 100644
index 0000000..e5c9675
--- /dev/null
+++ b/CarsonsAddins/Settings/Dimensioning/Views/GraphicsStylesSelectorControl.xaml.cs
@@ -0,0 +1,49 @@
+using Autodesk.Revit.DB;
+using CarsonsAddins.Settings.Dimensioning.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace CarsonsAddins.Settings.Dimensioning.Views
+{
+ ///
+ /// Interaction logic for GraphicsStylesSelectorControl.xaml
+ ///
+ public partial class GraphicsStylesSelectorControl : UserControl
+ {
+ private GraphicStylesSelectorViewModel viewModel;
+ public GraphicsStylesSelectorControl()
+ {
+ InitializeComponent();
+ }
+ public void Init(GraphicStylesSelectorViewModel viewModel)
+ {
+ this.viewModel = viewModel;
+ DataContext = viewModel;
+ }
+ private void AddStyle_Click(object sender, RoutedEventArgs e)
+ {
+ if (viewModel == null) return;
+ viewModel.AddStyle(viewModel.ComboboxSelectedGraphicStyleName);
+ }
+ private void RemoveStyle_Click(object sender, RoutedEventArgs e)
+ {
+ if (viewModel == null) return;
+ Button button = sender as Button;
+ if (!(button.DataContext is string styleName)) return;
+ viewModel.RemoveStyle(styleName);
+ }
+ }
+}
diff --git a/CarsonsAddins/Settings/Main/ViewModels/MyApplicationSettingsViewModel.cs b/CarsonsAddins/Settings/Main/ViewModels/MyApplicationSettingsViewModel.cs
new file mode 100644
index 0000000..7b2bf7c
--- /dev/null
+++ b/CarsonsAddins/Settings/Main/ViewModels/MyApplicationSettingsViewModel.cs
@@ -0,0 +1,35 @@
+using Autodesk.Revit.Attributes;
+using Autodesk.Revit.DB;
+using Autodesk.Revit.UI;
+using CarsonsAddins.Settings.ComponentStates.ViewModels;
+using CarsonsAddins.Settings.Dimensioning.ViewModels;
+using CarsonsAddins.Settings.Main.Views;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CarsonsAddins.Settings.Main.ViewModels
+{
+ public class MyApplicationSettingsViewModel
+ {
+ public DimensionSettingsViewModel dimensionSettingsViewModel;
+ public SettingsPluginViewModel pluginsViewModel = new SettingsPluginViewModel();
+ public MyApplicationSettingsViewModel(DimensionSettingsViewModel dimensionSettingsViewModel, SettingsPluginViewModel pluginsViewModel)
+ {
+ this.dimensionSettingsViewModel = dimensionSettingsViewModel;
+ this.pluginsViewModel = pluginsViewModel;
+ }
+ public MyApplicationSettingsViewModel(DimensionSettingsViewModel dimensionSettingsViewModel)
+ {
+ this.dimensionSettingsViewModel = dimensionSettingsViewModel;
+ }
+ public void Save()
+ {
+ dimensionSettingsViewModel.Save();
+ pluginsViewModel.Save();
+ }
+ }
+}
diff --git a/CarsonsAddins/Settings/Main/Views/MyApplicationSettingsWindow.xaml b/CarsonsAddins/Settings/Main/Views/MyApplicationSettingsWindow.xaml
new file mode 100644
index 0000000..5b832c7
--- /dev/null
+++ b/CarsonsAddins/Settings/Main/Views/MyApplicationSettingsWindow.xaml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CarsonsAddins/Settings/ViewModels/MyApplicationSettingsWindow.xaml.cs b/CarsonsAddins/Settings/Main/Views/MyApplicationSettingsWindow.xaml.cs
similarity index 61%
rename from CarsonsAddins/Settings/ViewModels/MyApplicationSettingsWindow.xaml.cs
rename to CarsonsAddins/Settings/Main/Views/MyApplicationSettingsWindow.xaml.cs
index 7ec8179..1cdaac1 100644
--- a/CarsonsAddins/Settings/ViewModels/MyApplicationSettingsWindow.xaml.cs
+++ b/CarsonsAddins/Settings/Main/Views/MyApplicationSettingsWindow.xaml.cs
@@ -1,11 +1,13 @@
-using CarsonsAddins.Properties;
-using Newtonsoft.Json;
+using Autodesk.Revit.Attributes;
+using Autodesk.Revit.DB;
+using Autodesk.Revit.UI;
+using CarsonsAddins.Settings.ComponentStates.ViewModels;
+using CarsonsAddins.Settings.Main.ViewModels;
using System;
using System.Collections.Generic;
-using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
-using System.Runtime.CompilerServices;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@@ -17,30 +19,25 @@
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
-using System.Reflection;
-using Autodesk.Revit.UI;
-using System.Configuration.Assemblies;
-using Autodesk.Revit.Attributes;
-using Autodesk.Revit.DB;
-using System.CodeDom;
-using System.Threading;
-using Autodesk.Revit.DB.ExtensibleStorage;
-using System.Net.NetworkInformation;
-using System.Windows.Forms;
-namespace CarsonsAddins
+namespace CarsonsAddins.Settings.Main.Views
{
-
///
- /// Controls the loading, setting, and saving of ComponentState information. There is one ComponentState per Command and each State can be enabled and disabled within the Window UI.
+ /// Interaction logic for MyApplicationSettingsWindow.xaml
///
public partial class MyApplicationSettingsWindow : Window
{
+ private MyApplicationSettingsViewModel viewModel;
public MyApplicationSettingsWindow()
{
InitializeComponent();
}
-
+ public void Init(MyApplicationSettingsViewModel viewModel)
+ {
+ this.viewModel = viewModel;
+ PluginControl.Init(viewModel.pluginsViewModel);
+ DimensionsControl.Init(viewModel.dimensionSettingsViewModel);
+ }
///
/// Creates a PushButtonData for the Application Settings Window.
///
@@ -56,22 +53,12 @@ public static PushButtonData RegisterButton(Assembly assembly)
};
return pushButtonData;
}
-
- ///
- /// When the "Apply" button is pressed, saves the current SettingState to Revit.
- ///
- private void ApplyButtonClick(object sender, RoutedEventArgs e)
- {
- MyApplicationSettings.Instance.SaveToDB();
- TaskDialog.Show("Preferences Updated", "Please restart Revit to apply changes to preferences.");
- }
- ///
- /// When the "Revert" button is pressed, reloads SettingsState to the state which is saved within Revit.
- ///
- private void RevertButtonClick(object sender, RoutedEventArgs e)
+ protected override void OnClosing(CancelEventArgs e)
{
- MyApplicationSettings.Instance.LoadFromDB(Assembly.GetExecutingAssembly());
+ viewModel.Save();
+ e.Cancel = true;
+ Visibility = System.Windows.Visibility.Hidden;
}
///
@@ -80,16 +67,23 @@ private void RevertButtonClick(object sender, RoutedEventArgs e)
[Transaction(TransactionMode.Manual)]
public class ShowSettingsWindow : IExternalCommand
{
- private MyApplicationSettingsWindow instance;
+ private static MyApplicationSettingsWindow instance;
+ private static MyApplicationSettingsViewModel viewModel;
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
try
{
if (instance == null) instance = new MyApplicationSettingsWindow();
- instance.SettingsDataGrid.ItemsSource = MyApplicationSettings.Instance.settingsState;
- instance.Show();
-
+ if (viewModel == null) viewModel = new MyApplicationSettingsViewModel(new Dimensioning.ViewModels.DimensionSettingsViewModel(commandData.Application.ActiveUIDocument));
+ instance.Init(viewModel);
+ switch (instance.Visibility)
+ {
+ case System.Windows.Visibility.Collapsed: instance.Visibility = System.Windows.Visibility.Visible; break;
+ case System.Windows.Visibility.Hidden: instance.ShowDialog(); break;
+ case System.Windows.Visibility.Visible: instance.Focus(); break;
+ default: break;
+ }
return Result.Succeeded;
}
@@ -101,7 +95,5 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme
}
}
-
}
-
}
diff --git a/CarsonsAddins/Setup/ApplicationIds.cs b/CarsonsAddins/Setup/ApplicationIds.cs
index 6bbbbe3..c851ffd 100644
--- a/CarsonsAddins/Setup/ApplicationIds.cs
+++ b/CarsonsAddins/Setup/ApplicationIds.cs
@@ -22,11 +22,11 @@ public static void Init()
{
guidsTypeMap = new Dictionary
{
- { typeof(PipingLCDockablePane), new Guid("{1524F3C0-B6EB-4A32-985F-E3A7071F32B2}") },
- { typeof(PipingLCUpdater), new Guid("{BD82E5B2-D984-49F9-8442-ED572680656D}") },
+ //{ typeof(PipingLCDockablePane), new Guid("{1524F3C0-B6EB-4A32-985F-E3A7071F32B2}") },
+ //{ typeof(PipingLCUpdater), new Guid("{BD82E5B2-D984-49F9-8442-ED572680656D}") },
{ typeof(PipeEndPrepUpdater), new Guid("{892AC63B-A827-466F-A8EA-F4418C27B7C2}") },
{ typeof(PipeEndPrepWindow), new Guid("{7FAA23DB-AAFD-4F47-857E-C06D21B2717E}") },
- { typeof(SimpleFilterDockablePane), new Guid("{5539CADC-1545-4427-9495-3E74FAB6071C}") },
+ //{ typeof(SimpleFilterDockablePane), new Guid("{5539CADC-1545-4427-9495-3E74FAB6071C}") },
{ typeof(ParameterManagerDockablePane), new Guid("{DEF29C25-F7BA-4BE6-A9CD-B1702328043E}") },
{ typeof(StaleReferenceUpdater), new Guid("E00DAD85-B1A0-4C8D-84A8-CEE2BFBBB2E5") },
{ typeof(PipeEndPrepBCWindow), new Guid("89C5BB50-B5E9-457E-9A51-F27318BF2DEA") },
diff --git a/CarsonsAddins/Setup/GenericComponentCommands.cs b/CarsonsAddins/Setup/GenericComponentCommands.cs
index dfd5b92..fae2f8a 100644
--- a/CarsonsAddins/Setup/GenericComponentCommands.cs
+++ b/CarsonsAddins/Setup/GenericComponentCommands.cs
@@ -118,6 +118,19 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme
///
private static UIApplication uiapp;
private static T instance;
+
+ public void InitWindow(UIApplication uiapp)
+ {
+ if (uiapp == null) return;
+ if (instance == null)
+ {
+ instance = new T();
+ instance.Closing += Window_Closing;
+ }
+ instance.Init(uiapp.ActiveUIDocument);
+ instance.Closing += Window_Closing;
+ uiapp.Application.DocumentOpened += Application_DocumentOpened;
+ }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
try
diff --git a/CarsonsAddins/Shared/CopyTaskDialog.xaml b/CarsonsAddins/Shared/CopyTaskDialog.xaml
new file mode 100644
index 0000000..d5ac18d
--- /dev/null
+++ b/CarsonsAddins/Shared/CopyTaskDialog.xaml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CarsonsAddins/Shared/CopyTaskDialog.xaml.cs b/CarsonsAddins/Shared/CopyTaskDialog.xaml.cs
new file mode 100644
index 0000000..80435f4
--- /dev/null
+++ b/CarsonsAddins/Shared/CopyTaskDialog.xaml.cs
@@ -0,0 +1,47 @@
+using CarsonsAddins.GenericCommands;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace CarsonsAddins.Shared.CopyTaskDialog
+{
+ ///
+ /// Interaction logic for CopyTaskDialog.xaml
+ ///
+ public partial class CopyTaskDialog : Window
+ {
+
+ public CopyTaskDialog(string title, string text)
+ {
+ InitializeComponent();
+ Title = title;
+ MainText.Text = text;
+ }
+
+ private void Copy_Click(object sender, RoutedEventArgs e)
+ {
+ Clipboard.SetText(MainText.Text);
+ }
+ private void Close_Click(object sender, RoutedEventArgs e)
+ {
+ Close();
+ }
+
+ public static void Show(string title, string text)
+ {
+ CopyTaskDialog instance = new CopyTaskDialog(title, text);
+ instance.Show();
+ }
+ }
+}
diff --git a/CarsonsAddins/Setup/SelectDimensionsIndividuallyCommand.cs b/CarsonsAddins/Shared/SelectDimensionsIndividuallyCommand.cs
similarity index 100%
rename from CarsonsAddins/Setup/SelectDimensionsIndividuallyCommand.cs
rename to CarsonsAddins/Shared/SelectDimensionsIndividuallyCommand.cs
diff --git a/CarsonsAddins/Shared/TextBoxWithLabel/Views/TextBoxWithLabel.xaml b/CarsonsAddins/Shared/TextBoxWithLabel.xaml
similarity index 100%
rename from CarsonsAddins/Shared/TextBoxWithLabel/Views/TextBoxWithLabel.xaml
rename to CarsonsAddins/Shared/TextBoxWithLabel.xaml
diff --git a/CarsonsAddins/Shared/TextBoxWithLabel/ViewModels/TextBoxWithLabel.xaml.cs b/CarsonsAddins/Shared/TextBoxWithLabel.xaml.cs
similarity index 98%
rename from CarsonsAddins/Shared/TextBoxWithLabel/ViewModels/TextBoxWithLabel.xaml.cs
rename to CarsonsAddins/Shared/TextBoxWithLabel.xaml.cs
index 2771db2..96e62c2 100644
--- a/CarsonsAddins/Shared/TextBoxWithLabel/ViewModels/TextBoxWithLabel.xaml.cs
+++ b/CarsonsAddins/Shared/TextBoxWithLabel.xaml.cs
@@ -40,7 +40,7 @@ public partial class TextBoxWithLabel : UserControl
ownerType: typeof(TextBoxWithLabel),
typeMetadata: new FrameworkPropertyMetadata(defaultValue: true));
- public string LabelText
+ public string LabelText
{
get => (string)GetValue(LabelTextProperty);
set => SetValue(LabelTextProperty, value);
diff --git a/CarsonsAddins/Shared/ToggleableTextBox/Views/ToggleableTextBox.xaml b/CarsonsAddins/Shared/ToggleableTextBox.xaml
similarity index 98%
rename from CarsonsAddins/Shared/ToggleableTextBox/Views/ToggleableTextBox.xaml
rename to CarsonsAddins/Shared/ToggleableTextBox.xaml
index 71c80d7..77abf25 100644
--- a/CarsonsAddins/Shared/ToggleableTextBox/Views/ToggleableTextBox.xaml
+++ b/CarsonsAddins/Shared/ToggleableTextBox.xaml
@@ -13,5 +13,5 @@
-
+
diff --git a/CarsonsAddins/Shared/ToggleableTextBox/ViewModels/ToggleableTextBox.xaml.cs b/CarsonsAddins/Shared/ToggleableTextBox.xaml.cs
similarity index 93%
rename from CarsonsAddins/Shared/ToggleableTextBox/ViewModels/ToggleableTextBox.xaml.cs
rename to CarsonsAddins/Shared/ToggleableTextBox.xaml.cs
index 3cc42d6..78ea8c4 100644
--- a/CarsonsAddins/Shared/ToggleableTextBox/ViewModels/ToggleableTextBox.xaml.cs
+++ b/CarsonsAddins/Shared/ToggleableTextBox.xaml.cs
@@ -35,7 +35,7 @@ public partial class ToggleableTextBox : UserControl
name: "IsTextEditable",
propertyType: typeof(bool),
ownerType: typeof(ToggleableTextBox),
- typeMetadata: new FrameworkPropertyMetadata( defaultValue: true));
+ typeMetadata: new FrameworkPropertyMetadata(defaultValue: true));
public static readonly DependencyProperty IsCheckedProperty =
DependencyProperty.Register(
@@ -67,9 +67,10 @@ public partial class ToggleableTextBox : UserControl
public event RoutedEventHandler OnChecked
{
- add {
+ add
+ {
AddHandler(OnCheckedEvent, value);
- TaskDialog.Show("ToggleableTextBox - Added to handler","");
+ TaskDialog.Show("ToggleableTextBox - Added to handler", "");
}
remove { RemoveHandler(OnCheckedEvent, value); }
}
@@ -77,7 +78,7 @@ public event RoutedEventHandler OnChecked
public bool IsClickable
{
get => (bool)GetValue(IsClickableProperty);
- set => SetValue(IsClickableProperty, value);
+ set => SetValue(IsClickableProperty, value);
}
public bool IsTextEditable
@@ -95,7 +96,7 @@ public bool IsChecked
public string LabelText
{
- get => (string) GetValue(LabelTextProperty);
+ get => (string)GetValue(LabelTextProperty);
set => SetValue(LabelTextProperty, value);
}
@@ -114,7 +115,7 @@ public ToggleableTextBox()
private void CheckBoxControl_Click(object sender, RoutedEventArgs e)
{
- if (IsChecked)
+ if (IsChecked)
{
RoutedEventArgs args = new RoutedEventArgs(ToggleableTextBox.OnCheckedEvent);
RaiseEvent(args);
diff --git a/CarsonsAddins/Shared/Utils/ConnectionUtils.cs b/CarsonsAddins/Shared/Utils/ConnectionUtils.cs
index e223300..e300bd7 100644
--- a/CarsonsAddins/Shared/Utils/ConnectionUtils.cs
+++ b/CarsonsAddins/Shared/Utils/ConnectionUtils.cs
@@ -14,7 +14,7 @@ namespace CarsonsAddins.Utils
public static class ConnectionUtils
{
///
- /// Default: None,
+ /// Default: Default,
/// Bell: Female end of the Pipe.
/// Spigot: Male end of the Pipe.
///
diff --git a/CarsonsAddins/Shared/Utils/DimensioningUtils.cs b/CarsonsAddins/Shared/Utils/DimensioningUtils.cs
index 090be1e..93226ec 100644
--- a/CarsonsAddins/Shared/Utils/DimensioningUtils.cs
+++ b/CarsonsAddins/Shared/Utils/DimensioningUtils.cs
@@ -10,6 +10,8 @@ namespace CarsonsAddins.Utils
{
public static class DimensioningUtils
{
+
+
public static Line GetDimensionSegmentLine(DimensionSegment segment, XYZ direction)
{
if (segment.Value == null) return null;
@@ -292,21 +294,7 @@ public static Reference GetFlangeEndReference(Plane plane, Element flange, Eleme
if (connector == null) return null;
Connector adjacent = ConnectionUtils.GetAdjacentConnector(connector);
if (adjacent == null) return null;
- return GeometryUtils.GetPseudoReferenceOfConnector(GeometryUtils.GetGeometryOptions(), plane, adjacent);
- }
-
-
- ///
- /// Retrieves a reference to the end point of a Piping Element. Meant to be used when dimensioning to a end of the Pipeline
- ///
- /// The active View.
- /// The ElementIds corresponding to the valid centerline line styles.
- /// a Piping Element
- /// a Reference corresponding to the endpoint of the Piping Element.
- public static Reference GetEndReference(View activeView, ElementId[] validStyleIds, Element element)
- {
- if (ElementCheckUtils.IsPipe(element)) return GetPipeEndReference(activeView, element as Pipe);
- return GetCenterReference(validStyleIds, element);
+ return GeometryUtils.GetPseudoReferenceOfConnector(null, GeometryUtils.GetGeometryOptions(), plane, adjacent);
}
///
@@ -372,8 +360,7 @@ public static Reference GetCenterReference(ElementId[] validStyleIds, Element el
{
Line[] instanceLines = GeometryUtils.GetInstanceGeometryObjectsWithStyleIds(GeometryUtils.GetGeometryOptions(), element, validStyleIds);
Line[] symbolLines = GeometryUtils.GetSymbolGeometryObjectsWithStyleIds(GeometryUtils.GetGeometryOptions(), element, validStyleIds);
- if (instanceLines == null || symbolLines == null) return null;
- if (instanceLines.Length == 0 || symbolLines.Length == 0) return null;
+ if (instanceLines == null || instanceLines.Length == 0 || symbolLines == null || symbolLines.Length == 0) return null;
XYZ origin = GetOriginOfElement(element);
int id = -1;
int endIndex = -1;
@@ -394,6 +381,31 @@ public static Reference GetCenterReference(ElementId[] validStyleIds, Element el
return symbolLines.Where(line => line.Id.Equals(id)).FirstOrDefault()?.GetEndPointReference(endIndex);
}
+ public static Reference GetProjectedCenterReference(Options geometryOptions, ElementId[] validStyleIds, Plane plane, Element element)
+ {
+ Line[] instanceLines = GeometryUtils.GetInstanceGeometryObjectsWithStyleIds(geometryOptions, element, validStyleIds);
+ Line[] symbolLines = GeometryUtils.GetSymbolGeometryObjectsWithStyleIds(geometryOptions, element, validStyleIds);
+ if (instanceLines == null || instanceLines.Length == 0 || symbolLines == null || symbolLines.Length == 0) return null;
+ XYZ projectedOrigin = GeometryUtils.ProjectPointOntoPlane(plane, GetOriginOfElement(element));
+ int id = -1;
+ int endIndex = -1;
+ foreach (Line line in instanceLines)
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ XYZ projectedEndPoint = GeometryUtils.ProjectPointOntoPlane(plane, line.GetEndPoint(i));
+ if (projectedEndPoint.IsAlmostEqualTo(projectedOrigin))
+ {
+ id = line.Id;
+ endIndex = i;
+ break;
+ }
+ }
+ if (id != -1) break;
+ }
+ if (id == -1 || endIndex == -1) return null;
+ return symbolLines.Where(line => line.Id.Equals(id)).FirstOrDefault()?.GetEndPointReference(endIndex);
+ }
///
/// Retrieves the Reference for unused connector of the pipe.
@@ -423,9 +435,10 @@ public static Reference GetPipeEndReference(View activeView, Pipe pipe)
public static Reference GetMechanicalEquipmentEndReference(Plane plane, FamilyInstance mechanicalEquipment, FamilyInstance connected)
{
- Connector connector = ConnectionUtils.TryGetOneSidedConnection(mechanicalEquipment, connected);
- if (connector == null) return null;
- return GeometryUtils.GetPseudoReferenceOfConnector(GeometryUtils.GetGeometryOptions(), plane, connector);
+ return null;
+ //Connector connector = ConnectionUtils.TryGetOneSidedConnection(mechanicalEquipment, connected);
+ //if (connector == null) return null;
+ //return GeometryUtils.GetPseudoReferenceOfConnector(GeometryUtils.GetGeometryOptions(), plane, connector);
}
}
diff --git a/CarsonsAddins/Shared/Utils/GeometryUtils.cs b/CarsonsAddins/Shared/Utils/GeometryUtils.cs
index 85065f8..ab96df1 100644
--- a/CarsonsAddins/Shared/Utils/GeometryUtils.cs
+++ b/CarsonsAddins/Shared/Utils/GeometryUtils.cs
@@ -3,8 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using static CarsonsAddins.Utils.GeometryUtils;
namespace CarsonsAddins.Utils
{
@@ -129,20 +128,82 @@ public static (PlanarFace, PlanarFace) GetPlanarFaceFromConnector(Options geomet
}
return (null, null);
}
-
- public static Reference GetPseudoReferenceOfConnector(Options geometryOptions, Plane plane, Connector connector)
+ public static Reference GetPseudoReferenceOfConnector(ElementId[] validElementIds, Options geometryOptions, Plane plane, Connector connector)
+ {
+ return GetExposedPseudoReferenceOfConnectorByFaces(geometryOptions, plane, connector) ??
+ GetExposedPseudoReferenceOfConnectorByLines(validElementIds, geometryOptions, plane, connector) ??
+ GetPseudoReferenceOfConnectorByFace(geometryOptions, plane, connector) ??
+ GetPseudoReferenceOfConnector(validElementIds, geometryOptions, plane, connector);
+ }
+ public static Reference GetPseudoReferenceOfConnectorByFace(Options geometryOptions, Plane plane, Connector connector)
{
if (connector == null) return null;
XYZ projectedOrigin = ProjectPointOntoPlane(plane, connector.Origin);
if (projectedOrigin == null) return null;
PlanarFace[] instancePlanarFaces = GetGeometryObjectFromInstanceGeometry(geometryOptions, connector.Owner);
Lookup symbolPlanarFacesLookup = GetGeometryObjectFromSymbolGeometry(geometryOptions, connector.Owner).ToLookup(planarFace => planarFace.Id) as Lookup;
- PlanarFace instanceConnectorFace = instancePlanarFaces.Where(planarFace => ProjectPointOntoPlane(plane, planarFace.Origin).IsAlmostEqualTo(projectedOrigin, 0.000001)).FirstOrDefault();
+ PlanarFace instanceConnectorFace = instancePlanarFaces.Where(planarFace => projectedOrigin.IsAlmostEqualTo(ProjectPointOntoPlane(plane, planarFace.Origin), 0.000001)).FirstOrDefault();
if (instanceConnectorFace == default(PlanarFace)) return null;
PlanarFace symbolFace = symbolPlanarFacesLookup[instanceConnectorFace.Id].FirstOrDefault();
Reference referenceConnectorFace = symbolFace.Reference;
return referenceConnectorFace;
}
+ public static Reference GetPseudoReferenceOfConnectorByLines(ElementId[] validElementIds, Options geometryOptions, Plane plane, Connector connector)
+ {
+ if (connector == null || validElementIds == null || validElementIds.Length == 0) return null;
+ XYZ projectedOrigin = ProjectPointOntoPlane(plane, connector.Origin);
+ if (projectedOrigin == null) return null;
+ Line[] instanceLines = GetGeometryObjectFromInstanceGeometry(geometryOptions, connector.Owner).Where(line => validElementIds.Contains(line.GraphicsStyleId)).ToArray();
+ Lookup referenceLookup = GetGeometryObjectFromSymbolGeometry(geometryOptions, connector.Owner).ToLookup(line => line.Id, line => GetEndPointReferences(line)) as Lookup;
+ foreach (Line line in instanceLines)
+ {
+ for (int i = 0 ; i < 2; i++)
+ {
+ XYZ endPoint = line.GetEndPoint(i);
+ XYZ projectedEndPoint = ProjectPointOntoPlane(plane, endPoint);
+ if (projectedOrigin.IsAlmostEqualTo(projectedEndPoint) && referenceLookup.Contains(line.Id)) return referenceLookup[line.Id].FirstOrDefault()?[i];
+ }
+
+ }
+ return null;
+ }
+
+ public static Reference GetExposedPseudoReferenceOfConnectorByFaces(Options geometryOptions, Plane plane, Connector connector)
+ {
+ if (connector == null) return null;
+ XYZ projectedOrigin = ProjectPointOntoPlane(plane, connector.Origin);
+ if (projectedOrigin == null) return null;
+ PlanarFace[] faces = GetExposedGeometryObjects(geometryOptions, connector.Owner);
+ foreach (PlanarFace face in faces)
+ {
+ XYZ projectedFaceOrigin = ProjectPointOntoPlane(plane, face.Origin);
+ if (projectedOrigin.IsAlmostEqualTo(projectedFaceOrigin)) return face.Reference;
+
+ }
+ return null;
+ }
+
+ public static Reference GetExposedPseudoReferenceOfConnectorByLines(ElementId[] validElementIds, Options geometryOptions, Plane plane, Connector connector)
+ {
+ if (connector == null || validElementIds == null || validElementIds.Length == 0) return null;
+ XYZ projectedOrigin = ProjectPointOntoPlane(plane, connector.Origin);
+ if (projectedOrigin == null) return null;
+ Line[] lines = GetExposedGeometryObjects(geometryOptions, connector.Owner).Where(line => validElementIds.Contains(line.GraphicsStyleId)).ToArray();
+ foreach (Line line in lines)
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ XYZ endPoint = line.GetEndPoint(i);
+ XYZ projectedEndPoint = ProjectPointOntoPlane(plane, endPoint);
+ if (projectedOrigin.IsAlmostEqualTo(projectedEndPoint)) return line.GetEndPointReference(i);
+ }
+
+ }
+ return null;
+ }
+
+
+
public static GeometryObject[] GetGeometryLinesOfBend(View activeView, Element element, ElementId validStyleId)
{
if (element == null) return null;
@@ -288,37 +349,33 @@ public static T[] GetInstanceGeometryObjectsWithStyleIds(Options geometryOpti
}
return geometryObjects.ToArray();
}
- public static XYZWithReference[] StripGeometryObjectsWithReferences(Element element)
+ public static GeometryObject[] BreakdownGeometryElementIntoDimensionableGeometryObjects(ElementId[] validStyleIds, GeometryElement geometryInstance)
{
- GeometryElement geometryElement = element.get_Geometry(GetGeometryOptions());
- if (geometryElement == null) return new XYZWithReference[0];
- GeometryInstance geometryInstance = geometryElement.OfType().FirstOrDefault();
- if (geometryInstance == null) return new XYZWithReference[0];
- List geometryObjectWithReferences = new List();
- IdWithXYZ[] idsWithXYZs = IdWithXYZ.BreakdownGeometryObjects(BreakdownSolidsIntoDimensionableGeometryObjects(geometryInstance.GetInstanceGeometry()));
- Lookup idsWithReferences = IdWithReference.BreakdownGeometryObjects(BreakdownSolidsIntoDimensionableGeometryObjects(geometryInstance.GetSymbolGeometry()))
- .ToLookup(idWithReference => idWithReference.id) as Lookup;
+ if (geometryInstance == null) return new GeometryObject[0];
+ List geometryObjects = new List();
+ foreach (GeometryObject geometryObject in geometryInstance)
+ {
+ if (geometryObject == null) continue;
+ else if (geometryObject is Solid solid) geometryObjects.AddRange(solid.Faces.OfType().ToArray());
+ else if (geometryObject is Point) geometryObjects.Add(geometryObject);
+ else if (geometryObject is Curve && (validStyleIds.Contains(geometryObject.GraphicsStyleId) || validStyleIds == null)) geometryObjects.Add(geometryObject);
- XYZWithReference[] xyzsWithReferences = idsWithXYZs.Select(xyzWithRef => new XYZWithReference(xyzWithRef.xyz, idsWithReferences[xyzWithRef.id]
- .Where(idWithRef => xyzWithRef.secondaryId == idWithRef.secondaryId).FirstOrDefault().reference)).ToArray();
- return xyzsWithReferences;
+ }
+ return geometryObjects.ToArray();
}
-
- public static GeometryObject[] BreakdownSolidsIntoDimensionableGeometryObjects(GeometryElement geometryElement)
+ public static GeometryObject[] StripExposedGeometryObjects(ElementId[] validStyleIds, GeometryElement geometryElement)
{
if (geometryElement == null) return new GeometryObject[0];
List geometryObjects = new List();
foreach (GeometryObject geometryObject in geometryElement)
{
- if (geometryObject == null) continue;
+ if (geometryObject == null || !geometryObject.IsElementGeometry || geometryObject is GeometryInstance) continue;
else if (geometryObject is Solid solid) geometryObjects.AddRange(solid.Faces.OfType().ToArray());
- else if (geometryObject is Point) geometryObjects.Add(geometryObject);
- else if (geometryObject is Line) geometryObjects.Add(geometryObject);
-
+ else if (geometryObject is Point point && point.Reference != null) geometryObjects.Add(geometryObject);
+ else if (geometryObject is Line && (validStyleIds.Contains(geometryObject.GraphicsStyleId) || validStyleIds == null)) geometryObjects.Add(geometryObject);
}
return geometryObjects.ToArray();
}
-
public struct XYZWithReference
{
public XYZ xyz;
@@ -328,12 +385,64 @@ public XYZWithReference(XYZ xyz, Reference reference)
this.xyz = xyz;
this.reference = reference;
}
+ public override string ToString()
+ {
+ return xyz.ToString() + " -> " + reference.ToString();
+ }
+ public static XYZWithReference[] StripGeometryObjectsWithReferences(ElementId[] validStyleIds, Options geometryOptions, Element element)
+ {
+
+ GeometryElement geometryElement = element.get_Geometry(geometryOptions);
+ if (geometryElement == null) return new XYZWithReference[0];
+ List geometryObjectWithReferences = new List();
+ geometryObjectWithReferences.AddRange(StripExposedGeometryObjectsWithReferences(validStyleIds, geometryOptions, element));
+ GeometryInstance geometryInstance = geometryElement.OfType().FirstOrDefault();
+ if (geometryInstance == null) return geometryObjectWithReferences.ToArray();
+ IdWithXYZ[] idsWithXYZs = IdWithXYZ.BreakdownGeometryObjects(BreakdownGeometryElementIntoDimensionableGeometryObjects(validStyleIds, geometryInstance.GetInstanceGeometry()));
+ Lookup<(int, int), IdWithReference> idsWithReferences = IdWithReference.BreakdownGeometryObjects(BreakdownGeometryElementIntoDimensionableGeometryObjects(validStyleIds, geometryInstance.GetSymbolGeometry()))
+ .ToLookup(idWithReference => (idWithReference.id, idWithReference.secondaryId)) as Lookup<(int, int), IdWithReference>;
+
+ XYZWithReference[] xyzsWithReferences = idsWithXYZs.Select(xyzWithRef => new XYZWithReference(xyzWithRef.xyz, idsWithReferences[(xyzWithRef.id, xyzWithRef.secondaryId)]
+ .Where(idWithRef => xyzWithRef.secondaryId == idWithRef.secondaryId).FirstOrDefault().reference)).ToArray();
+ return xyzsWithReferences;
+ }
+
+ public static XYZWithReference[] StripExposedGeometryObjectsWithReferences(ElementId[] validStyleIds, Options geometryOptions, Element element)
+ {
+ if (element == null) return default;
+ GeometryObject[] geometryObjects = StripExposedGeometryObjects(validStyleIds, element.get_Geometry(geometryOptions));
+ List xyzWithReferences = new List();
+ foreach (GeometryObject geometryObject in geometryObjects)
+ {
+ if (geometryObject == null) continue;
+ else if (geometryObject is Solid solid) xyzWithReferences.AddRange(solid.Faces.OfType().SelectMany(face => StripExposedFacesWithReferences(face)).ToArray());
+ else if (geometryObject is Point point) xyzWithReferences.Add(new XYZWithReference(point.Coord, point.Reference));
+ else if (geometryObject is Curve curve && (validStyleIds.Contains(geometryObject.GraphicsStyleId) || validStyleIds == null))
+ {
+ xyzWithReferences.Add(new XYZWithReference(curve.GetEndPoint(0), curve.GetEndPointReference(0)));
+ xyzWithReferences.Add(new XYZWithReference(curve.GetEndPoint(1), curve.GetEndPointReference(1)));
+ }
+ }
+ return xyzWithReferences.ToArray();
+ }
+
+ public static XYZWithReference[] StripExposedFacesWithReferences(PlanarFace face)
+ {
+ Edge[] edges = face.EdgeLoops.OfType().ToArray();
+ List xyzWithReferences = new List();
+ foreach (Edge edge in edges)
+ {
+ if (edge == null) continue;
+ xyzWithReferences.AddRange(edge.Tessellate().Select(xyz => new XYZWithReference(xyz, face.Reference)));
+ }
+ return xyzWithReferences.ToArray();
+ }
}
public struct IdWithXYZ
{
public int id;
- public int secondaryId; //only used for line endpoint indices
+ public int secondaryId; //only used for line endPoint indices
public XYZ xyz;
public IdWithXYZ(int id, int secondaryId, XYZ xyz)
{
@@ -350,11 +459,10 @@ public IdWithXYZ(int id, XYZ xyz)
public static IdWithXYZ[] BreakdownGeometryObject(GeometryObject geometryObject)
{
if (geometryObject == null) return new IdWithXYZ[0];
- if (!geometryObject.IsElementGeometry) return new IdWithXYZ[0];
if (geometryObject is Point point) return new IdWithXYZ[1] { new IdWithXYZ(point.Id, point.Coord) };
- if (geometryObject is Line line) return new IdWithXYZ[2] {
- new IdWithXYZ(line.Id, 0, line.GetEndPoint(0)),
- new IdWithXYZ(line.Id, 1, line.GetEndPoint(1))
+ if (geometryObject is Curve curve) return new IdWithXYZ[2] {
+ new IdWithXYZ(curve.Id, 0, curve.GetEndPoint(0)),
+ new IdWithXYZ(curve.Id, 1, curve.GetEndPoint(1))
};
if (geometryObject is PlanarFace planarFace) return new IdWithXYZ[1] { new IdWithXYZ(planarFace.Id, planarFace.Origin) };
return new IdWithXYZ[0];
@@ -368,12 +476,17 @@ public static IdWithXYZ[] BreakdownGeometryObjects(GeometryObject[] geometryObje
}
return idsWithXYZs.ToArray();
}
+ public override string ToString()
+ {
+ if (secondaryId >= 0) return "( " + id + ", " + secondaryId + " ): " + xyz.ToString();
+ return "( " + id + " ): " + xyz.ToString();
+ }
}
public struct IdWithReference
{
public int id;
- public int secondaryId; //only used for line endpoint indices
+ public int secondaryId; //only used for line endPoint indices
public Reference reference;
public IdWithReference(int id, int secondaryId, Reference reference)
{
@@ -392,9 +505,9 @@ public static IdWithReference[] BreakdownGeometryObject(GeometryObject geometryO
if (geometryObject == null) return new IdWithReference[0];
if (!geometryObject.IsElementGeometry) return new IdWithReference[0];
if (geometryObject is Point point) return new IdWithReference[1] { new IdWithReference(point.Id, point.Reference) };
- if (geometryObject is Line line) return new IdWithReference[2] {
- new IdWithReference(line.Id, 0, line.GetEndPointReference(0)),
- new IdWithReference(line.Id, 1, line.GetEndPointReference(1))
+ if (geometryObject is Curve curve) return new IdWithReference[2] {
+ new IdWithReference(curve.Id, 0, curve.GetEndPointReference(0)),
+ new IdWithReference(curve.Id, 1, curve.GetEndPointReference(1))
};
if (geometryObject is PlanarFace planarFace) return new IdWithReference[1] { new IdWithReference(planarFace.Id, planarFace.Reference) };
return new IdWithReference[0];
@@ -410,6 +523,11 @@ public static IdWithReference[] BreakdownGeometryObjects(GeometryObject[] geomet
}
return IdsWithReferences.ToArray();
}
+ public override string ToString()
+ {
+ if (secondaryId >= 0) return "( " + id + ", " + secondaryId + " ): " + reference.ToString();
+ return "( " + id + " ): " + reference.ToString();
+ }
}
diff --git a/CarsonsAddins/Standalone/ParameterManager/Models/ElementRow.cs b/CarsonsAddins/Standalone/ParameterManager/Models/ElementRow.cs
new file mode 100644
index 0000000..87baf91
--- /dev/null
+++ b/CarsonsAddins/Standalone/ParameterManager/Models/ElementRow.cs
@@ -0,0 +1,125 @@
+using Autodesk.Revit.DB;
+using Autodesk.Revit.UI;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CarsonsAddins.Standalone.ParameterManager.Models
+{
+ class ElementRowCollection : ObservableCollection { }
+
+ ///
+ /// Stores and References data of a single Element. Currently binding and tracking changes via the INotifyPropertyChanged base class. Will eventually move to binding via DependencyProperties for speed increase.
+ ///
+ class ElementRow : INotifyPropertyChanged // 1 to 1: Element to Row
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public Element element { get; private set; }
+ private readonly ElementId id = ElementId.InvalidElementId;
+ public ElementId Id { get => id; }
+ private bool isSelected = false;
+ public bool IsSelected
+ {
+ get => isSelected;
+ set
+ {
+ if (isSelected == value) return;
+ isSelected = value;
+ OnNotifyPropertyChanged();
+ }
+ }
+
+ public Dictionary cells { private set; get; }
+ public ElementRow(Element element)
+ {
+ cells = new Dictionary();
+ this.element = element;
+ id = element.Id;
+ }
+
+ public void Refresh()
+ {
+ foreach (ParameterCell cell in cells.Values)
+ {
+ cell.Refresh();
+ }
+ }
+ public void Refresh(string parameterName)
+ {
+ if (cells.ContainsKey(parameterName)) cells[parameterName].Refresh();
+ }
+
+ public bool HasParameterValue(string parameterName, string valueString)
+ {
+ if (valueString is null) return false;
+ if (parameterName == "IsSelected") return (GroupIsSelectedProperty.GetGroupName(IsSelected) == valueString);
+ if (!cells.ContainsKey(parameterName)) return false;
+ ParameterCell cell = cells[parameterName];
+ if (cell is null) return false;
+ return valueString.Equals(GroupParameterValueProperty.GetGroupName(cell));
+ }
+
+ public Parameter AddParameter(Definition definition)
+ {
+ if (element == null) return null;
+ Parameter parameter = element.get_Parameter(definition);
+ cells.Add(definition.Name, new ParameterCell(parameter));
+ return parameter;
+ }
+ public Parameter AddParameter(string parameterName)
+ {
+ if (element == null) return null;
+ if (parameterName == null) return null;
+ Parameter parameter = element.LookupParameter(parameterName);
+ cells.Add(parameterName, new ParameterCell(parameter));
+ return parameter;
+ }
+ public void RemoveParameter(string parameterName)
+ {
+ if (!cells.ContainsKey(parameterName)) return;
+ cells.Remove(parameterName);
+ }
+ public string GetCellValue(string parameterName)
+ {
+ if (parameterName == null) return "";
+ if (!cells.TryGetValue(parameterName, out ParameterCell cell)) return "";
+ return cell.ParameterValue;
+ }
+ public void PushUpdatesToElement(string parameterName)
+ {
+ try
+ {
+ if (!cells.ContainsKey(parameterName)) return;
+ ParameterCell cell = cells[parameterName];
+ if (cell.IsSynced) return;
+ if (cell.IsNull) return;
+ cell.PushValueToParameter();
+
+ }
+ catch (Exception ex)
+ {
+ TaskDialog.Show("Parameter Row Error", ex.Message);
+ }
+ }
+ public void PushUpdatesToElement()
+ {
+ foreach (string parameterName in cells.Keys)
+ {
+ PushUpdatesToElement(parameterName);
+
+
+ }
+ }
+
+ protected void OnNotifyPropertyChanged([CallerMemberName] string memberName = "")
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(memberName));
+ }
+ }
+}
diff --git a/CarsonsAddins/Standalone/ParameterManager/Models/GroupIsSelectedProperty.cs b/CarsonsAddins/Standalone/ParameterManager/Models/GroupIsSelectedProperty.cs
new file mode 100644
index 0000000..8694518
--- /dev/null
+++ b/CarsonsAddins/Standalone/ParameterManager/Models/GroupIsSelectedProperty.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace CarsonsAddins.Standalone.ParameterManager.Models
+{
+ class GroupIsSelectedProperty : PropertyGroupDescription
+ {
+ public GroupIsSelectedProperty() : base("IsSelected") { }
+ public override object GroupNameFromItem(object item, int level, CultureInfo culture)
+ {
+ var baseItem = base.GroupNameFromItem(item, level, culture);
+ if (!(baseItem is bool isSelected)) return "NULL";
+ return GetGroupName(isSelected);
+ }
+ public static string GetGroupName(bool isSelected)
+ {
+ return isSelected ? "Selected" : "Not Selected";
+ }
+ }
+}
diff --git a/CarsonsAddins/Standalone/ParameterManager/Models/GroupParameterValueProperty.cs b/CarsonsAddins/Standalone/ParameterManager/Models/GroupParameterValueProperty.cs
new file mode 100644
index 0000000..fa724fc
--- /dev/null
+++ b/CarsonsAddins/Standalone/ParameterManager/Models/GroupParameterValueProperty.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace CarsonsAddins.Standalone.ParameterManager.Models
+{
+ class GroupParameterValueProperty : PropertyGroupDescription
+ {
+ public GroupParameterValueProperty(string propertyName) : base(propertyName)
+ {
+ PropertyName = propertyName;
+ }
+
+ public override object GroupNameFromItem(object item, int level, CultureInfo culture)
+ {
+ var baseItem = base.GroupNameFromItem(item, level, culture);
+ ParameterCell parameterCell = baseItem as ParameterCell;
+ return GetGroupName(parameterCell);
+ }
+
+ public static string GetGroupName(ParameterCell parameterCell)
+ {
+ if (parameterCell.IsNull) return "No Parameter";
+ else if (string.IsNullOrEmpty(parameterCell.ParameterValue)) return "Empty";
+ return parameterCell.ParameterValue;
+ }
+ public static string GetGroupName(string parameterName)
+ {
+ return (string.IsNullOrEmpty(parameterName)) ? "Empty" : parameterName;
+ }
+
+ }
+}
diff --git a/CarsonsAddins/Standalone/ParameterManager/Models/ParameterCell.cs b/CarsonsAddins/Standalone/ParameterManager/Models/ParameterCell.cs
new file mode 100644
index 0000000..499ac25
--- /dev/null
+++ b/CarsonsAddins/Standalone/ParameterManager/Models/ParameterCell.cs
@@ -0,0 +1,151 @@
+using Autodesk.Revit.DB;
+using Autodesk.Revit.UI;
+using CarsonsAddins.Shared.EventHandlers;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+
+namespace CarsonsAddins.Standalone.ParameterManager.Models
+{
+ class ParameterCell : INotifyPropertyChanged
+ {
+ public static SingleCallFunctionEventHandler UpdateParameterEventHandler;
+ public event PropertyChangedEventHandler PropertyChanged;
+ private bool isSynced = true;
+ public bool IsSynced
+ {
+ get => isSynced;
+ set
+ {
+ if (isSynced == value) return;
+ isSynced = value;
+ }
+ }
+ private SolidColorBrush fontColor = new SolidColorBrush(Colors.Black);
+ public SolidColorBrush FontColor
+ {
+ get => fontColor;
+ set
+ {
+ if (value == null) return;
+ if (fontColor == value) return;
+ fontColor = value;
+ OnNotifyPropertyChanged();
+ }
+ }
+ private SolidColorBrush backgroundColor = new SolidColorBrush(Colors.White);
+ public SolidColorBrush BackgroundColor
+ {
+ get => backgroundColor;
+ set
+ {
+ if (value == null) return;
+ if (backgroundColor == value) return;
+ backgroundColor = value;
+ OnNotifyPropertyChanged();
+ }
+ }
+ public bool IsNull = true;
+ private readonly Parameter parameter;
+ private string parameterValue = "";
+ public string ParameterValue
+ {
+ get => parameterValue;
+ set
+ {
+ if (value == null) return;
+ if (parameterValue.Equals(value)) return;
+ if (IsNull) return;
+ parameterValue = value;
+ IsSynced = false;
+ PushValueToParameter();
+ OnNotifyPropertyChanged();
+ }
+ }
+
+
+ public ParameterCell(Parameter parameter)
+ {
+ this.parameter = parameter;
+ IsNull = parameter == null;
+ // parameterValue = GetParameterValue(parameter);
+ ParameterValue = GetParameterValue(parameter);
+ IsSynced = true;
+ if (IsNull) BackgroundColor = new SolidColorBrush(Colors.LightGray);
+ if (!IsNull && parameter.IsReadOnly) FontColor = new SolidColorBrush(Colors.Gray);
+ }
+
+ private string GetParameterValue(Parameter parameter)
+ {
+ if (parameter == null) return null;
+ if (StorageType.String.Equals(parameter.StorageType)) return parameter.AsString();
+ return parameter.AsValueString();
+ /*switch (parameter.StorageType)
+ {
+ case StorageType.String: return parameter.AsValueString();
+ case StorageType.Integer: return parameter.AsInteger().ToString();
+ case StorageType.Double: return parameter.AsDouble().ToString();
+ case StorageType.ElementId: return parameter.AsValueString().ToString();
+ default: return null;
+ }*/
+
+ }
+ public void Refresh()
+ {
+ if (IsNull) return;
+ ParameterValue = GetParameterValue(parameter);
+ IsSynced = true;
+ }
+ //public void PushValueToParameterEvent()
+ //{
+ // UpdateParameterHandler.Instance.handler.Functions += PushValueToParameter;
+ //}
+ public void PushValueToParameter()
+ {
+ if (IsNull) return;
+ if (parameter.IsReadOnly) return;
+ if (ParameterValue == GetParameterValue(parameter)) return;
+ //Transaction transaction = new Transaction(doc);
+ //transaction.Start("Update " + parameter.Definition.Name + " Cell");
+ try
+ {
+ UpdateParameterEventHandler.Functions += PushValueFromHandler;
+ //transaction.Commit();
+ //return;
+ }
+ catch (Exception ex)
+ {
+ //transaction.RollBack();
+ TaskDialog.Show("ParameterCell Error", ex.Message);
+ //return;
+ }
+
+ }
+ public void PushValueFromHandler(Document doc)
+ {
+ Transaction transaction = new Transaction(doc);
+ transaction.Start("Update Parameter");
+ try
+ {
+ if (parameter.StorageType != StorageType.String) parameter.SetValueString(ParameterValue);
+ else parameter.Set(ParameterValue);
+ IsSynced = true;
+ transaction.Commit();
+ }
+ catch (Exception ex)
+ {
+ transaction.RollBack();
+ TaskDialog.Show("Error Updating Element", ex.Message);
+ }
+ }
+ protected void OnNotifyPropertyChanged([CallerMemberName] string memberName = "")
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(memberName));
+ }
+ }
+}
diff --git a/CarsonsAddins/Standalone/ParameterManager/Models/ParameterManagerTable.cs b/CarsonsAddins/Standalone/ParameterManager/Models/ParameterManagerTable.cs
index 00e5665..d9a2b32 100644
--- a/CarsonsAddins/Standalone/ParameterManager/Models/ParameterManagerTable.cs
+++ b/CarsonsAddins/Standalone/ParameterManager/Models/ParameterManagerTable.cs
@@ -18,11 +18,11 @@
using System.Windows.Media;
using CarsonsAddins.Shared.EventHandlers;
-namespace CarsonsAddins.UICommands
+namespace CarsonsAddins.Standalone.ParameterManager.Models
{
///
- /// Abstracts the parameters and element data and interactions with the WPF DataGrid into its own class.
+ /// Abstracts the parameters and element data and interactions with the WPF DataGrid into its own class. Note: Created before migrating to MVVM architecture, so it doesn't exactly fit.
///
class ParameterTable
{
@@ -41,7 +41,6 @@ public ParameterTable(DataGrid dataGrid, CollectionViewSource collectionViewSour
{
this.dataGrid = dataGrid;
this.collectionViewSource = collectionViewSource;
- //dataGrid.ItemsSource = rows;
collectionViewSource.Source = rows;
ParameterCell.UpdateParameterEventHandler = new SingleCallFunctionEventHandler();
updateParametersEvent = ExternalEvent.Create(ParameterCell.UpdateParameterEventHandler);
@@ -73,13 +72,13 @@ public void Clear()
parameterReadOnly.Clear();
collectionViewSource.GroupDescriptions.Clear();
currentGroupName = "";
- //CollectionViewSource.GetDefaultView(rows).GroupDescriptions.Clear();
for (int i = dataGrid.Columns.Count - 1; i >= 2; i--)
{
dataGrid.Columns.RemoveAt(i);
}
}
+
public void SetGroup(string groupName)
{
if (groupName == "ElementId") return;
@@ -100,16 +99,19 @@ public void SetGroup(string groupName)
collectionViewSource.GroupDescriptions.Add(groupDescription);
currentGroupName = groupName;
}
+
public void ClearGroups()
{
if (collectionViewSource == null) return;
currentGroupName = "";
collectionViewSource.GroupDescriptions.Clear();
}
+
public void RefreshElements(params ElementId[] elementIds)
{
Array.ForEach(elementIds, id => RefreshElement(id));
}
+
public void RefreshElement(ElementId id)
{
if (ElementId.InvalidElementId.Equals(id)) return;
@@ -117,6 +119,7 @@ public void RefreshElement(ElementId id)
if (index == -1) return;
rows[index].Refresh();
}
+
public void Refresh()
{
foreach (ElementRow row in rows)
@@ -124,10 +127,12 @@ public void Refresh()
row.Refresh();
}
}
+
public void SetSelectedStateOfElements(ElementRow[] elementRows, bool isSelected)
{
Array.ForEach(elementRows, row => row.IsSelected = isSelected);
}
+
public ElementId[] GetSelectedElements()
{
return rows.Where(row => row.IsSelected && !ElementId.InvalidElementId.Equals(row.Id)).Select(row => row.Id).ToArray();
@@ -224,15 +229,10 @@ private void AddColumn(string parameterName, bool isReadOnly)
Header = parameterName,
IsReadOnly = isReadOnly,
CellStyle = style,
- //ElementStyle = style,
- //EditingElementStyle = style,
-
-
};
dataGrid.Columns.Add(column);
}
-
///
/// Removes a parameter column from the datagrid.
///
@@ -255,6 +255,7 @@ public void RemoveParameter(string parameterName)
}
}
+
///
/// Recursive update element parameter values.
///
@@ -285,302 +286,4 @@ public void RemoveRow(ElementId id)
ids.Remove(id);
}
}
-
- class ElementRowCollection : ObservableCollection { }
-
- ///
- /// Stores and References data of a single Element. Currently binding and tracking changes via the INotifyPropertyChanged base class. Will eventually move to binding via DependencyProperties for speed increase.
- ///
- class ElementRow : INotifyPropertyChanged // 1 to 1: Element to Row
- {
- public event PropertyChangedEventHandler PropertyChanged;
-
- public Element element { get; private set; }
- private readonly ElementId id = ElementId.InvalidElementId;
- public ElementId Id { get => id; }
- private bool isSelected = false;
- public bool IsSelected
- {
- get => isSelected;
- set
- {
- if (isSelected == value) return;
- isSelected = value;
- OnNotifyPropertyChanged();
- }
- }
-
- public Dictionary cells { private set; get; }
- public ElementRow(Element element)
- {
- cells = new Dictionary();
- this.element = element;
- id = element.Id;
- }
-
- public void Refresh()
- {
- foreach (ParameterCell cell in cells.Values)
- {
- cell.Refresh();
- }
- }
- public void Refresh(string parameterName)
- {
- if (cells.ContainsKey(parameterName)) cells[parameterName].Refresh();
- }
-
- public bool HasParameterValue(string parameterName, string valueString)
- {
- if (valueString is null) return false;
- if (parameterName == "IsSelected") return (GroupIsSelectedProperty.GetGroupName(IsSelected) == valueString);
- if (!cells.ContainsKey(parameterName)) return false;
- ParameterCell cell = cells[parameterName];
- if (cell is null) return false;
- return valueString.Equals(GroupParameterValueProperty.GetGroupName(cell));
- }
-
-
-
- public Parameter AddParameter(Definition definition)
- {
- if (element == null) return null;
- Parameter parameter = element.get_Parameter(definition);
- cells.Add(definition.Name, new ParameterCell(parameter));
- return parameter;
- }
- public Parameter AddParameter(string parameterName)
- {
- if (element == null) return null;
- if (parameterName == null) return null;
- Parameter parameter = element.LookupParameter(parameterName);
- cells.Add(parameterName, new ParameterCell(parameter));
- return parameter;
- }
- public void RemoveParameter(string parameterName)
- {
- if (!cells.ContainsKey(parameterName)) return;
- cells.Remove(parameterName);
- }
- public string GetCellValue(string parameterName)
- {
- if (parameterName == null) return "";
- if (!cells.TryGetValue(parameterName, out ParameterCell cell)) return "";
- return cell.ParameterValue;
- }
- public void PushUpdatesToElement(string parameterName)
- {
- try
- {
- if (!cells.ContainsKey(parameterName)) return;
- ParameterCell cell = cells[parameterName];
- if (cell.IsSynced) return;
- if (cell.IsNull) return;
- cell.PushValueToParameter();
-
- }
- catch (Exception ex)
- {
- TaskDialog.Show("Parameter Row Error", ex.Message);
- }
- }
- public void PushUpdatesToElement()
- {
- foreach (string parameterName in cells.Keys)
- {
- PushUpdatesToElement(parameterName);
-
-
- }
- }
-
-
-
- protected void OnNotifyPropertyChanged([CallerMemberName] string memberName = "")
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(memberName));
- }
- }
- class ParameterCell : INotifyPropertyChanged
- {
- public static SingleCallFunctionEventHandler UpdateParameterEventHandler;
- public event PropertyChangedEventHandler PropertyChanged;
- private bool isSynced = true;
- public bool IsSynced
- {
- get => isSynced;
- set
- {
- if (isSynced == value) return;
- isSynced = value;
- //OnNotifyPropertyChanged();
- }
- }
- private SolidColorBrush fontColor = new SolidColorBrush(Colors.Black);
- public SolidColorBrush FontColor
- {
- get => fontColor;
- set
- {
- if (value == null) return;
- if (fontColor == value) return;
- fontColor = value;
- OnNotifyPropertyChanged();
- }
- }
- private SolidColorBrush backgroundColor = new SolidColorBrush(Colors.White);
- public SolidColorBrush BackgroundColor
- {
- get => backgroundColor;
- set
- {
- if (value == null) return;
- if (backgroundColor == value) return;
- backgroundColor = value;
- OnNotifyPropertyChanged();
- }
- }
- public bool IsNull = true;
- private readonly Parameter parameter;
- private string parameterValue = "";
- public string ParameterValue
- {
- get => parameterValue;
- set
- {
- if (value == null) return;
- if (parameterValue.Equals(value)) return;
- if (IsNull) return;
- parameterValue = value;
- IsSynced = false;
- PushValueToParameter();
- OnNotifyPropertyChanged();
- }
- }
-
-
- public ParameterCell(Parameter parameter)
- {
- this.parameter = parameter;
- IsNull = parameter == null;
- // parameterValue = GetParameterValue(parameter);
- ParameterValue = GetParameterValue(parameter);
- IsSynced = true;
- if (IsNull) BackgroundColor = new SolidColorBrush(Colors.LightGray);
- if (!IsNull && parameter.IsReadOnly) FontColor = new SolidColorBrush(Colors.Gray);
- }
-
- private string GetParameterValue(Parameter parameter)
- {
- if (parameter == null) return null;
- if (StorageType.String.Equals(parameter.StorageType)) return parameter.AsString();
- return parameter.AsValueString();
- /*switch (parameter.StorageType)
- {
- case StorageType.String: return parameter.AsValueString();
- case StorageType.Integer: return parameter.AsInteger().ToString();
- case StorageType.Double: return parameter.AsDouble().ToString();
- case StorageType.ElementId: return parameter.AsValueString().ToString();
- default: return null;
- }*/
-
- }
- public void Refresh()
- {
- if (IsNull) return;
- ParameterValue = GetParameterValue(parameter);
- IsSynced = true;
- }
- //public void PushValueToParameterEvent()
- //{
- // UpdateParameterHandler.Instance.handler.Functions += PushValueToParameter;
- //}
- public void PushValueToParameter()
- {
- if (IsNull) return;
- if (parameter.IsReadOnly) return;
- if (ParameterValue == GetParameterValue(parameter)) return;
- //Transaction transaction = new Transaction(doc);
- //transaction.Start("Update " + parameter.Definition.Name + " Cell");
- try
- {
- UpdateParameterEventHandler.Functions += PushValueFromHandler;
- //transaction.Commit();
- //return;
- }
- catch (Exception ex)
- {
- //transaction.RollBack();
- TaskDialog.Show("ParameterCell Error", ex.Message);
- //return;
- }
-
- }
- public void PushValueFromHandler(Document doc)
- {
- Transaction transaction = new Transaction(doc);
- transaction.Start("Update Parameter");
- try
- {
- if (parameter.StorageType != StorageType.String) parameter.SetValueString(ParameterValue);
- else parameter.Set(ParameterValue);
- IsSynced = true;
- transaction.Commit();
- }
- catch (Exception ex)
- {
- transaction.RollBack();
- TaskDialog.Show("Error Updating Element", ex.Message);
- }
- }
- protected void OnNotifyPropertyChanged([CallerMemberName] string memberName = "")
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(memberName));
- }
- }
- class GroupParameterValueProperty : PropertyGroupDescription
- {
- public GroupParameterValueProperty(string propertyName) : base(propertyName)
- {
- PropertyName = propertyName;
- }
-
- public override object GroupNameFromItem(object item, int level, CultureInfo culture)
- {
- var baseItem = base.GroupNameFromItem(item, level, culture);
- ParameterCell parameterCell = baseItem as ParameterCell;
- return GetGroupName(parameterCell);
- }
-
- public static string GetGroupName(ParameterCell parameterCell)
- {
- if (parameterCell.IsNull) return "No Parameter";
- else if (string.IsNullOrEmpty(parameterCell.ParameterValue)) return "Empty";
- return parameterCell.ParameterValue;
- }
- public static string GetGroupName(string parameterName)
- {
- return (string.IsNullOrEmpty(parameterName)) ? "Empty" : parameterName;
- }
-
- }
-
- class GroupIsSelectedProperty : PropertyGroupDescription
- {
- public GroupIsSelectedProperty() : base("IsSelected") { }
- public override object GroupNameFromItem(object item, int level, CultureInfo culture)
- {
- var baseItem = base.GroupNameFromItem(item, level, culture);
- if (!(baseItem is bool isSelected) ) return "NULL";
- return GetGroupName(isSelected);
- }
- public static string GetGroupName(bool isSelected)
- {
- return isSelected ? "Selected" : "Not Selected";
- }
- }
-
-
-
-
}
\ No newline at end of file
diff --git a/CarsonsAddins/Shared/Updaters/ParameterManagerUpdater.cs b/CarsonsAddins/Standalone/ParameterManager/Models/ParameterManagerUpdater.cs
similarity index 82%
rename from CarsonsAddins/Shared/Updaters/ParameterManagerUpdater.cs
rename to CarsonsAddins/Standalone/ParameterManager/Models/ParameterManagerUpdater.cs
index bf96708..34229af 100644
--- a/CarsonsAddins/Shared/Updaters/ParameterManagerUpdater.cs
+++ b/CarsonsAddins/Standalone/ParameterManager/Models/ParameterManagerUpdater.cs
@@ -58,19 +58,12 @@ private void RegisterTriggers()
}
public void Execute(UpdaterData data)
{
- if (parameterManager == null) return;
- RemoveStaleReferences(data.GetDeletedElementIds().ToArray());
- RefreshParameters(data.GetModifiedElementIds().ToArray());
- }
+ if (parameterManager == null || elementIds.Count == 0) return;
+ ElementId[] deletedElementIds = data.GetModifiedElementIds().Where(elementId => elementIds.Contains(elementId)).ToArray();
+ ElementId[] modifiedElementIds = data.GetModifiedElementIds().Where(elementId => elementIds.Contains(elementId)).ToArray();
- private void RemoveStaleReferences(ElementId[] deletedElementIds)
- {
- ElementId[] filteredDeletedElementIds = deletedElementIds.Where(id => elementIds.Contains(id)).ToArray();
- parameterManager.RemoveElements(filteredDeletedElementIds);
- }
- private void RefreshParameters(ElementId[] elementIds)
- {
- parameterManager.RefreshElements(elementIds);
+ if (deletedElementIds.Length > 0) parameterManager.RemoveElements(deletedElementIds);
+ if (modifiedElementIds.Length > 0) parameterManager.RefreshElements(modifiedElementIds);
}
public string GetAdditionalInformation()
diff --git a/CarsonsAddins/Shared/Updaters/StaleReferenceUpdater.cs b/CarsonsAddins/Standalone/ParameterManager/Models/StaleReferenceUpdater.cs
similarity index 100%
rename from CarsonsAddins/Shared/Updaters/StaleReferenceUpdater.cs
rename to CarsonsAddins/Standalone/ParameterManager/Models/StaleReferenceUpdater.cs
diff --git a/CarsonsAddins/Standalone/ParameterManager/Views/ParameterManagerDockablePane.xaml b/CarsonsAddins/Standalone/ParameterManager/Views/ParameterManagerDockablePane.xaml
index cbb636c..04051dd 100644
--- a/CarsonsAddins/Standalone/ParameterManager/Views/ParameterManagerDockablePane.xaml
+++ b/CarsonsAddins/Standalone/ParameterManager/Views/ParameterManagerDockablePane.xaml
@@ -6,8 +6,7 @@
xmlns:local="clr-namespace:CarsonsAddins"
xmlns:system="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
-
- d:DesignHeight="444" d:DesignWidth="512" >
+ Height="444" Width="512">
-
-
+
+
-
+
@@ -99,7 +98,7 @@
-
+
@@ -130,7 +129,7 @@
-
+
diff --git a/CarsonsAddins/Standalone/ParameterManager/ViewModels/ParameterManagerDockablePane.xaml.cs b/CarsonsAddins/Standalone/ParameterManager/Views/ParameterManagerDockablePane.xaml.cs
similarity index 94%
rename from CarsonsAddins/Standalone/ParameterManager/ViewModels/ParameterManagerDockablePane.xaml.cs
rename to CarsonsAddins/Standalone/ParameterManager/Views/ParameterManagerDockablePane.xaml.cs
index eb2f5d6..31c6e0a 100644
--- a/CarsonsAddins/Standalone/ParameterManager/ViewModels/ParameterManagerDockablePane.xaml.cs
+++ b/CarsonsAddins/Standalone/ParameterManager/Views/ParameterManagerDockablePane.xaml.cs
@@ -1,6 +1,6 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
-using CarsonsAddins.UICommands;
+using CarsonsAddins.Standalone.ParameterManager.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -15,7 +15,7 @@
namespace CarsonsAddins
{
///
- /// Allows for Pipe End Prep to be set for each side of each Flange / Union FamilyInstance that is currently loaded.
+ /// Allows for Elements to be sorted and grouped by parameters as well as edit those parameters
///
public partial class ParameterManagerDockablePane : Page, IDockablePaneProvider, ISettingsUIComponent, ISettingsUpdaterComponent
{
@@ -33,8 +33,8 @@ public ParameterManagerDockablePane()
InitializeComponent();
CollectionViewSource collectionViewSource = FindResource("ElementRowCollectionViewSource") as CollectionViewSource;
table = new ParameterTable(SelectionDataGrid, collectionViewSource);
-
-
+
+
}
public void Init(UIDocument uidoc)
@@ -227,14 +227,7 @@ private void SelectGroup_CheckBox(object sender, RoutedEventArgs e)
}
-
-
- }
- class ParameterTracker
- {
- private List allPossibleParameters = new List();
- private ObservableCollection filteredParameterList = new ObservableCollection();
- public ParameterTracker() { }
+
}
}
\ No newline at end of file
diff --git a/CarsonsAddins/Pipeline/Models/PipeLine.cs b/CarsonsAddins/Standalone/PipeLine.cs
similarity index 100%
rename from CarsonsAddins/Pipeline/Models/PipeLine.cs
rename to CarsonsAddins/Standalone/PipeLine.cs
diff --git a/CarsonsAddins/Pipeline/Models/SelectPipeLineCommand.cs b/CarsonsAddins/Standalone/SelectPipeLineCommand.cs
similarity index 100%
rename from CarsonsAddins/Pipeline/Models/SelectPipeLineCommand.cs
rename to CarsonsAddins/Standalone/SelectPipeLineCommand.cs
diff --git a/CarsonsAddins/Standalone/SmartFlipCommand.cs b/CarsonsAddins/Standalone/SmartFlipCommand.cs
index 0d148bf..14d149f 100644
--- a/CarsonsAddins/Standalone/SmartFlipCommand.cs
+++ b/CarsonsAddins/Standalone/SmartFlipCommand.cs
@@ -80,7 +80,7 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme
{
transaction.RollBack();
message += "Could not flip element.\n";
- return Result.Failed;
+ return Result.Cancelled;
}
transaction.Commit();
diff --git a/CarsonsAddins/app.config b/CarsonsAddins/app.config
index aa2fb27..afaba65 100644
--- a/CarsonsAddins/app.config
+++ b/CarsonsAddins/app.config
@@ -1,7 +1,7 @@
-
+
-
+
@@ -10,15 +10,20 @@
-
-
-
-
+ {"PipeEndPrepBCWindow":true,"PipeEndPrepWindow":false,"DebugSettingsCommand":false,"DimensionTextWindow":true,"DimensionPipeLineCommand":true,"SelectPipeLineCommand":true,"DebugGeometryCommand":false,"FilterPipingElementsCommand":true,"GetTotalPipeLengthCommand":true,"ParameterManagerDockablePane":true,"SelectAllElementsOfSystemCommand":true,"SmartFlipCommand":true}
-
+ {"primaryDimensionTypeName":"C & B","secondaryPipeDimensionTypeName":"C & B PIPE w/dot","secondaryAccessoryDimensionTypeName":"C & B FITTING w/dot","secondaryFittingDimensionTypeName":"C & B FITTING w/dot","secondaryOtherDimensionTypeName":"C & B FITTING w/dot","graphicsStyleNames":["<Centerline>","Pipes","Pipe Fittings","zLines"],"flangeModeItems":[{"elementId":7465461,"Name":"DI FLG DBL","Mode":2},{"elementId":7151319,"Name":"DI FCA","Mode":2},{"elementId":4634124,"Name":"Coupling - Generic","Mode":0},{"elementId":7047513,"Name":"DI CMJ LONG SLEEVE C153","Mode":4},{"elementId":7230174,"Name":"CS WELD GAP MP","Mode":0},{"elementId":7230980,"Name":"CS WELD GAP","Mode":0},{"elementId":7316050,"Name":"DI FLG DBL for fillers","Mode":2},{"elementId":7316874,"Name":"DI FLG DBL MP","Mode":2},{"elementId":7317685,"Name":"DI FLG DBL UN LINKED","Mode":2},{"elementId":7320961,"Name":"DI FLG SINGLE MP","Mode":2},{"elementId":7322565,"Name":"DI FLG SINGLE","Mode":2},{"elementId":7303217,"Name":"DI FLG GASKET DO NOT SCHEDULE","Mode":2},{"elementId":7315853,"Name":"DI FLG GASKET","Mode":2},{"elementId":7319339,"Name":"DI FLG DBL WITH STUDS","Mode":2},{"elementId":7237273,"Name":"SS WELD GAP","Mode":0},{"elementId":7252261,"Name":"SS WELD GAP MP","Mode":0},{"elementId":4584135,"Name":"Non-Connector","Mode":0},{"elementId":7030191,"Name":"Victaulic-Grooved Coupling OGS-AGS_Face","Mode":2},{"elementId":7036679,"Name":"DI HP LOK FITTING BELL","Mode":3},{"elementId":7039212,"Name":"DI MJ BELL","Mode":4},{"elementId":7040062,"Name":"DI PO BELL","Mode":4},{"elementId":7062627,"Name":"Victaulic-AWWA-Grooved Coupling","Mode":2},{"elementId":7063762,"Name":"DI MJ LONG SLEEVE C110","Mode":4},{"elementId":7105299,"Name":"DI TRFLEX SLEEVE DOMESTIC","Mode":3},{"elementId":7123588,"Name":"DI TRFLEX SLEEVE IMPORT","Mode":3},{"elementId":7256569,"Name":"DI TR FLEX FITTING BELL MP","Mode":3},{"elementId":7273137,"Name":"DI HP LOK FITTING BELL MP","Mode":3},{"elementId":7275670,"Name":"DI MJ BELL MP","Mode":4},{"elementId":7276520,"Name":"DI PO BELL MP WITH FIELD LOK GASKET","Mode":2},{"elementId":7279034,"Name":"DI PO BELL MP","Mode":4},{"elementId":7284498,"Name":"Victaulic-AWWA-Coupling Style 31_MP","Mode":2},{"elementId":7286104,"Name":"DI VIC STYLE 31 CPLG_MP","Mode":2},{"elementId":7289129,"Name":"DI VIC STYLE 31 CPLG","Mode":2},{"elementId":7292332,"Name":"DI FLG GASKET w- STUDS","Mode":2},{"elementId":7306393,"Name":"FLG PACK w TWO GASKETS & EX LONG STUDS w DBL NUTS EA","Mode":2},{"elementId":7309215,"Name":"DI HDSS BELL","Mode":3},{"elementId":7311748,"Name":"DI HDSS BELL MP","Mode":3},{"elementId":7314281,"Name":"DI FLG x VIC FLG STYLE 341","Mode":2},{"elementId":7321771,"Name":"DI FLG SINGLE wo GASKET","Mode":2},{"elementId":7466331,"Name":"DI TR FLEX FITTING BELL","Mode":3}]}
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CarsonsAddins/packages.config b/CarsonsAddins/packages.config
deleted file mode 100644
index 7b8347e..0000000
--- a/CarsonsAddins/packages.config
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file