diff --git a/SDK/Add-In Manager/Autodesk.AddInManager.Command.dll b/SDK/Add-In Manager/Autodesk.AddInManager.Command.dll
index b9d9368a..c4b71796 100644
Binary files a/SDK/Add-In Manager/Autodesk.AddInManager.Command.dll and b/SDK/Add-In Manager/Autodesk.AddInManager.Command.dll differ
diff --git a/SDK/Autodesk Icon Guidelines.pdf b/SDK/Autodesk Icon Guidelines.pdf
deleted file mode 100644
index 42490ea2..00000000
Binary files a/SDK/Autodesk Icon Guidelines.pdf and /dev/null differ
diff --git a/SDK/Getting Started with the Revit API.docx b/SDK/Getting Started with the Revit API.docx
index b7ee9d70..ebf952f5 100644
Binary files a/SDK/Getting Started with the Revit API.docx and b/SDK/Getting Started with the Revit API.docx differ
diff --git a/SDK/Macro Samples/GetTimeElapsed/Addin/GetTimeElapsed.dat b/SDK/Macro Samples/GetTimeElapsed/Addin/GetTimeElapsed.dat
new file mode 100644
index 00000000..ae21dfd3
Binary files /dev/null and b/SDK/Macro Samples/GetTimeElapsed/Addin/GetTimeElapsed.dat differ
diff --git a/SDK/Macro Samples/GetTimeElapsed/Addin/GetTimeElapsed.dll b/SDK/Macro Samples/GetTimeElapsed/Addin/GetTimeElapsed.dll
new file mode 100644
index 00000000..0c51de0c
Binary files /dev/null and b/SDK/Macro Samples/GetTimeElapsed/Addin/GetTimeElapsed.dll differ
diff --git a/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/.vscode/extensions.json b/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/.vscode/extensions.json
new file mode 100644
index 00000000..61ae8a27
--- /dev/null
+++ b/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/.vscode/extensions.json
@@ -0,0 +1,5 @@
+{
+ "recommendations": [
+ "ms-dotnettools.csharp",
+ ]
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/.vscode/launch.json b/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/.vscode/launch.json
new file mode 100644
index 00000000..a19a9b99
--- /dev/null
+++ b/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/.vscode/launch.json
@@ -0,0 +1,15 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Attach to Revit",
+ "type": "coreclr",
+ "request": "attach",
+ "processName": "revit.exe",
+ "justMyCode": true
+ }
+ ]
+}
diff --git a/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/.vscode/tasks.json b/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/.vscode/tasks.json
new file mode 100644
index 00000000..ca683426
--- /dev/null
+++ b/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/.vscode/tasks.json
@@ -0,0 +1,14 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ ]
+}
diff --git a/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/GetTimeElapsed.csproj b/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/GetTimeElapsed.csproj
new file mode 100644
index 00000000..87a139a4
--- /dev/null
+++ b/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/GetTimeElapsed.csproj
@@ -0,0 +1,38 @@
+
+
+ net8.0-windows
+ enable
+ enable
+
+
+ x64
+ false
+ false
+ False
+ True
+ Portable
+ ..\..\Addin\
+ GetTimeElapsed
+ obj\
+ DEBUG;TRACE
+ obj\Debug
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+
+
+
+ False
+
+
+ False
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/Properties/AssemblyInfo.cs b/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..7f4a7cce
--- /dev/null
+++ b/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/Properties/AssemblyInfo.cs
@@ -0,0 +1,31 @@
+#region Using directives
+
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+#endregion
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("NewModule")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("NewModule")]
+[assembly: AssemblyCopyright("Copyright 2023")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all the values or you can use the default the Revision and
+// Build Numbers by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.*")]
diff --git a/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/ThisApplication.Designer.cs b/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/ThisApplication.Designer.cs
new file mode 100644
index 00000000..c88feb7f
--- /dev/null
+++ b/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/ThisApplication.Designer.cs
@@ -0,0 +1,54 @@
+namespace GetTimeElapsed
+{
+
+ public sealed partial class ThisApplication : Autodesk.Revit.UI.Macros.ApplicationEntryPoint
+ {
+
+ public event System.EventHandler Startup;
+
+ public event System.EventHandler Shutdown;
+
+ ///
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ private void OnStartup()
+ {
+ }
+
+ ///
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ protected override void FinishInitialization()
+ {
+ base.FinishInitialization();
+ this.OnStartup();
+ this.InternalStartup();
+ if ((this.Startup != null))
+ {
+ this.Startup(this, System.EventArgs.Empty);
+ }
+ }
+
+ ///
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ protected override void OnShutdown()
+ {
+ if ((this.Shutdown != null))
+ {
+ this.Shutdown(this, System.EventArgs.Empty);
+ }
+ base.OnShutdown();
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ protected override string PrimaryCookie
+ {
+ get
+ {
+ return "ThisApplication";
+ }
+ }
+ }
+}
diff --git a/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/ThisApplication.cs b/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/ThisApplication.cs
new file mode 100644
index 00000000..ebe83fe5
--- /dev/null
+++ b/SDK/Macro Samples/GetTimeElapsed/Source/GetTimeElapsed/ThisApplication.cs
@@ -0,0 +1,139 @@
+using System;
+using Autodesk.Revit.UI;
+using Autodesk.Revit.DB;
+using Autodesk.Revit.DB.Events;
+using Autodesk.Revit.UI.Selection;
+using System.Collections.Generic;
+using System.Collections;
+using System.Linq;
+using Autodesk.Revit.DB.ExtensibleStorage;
+
+namespace GetTimeElapsed
+{
+ [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
+ [Autodesk.Revit.DB.Macros.AddInId("4FD02D8C-2CDD-4FA8-89E0-0D03B812A398")]
+ public partial class ThisApplication
+ {
+ Dictionary m_dicLastSaved = new Dictionary();
+ private void Module_Startup(object? sender, EventArgs e)
+ {
+ InitializeDicLastSaved();
+ this.Application.DocumentSaved += new EventHandler(ThisApplication_DocumentSaved);
+ this.Application.DocumentOpened += new EventHandler(ThisApplication_DocumentOpened);
+ this.Application.DocumentCreated += new EventHandler(ThisApplication_DocumentCreated);
+ this.Application.DocumentClosing += new EventHandler(ThisApplication_DocumentClosing);
+ }
+
+ private void Module_Shutdown(object? sender, EventArgs e)
+ {
+ this.Application.DocumentSaved -= new EventHandler(ThisApplication_DocumentSaved);
+ this.Application.DocumentOpened -= new EventHandler(ThisApplication_DocumentOpened);
+ this.Application.DocumentCreated -= new EventHandler(ThisApplication_DocumentCreated);
+ this.Application.DocumentClosing -= new EventHandler(ThisApplication_DocumentClosing);
+ }
+
+ #region Revit Macros generated code
+ private void InternalStartup()
+ {
+ this.Startup += new System.EventHandler(Module_Startup);
+ this.Shutdown += new System.EventHandler(Module_Shutdown);
+ }
+ #endregion
+
+ ///
+ /// Initialize
+ ///
+ private void InitializeDicLastSaved()
+ {
+ foreach (Document document in this.Application.Documents)
+ {
+ m_dicLastSaved.Add(document, DateTime.MaxValue);
+ }
+ }
+
+ ///
+ /// DocumentCreated event, add the created document into m_dicLastSaved
+ ///
+ /// sender
+ /// DocumentCreatedEventArgs
+ public void ThisApplication_DocumentCreated(object? sender, DocumentCreatedEventArgs args)
+ {
+ m_dicLastSaved.Add(args.Document, DateTime.MaxValue);
+ }
+
+ ///
+ /// DocumentClosing event, remove the closing document from m_dicLastSaved
+ ///
+ /// sender
+ /// DocumentClosingEventArgs
+ public void ThisApplication_DocumentClosing(object? sender, DocumentClosingEventArgs args)
+ {
+ m_dicLastSaved.Remove(args.Document);
+ }
+
+ ///
+ /// DocumentOpened event, add the opened document into m_dicLastSaved
+ ///
+ /// sender
+ /// DocumentOpenedEventArgs
+ public void ThisApplication_DocumentOpened(object? sender, DocumentOpenedEventArgs args)
+ {
+ m_dicLastSaved.Add(args.Document, DateTime.MaxValue);
+ }
+
+ ///
+ /// DocumentSaved event, record the current DataTime for the saved document
+ ///
+ /// sender
+ /// DocumentSavedEventArgs
+ public void ThisApplication_DocumentSaved(object? sender, DocumentSavedEventArgs args)
+ {
+ this.m_dicLastSaved[args.Document] = DateTime.Now;
+ }
+
+ ///
+ /// FormatTimeSpan
+ ///
+ /// TimeSpan
+ /// the string of TimeSpan
+ public String FormatTimeSpan(TimeSpan elapse)
+ {
+ String elapseStr = elapse.ToString();
+ int lastIndexOfDot = elapseStr.LastIndexOf('.');
+ return elapseStr.Substring(0, lastIndexOfDot);
+ }
+
+ ///
+ /// GetTimeElapsedSinceLastSave
+ ///
+ public void GetTimeElapsedSinceLastSave()
+ {
+ String text = String.Format("{0,-30}{1,-30}",
+ "Document Full Name",
+ "Elapse Time Since Last Save(day.hh:mm:ss)")
+ + "\n";
+ foreach (KeyValuePair pair in m_dicLastSaved)
+ {
+ String strElapsed = String.Empty;
+ if (pair.Value == DateTime.MaxValue)
+ {
+ strElapsed = "Never";
+ }
+ else
+ {
+ strElapsed = FormatTimeSpan(DateTime.Now - pair.Value);
+ }
+
+ String fileName = System.IO.Path.GetFileName(pair.Key.PathName);
+ if (String.IsNullOrEmpty(fileName))
+ {
+ fileName = "*New*";
+ }
+
+ text += String.Format("{0,-30}{1,-30}", fileName, strElapsed) + "\n";
+ }
+
+ TaskDialog.Show("Macro GetTimeElapsedSinceLastSave", text);
+ }
+ }
+}
diff --git a/SDK/Macro Samples/Macro Samples Readme.doc b/SDK/Macro Samples/Macro Samples Readme.doc
index ca7f6ecb..ac2cb136 100644
Binary files a/SDK/Macro Samples/Macro Samples Readme.doc and b/SDK/Macro Samples/Macro Samples Readme.doc differ
diff --git a/SDK/Macro Samples/MacroSamples_MEP/Addin/MacroSamples_MEP.dat b/SDK/Macro Samples/MacroSamples_MEP/Addin/MacroSamples_MEP.dat
new file mode 100644
index 00000000..f2790674
Binary files /dev/null and b/SDK/Macro Samples/MacroSamples_MEP/Addin/MacroSamples_MEP.dat differ
diff --git a/SDK/Macro Samples/MacroSamples_MEP/Addin/MacroSamples_MEP.dll b/SDK/Macro Samples/MacroSamples_MEP/Addin/MacroSamples_MEP.dll
new file mode 100644
index 00000000..43b7e3ed
Binary files /dev/null and b/SDK/Macro Samples/MacroSamples_MEP/Addin/MacroSamples_MEP.dll differ
diff --git a/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/.vscode/extensions.json b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/.vscode/extensions.json
new file mode 100644
index 00000000..61ae8a27
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/.vscode/extensions.json
@@ -0,0 +1,5 @@
+{
+ "recommendations": [
+ "ms-dotnettools.csharp",
+ ]
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/.vscode/launch.json b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/.vscode/launch.json
new file mode 100644
index 00000000..a19a9b99
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/.vscode/launch.json
@@ -0,0 +1,15 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Attach to Revit",
+ "type": "coreclr",
+ "request": "attach",
+ "processName": "revit.exe",
+ "justMyCode": true
+ }
+ ]
+}
diff --git a/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/.vscode/tasks.json b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/.vscode/tasks.json
new file mode 100644
index 00000000..ca683426
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/.vscode/tasks.json
@@ -0,0 +1,14 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ ]
+}
diff --git a/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/Detector.cs b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/Detector.cs
new file mode 100644
index 00000000..6e13ee56
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/Detector.cs
@@ -0,0 +1,161 @@
+//
+// (C) Copyright 2003-2008 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using Autodesk.Revit;
+using Autodesk.Revit.DB;
+using Autodesk.Revit.DB.Mechanical;
+
+using Element = Autodesk.Revit.DB.Element;
+
+namespace CS_AvoidObstruction
+{
+ ///
+ /// This class is used to detect the obstructions of a Line or a ray.
+ ///
+ class Detector
+ {
+ ///
+ /// Revit Document.
+ ///
+ private Document m_rvtDoc;
+
+ ///
+ /// Revit 3D view.
+ ///
+ private View3D? m_view3d;
+
+ ///
+ /// Constructor, initialize all the fields.
+ ///
+ /// Revit Document
+ public Detector(Document rvtDoc)
+ {
+ m_rvtDoc = rvtDoc;
+ ElementArray views = new ElementArray();
+ ElementFilter view3DElementFilter = new ElementClassFilter(typeof(View3D));
+ FilteredElementCollector collector = new FilteredElementCollector(m_rvtDoc);
+ collector.WherePasses(view3DElementFilter);
+ m_view3d = collector.ToElements()[0] as View3D;
+ }
+
+ ///
+ /// Return all the obstructions which intersect with a ray given by an origin and a direction.
+ ///
+ /// Ray's origin
+ /// Ray's direction
+ /// Obstructions intersected with the given ray
+ public List Obstructions(XYZ origin, XYZ dir)
+ {
+ List result = new List();
+ ReferenceIntersector referenceIntersector = new ReferenceIntersector(m_view3d);
+ referenceIntersector.TargetType = FindReferenceTarget.Face;
+ var obstructionsOnUnboundLine = referenceIntersector.Find(origin, dir);
+ foreach (ReferenceWithContext gRef in obstructionsOnUnboundLine)
+ {
+ if (!InArray(result, gRef))
+ {
+ result.Add(gRef);
+ }
+ }
+ result.Sort(CompareReferences);
+ return result;
+ }
+
+ ///
+ /// Return all the obstructions which intersect with a bound line.
+ ///
+ /// Bound line
+ /// Obstructions intersected with the bound line
+ public List Obstructions(Line boundLine)
+ {
+ List result = new List();
+ XYZ startPt = boundLine.GetEndPoint(0);
+ XYZ endPt = boundLine.GetEndPoint(1);
+ XYZ dir = (endPt.Subtract(startPt)).Normalize();
+ ReferenceIntersector referenceIntersector = new ReferenceIntersector(m_view3d);
+ referenceIntersector.TargetType = FindReferenceTarget.Face;
+ var obstructionsOnUnboundLine = referenceIntersector.Find(startPt, dir);
+ foreach (ReferenceWithContext gRef in obstructionsOnUnboundLine)
+ {
+ Reference refr = gRef.GetReference();
+ // Judge whether the point is in the bound line or not, if the distance between the point and line
+ // is Zero, then the point is in the bound line.
+ if (boundLine.Distance(refr.GlobalPoint) < 1e-9)
+ {
+ if (!InArray(result, gRef))
+ {
+ result.Add(gRef);
+ }
+ }
+ }
+ result.Sort(CompareReferences);
+ return result;
+ }
+
+ ///
+ /// Judge whether a given Reference is in a ReferenceWithContext list.
+ /// Give two ReferenceWithContexts, if their Proximitys and Element Ids are equal,
+ /// we say the two ReferenceWithContexts are equal.
+ ///
+ /// ReferenceWithContext Array
+ /// ReferenceWithContext
+ /// True of false
+ private bool InArray(List arr, ReferenceWithContext entry)
+ {
+ foreach (ReferenceWithContext tmp in arr)
+ {
+ if (tmp.Proximity == entry.Proximity &&
+ tmp.GetReference().ElementId.Value == entry.GetReference().ElementId.Value)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ ///
+ /// Used to compare two ReferenceWithContexts, just compare their Proximitys.
+ ///
+ /// First ReferenceWithContext to compare
+ /// Second ReferenceWithContext to compare
+ /// -1, 0, or 1
+ private int CompareReferences(ReferenceWithContext a, ReferenceWithContext b)
+ {
+ if (a.Proximity > b.Proximity)
+ {
+ return 1;
+ }
+
+ if (a.Proximity < b.Proximity)
+ {
+ return -1;
+ }
+
+ return 0;
+ }
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/MacroSamples_MEP.csproj b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/MacroSamples_MEP.csproj
new file mode 100644
index 00000000..20b19e60
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/MacroSamples_MEP.csproj
@@ -0,0 +1,38 @@
+
+
+ net8.0-windows
+ enable
+ enable
+
+
+ x64
+ false
+ false
+ False
+ True
+ Portable
+ ..\..\Addin\
+ MacroSamples_MEP
+ obj\
+ DEBUG;TRACE
+ obj\Debug
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+
+
+
+ False
+
+
+ False
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/Properties/AssemblyInfo.cs b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..7f4a7cce
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/Properties/AssemblyInfo.cs
@@ -0,0 +1,31 @@
+#region Using directives
+
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+#endregion
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("NewModule")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("NewModule")]
+[assembly: AssemblyCopyright("Copyright 2023")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all the values or you can use the default the Revision and
+// Build Numbers by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.*")]
diff --git a/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/Resolver.cs b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/Resolver.cs
new file mode 100644
index 00000000..f57d3a04
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/Resolver.cs
@@ -0,0 +1,542 @@
+//
+// (C) Copyright 2003-2017 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Autodesk.Revit.DB;
+using Autodesk.Revit.UI;
+using Autodesk.Revit;
+using Autodesk.Revit.ApplicationServices;
+using Autodesk.Revit.DB.Plumbing;
+using Autodesk.Revit.DB.Mechanical;
+using System.Diagnostics;
+using Element = Autodesk.Revit.DB.Element;
+using System.Collections;
+
+namespace CS_AvoidObstruction
+{
+ ///
+ /// This class implement the algorithm to detect the obstruction and resolve it.
+ ///
+ class Resolver
+ {
+ ///
+ /// Revit Document.
+ ///
+ private Document? m_rvtDoc;
+
+ ///
+ /// Detector to detect the obstructions.
+ ///
+ private Detector m_detector;
+
+
+ PipingSystemType? m_pipingSystemType;
+
+ ///
+ /// Constructor, initialize all the fields of this class.
+ ///
+ /// Revit ExternalCommandData from external command entrance
+ public Resolver(Document doc)
+ {
+ m_rvtDoc = doc;
+ m_detector = new Detector(m_rvtDoc);
+
+ FilteredElementCollector collector = new FilteredElementCollector(m_rvtDoc);
+ var pipingSystemTypes = collector.OfClass(typeof(PipingSystemType)).ToElements();
+ foreach (PipingSystemType pipingSystemType in pipingSystemTypes)
+ {
+ if (pipingSystemType.SystemClassification == MEPSystemClassification.SupplyHydronic ||
+ pipingSystemType.SystemClassification == MEPSystemClassification.ReturnHydronic)
+ {
+ m_pipingSystemType = pipingSystemType;
+ break;
+ }
+ }
+ }
+
+ ///
+ /// Detect and resolve the obstructions of all Pipes.
+ ///
+ public void Resolve()
+ {
+ List pipes = new List();
+ FilteredElementCollector collector = new FilteredElementCollector(m_rvtDoc);
+ pipes.AddRange(collector.OfClass(typeof(Pipe)).ToElements());
+ foreach (Element pipe in pipes)
+ {
+ Resolve(pipe as Pipe);
+ }
+ }
+
+ ///
+ /// Calculate the uniform perpendicular directions with inputting direction "dir".
+ ///
+ /// Direction to calculate
+ /// How many perpendicular directions will be calculated
+ /// The calculated perpendicular directions with dir
+ private List PerpendicularDirs(Autodesk.Revit.DB.XYZ dir, int count)
+ {
+ List dirs = new List();
+ Plane plane = Plane.CreateByNormalAndOrigin(dir, Autodesk.Revit.DB.XYZ.Zero);
+ Arc arc = Arc.Create(plane, 1.0, 0, 6.28);
+
+ double delta = 1.0 / (double)count;
+ for (int i = 1; i <= count; i++)
+ {
+ Autodesk.Revit.DB.XYZ pt = arc.Evaluate(delta * i, true);
+ dirs.Add(pt);
+ }
+
+ return dirs;
+ }
+
+ ///
+ /// Detect the obstructions of pipe and resolve them.
+ ///
+ /// Pipe to resolve
+ private void Resolve(Pipe? pipe)
+ {
+ if (pipe == null || m_pipingSystemType == null || m_rvtDoc == null)
+ return;
+ var parameter = pipe.get_Parameter(BuiltInParameter.RBS_START_LEVEL_PARAM);
+ var levelId = parameter.AsElementId();
+ var systemTypeId = m_pipingSystemType.Id;
+ // Get the centerline of pipe.
+
+ Line? pipeLine = (pipe.Location as LocationCurve)?.Curve as Line;
+
+ // Calculate the intersection references with pipe's centerline.
+ if (pipeLine == null)
+ return;
+ List obstructionRefArr = m_detector.Obstructions(pipeLine);
+
+ // Filter out the references, just allow Pipe, Beam, and Duct.
+ Filter(pipe, obstructionRefArr);
+
+ if (obstructionRefArr.Count == 0)
+ {
+ // There are no intersection found.
+ return;
+ }
+
+ // Calculate the direction of pipe's centerline.
+ Autodesk.Revit.DB.XYZ dir = pipeLine.GetEndPoint(1) - pipeLine.GetEndPoint(0);
+
+ // Build the sections from the intersection references.
+ List sections = Section.BuildSections(obstructionRefArr, dir.Normalize());
+
+ // Merge the neighbor sections if the distance of them is too close.
+ for (int i = sections.Count - 2; i >= 0; i--)
+ {
+ Autodesk.Revit.DB.XYZ detal = sections[i].End - sections[i + 1].Start;
+ if (detal.GetLength() < pipe.Diameter * 3)
+ {
+ sections[i].Refs.AddRange(sections[i + 1].Refs);
+ sections.RemoveAt(i + 1);
+ }
+ }
+
+ // Resolve the obstructions one by one.
+ foreach (Section sec in sections)
+ {
+ Resolve(pipe, sec);
+ }
+
+ // Connect the neighbor sections with pipe and elbow fittings.
+ //
+ for (int i = 1; i < sections.Count; i++)
+ {
+ // Get the end point from the previous section.
+ Autodesk.Revit.DB.XYZ start = sections[i - 1].End;
+
+ // Get the start point from the current section.
+ Autodesk.Revit.DB.XYZ end = sections[i].Start;
+
+ // Create a pipe between two neighbor section.
+ Pipe tmpPipe = Pipe.Create(m_rvtDoc, systemTypeId, pipe.PipeType.Id, levelId, start, end);
+
+ // Copy pipe's parameters values to tmpPipe.
+ CopyParameters(pipe, tmpPipe);
+
+ // Create elbow fitting to connect previous section with tmpPipe.
+ Connector? conn1 = FindConnector(sections[i - 1].Pipes[2], start);
+ Connector? conn2 = FindConnector(tmpPipe, start);
+ FamilyInstance fi = m_rvtDoc.Create.NewElbowFitting(conn1, conn2);
+
+ // Create elbow fitting to connect current section with tmpPipe.
+ Connector? conn3 = FindConnector(sections[i].Pipes[0], end);
+ Connector? conn4 = FindConnector(tmpPipe, end);
+ FamilyInstance f2 = m_rvtDoc.Create.NewElbowFitting(conn3, conn4);
+ }
+
+ // Find two connectors which pipe's two ends connector connected to.
+ Connector? startConn = FindConnectedTo(pipe, pipeLine.GetEndPoint(0));
+ Connector? endConn = FindConnectedTo(pipe, pipeLine.GetEndPoint(1));
+
+ Pipe? startPipe = null;
+ if (null != startConn)
+ {
+ // Create a pipe between pipe's start connector and pipe's start section.
+ startPipe = Pipe.Create(m_rvtDoc, pipe.PipeType.Id, levelId, startConn, sections[0].Start);
+ }
+ else
+ {
+ // Create a pipe between pipe's start point and pipe's start section.
+ startPipe = Pipe.Create(m_rvtDoc, systemTypeId, pipe.PipeType.Id, levelId, sections[0].Start, pipeLine.GetEndPoint(0));
+ }
+
+ // Copy parameters from pipe to startPipe.
+ CopyParameters(pipe, startPipe);
+
+ // Connect the startPipe and first section with elbow fitting.
+ Connector? connStart1 = FindConnector(startPipe, sections[0].Start);
+ Connector? connStart2 = FindConnector(sections[0].Pipes[0], sections[0].Start);
+ FamilyInstance fii = m_rvtDoc.Create.NewElbowFitting(connStart1, connStart2);
+
+ Pipe? endPipe = null;
+ int count = sections.Count;
+ if (null != endConn)
+ {
+ // Create a pipe between pipe's end connector and pipe's end section.
+ endPipe = Pipe.Create(m_rvtDoc, pipe.PipeType.Id, levelId, endConn, sections[count - 1].End);
+ }
+ else
+ {
+ // Create a pipe between pipe's end point and pipe's end section.
+ endPipe = Pipe.Create(m_rvtDoc, systemTypeId, pipe.PipeType.Id, levelId, sections[count - 1].End, pipeLine.GetEndPoint(1));
+ }
+
+ // Copy parameters from pipe to endPipe.
+ CopyParameters(pipe, endPipe);
+
+ // Connect the endPipe and last section with elbow fitting.
+ Connector? connEnd1 = FindConnector(endPipe, sections[count - 1].End);
+ Connector? connEnd2 = FindConnector(sections[count - 1].Pipes[2], sections[count - 1].End);
+ FamilyInstance fiii = m_rvtDoc.Create.NewElbowFitting(connEnd1, connEnd2);
+
+ // Delete the pipe after resolved.
+ m_rvtDoc.Delete(pipe.Id);
+ }
+
+ ///
+ /// Filter the inputting References, just allow Pipe, Duct and Beam References.
+ ///
+ /// Pipe
+ /// References to filter
+ private void Filter(Pipe pipe, List refs)
+ {
+ if (m_rvtDoc == null)
+ return;
+ for (int i = refs.Count - 1; i >= 0; i--)
+ {
+ Reference cur = refs[i].GetReference();
+ Element curElem = m_rvtDoc.GetElement(cur);
+ if (curElem.Id == pipe.Id ||
+ (!(curElem is Pipe) && !(curElem is Duct) &&
+ curElem.Category.Id.Value != (int)BuiltInCategory.OST_StructuralFraming))
+ {
+ refs.RemoveAt(i);
+ }
+ }
+ }
+
+ ///
+ /// This method will find out a route to avoid the obstruction.
+ ///
+ /// Pipe to resolve
+ /// Pipe's one obstruction
+ /// A route which can avoid the obstruction
+ private Line FindRoute(Pipe pipe, Section section)
+ {
+
+ // Perpendicular direction minimal length.
+ double minLength = pipe.Diameter * 2;
+
+ // Parallel direction jump step.
+ double jumpStep = pipe.Diameter;
+
+ // Calculate the directions in which to find the solution.
+ List dirs = new List();
+ Autodesk.Revit.DB.XYZ? crossDir = null;
+ foreach (ReferenceWithContext gref in section.Refs)
+ {
+ if (m_rvtDoc == null)
+ continue;
+ Element elem = m_rvtDoc.GetElement(gref.GetReference());
+ Line? locationLine = (elem.Location as LocationCurve)?.Curve as Line;
+ Autodesk.Revit.DB.XYZ refDir = locationLine?.GetEndPoint(1) - locationLine?.GetEndPoint(0);
+ refDir = refDir.Normalize();
+ if (refDir.IsAlmostEqualTo(section.PipeCenterLineDirection) || refDir.IsAlmostEqualTo(-section.PipeCenterLineDirection))
+ {
+ continue;
+ }
+ crossDir = refDir.CrossProduct(section.PipeCenterLineDirection);
+ dirs.Add(crossDir.Normalize());
+ break;
+ }
+
+ // When all the obstruction are parallel with the centerline of the pipe,
+ // We can't calculate the direction from the vector.Cross method.
+ if (dirs.Count == 0)
+ {
+ // Calculate perpendicular directions with dir in four directions.
+ List perDirs = PerpendicularDirs(section.PipeCenterLineDirection, 4);
+ dirs.Add(perDirs[0]);
+ dirs.Add(perDirs[1]);
+ }
+
+ Line? foundLine = null;
+ while (null == foundLine)
+ {
+ // Extend the section interval by jumpStep.
+ section.Inflate(0, jumpStep);
+ section.Inflate(1, jumpStep);
+
+ // Find solution in the given directions.
+ for (int i = 0; null == foundLine && i < dirs.Count; i++)
+ {
+ // Calculate the intersections.
+ List obs1 = m_detector.Obstructions(section.Start, dirs[i]);
+ List obs2 = m_detector.Obstructions(section.End, dirs[i]);
+
+ // Filter out the intersection result.
+ Filter(pipe, obs1);
+ Filter(pipe, obs2);
+
+ // Find out the minimal intersections in two opposite direction.
+ ReferenceWithContext[] mins1 = GetClosestSectionsToOrigin(obs1);
+ ReferenceWithContext[] mins2 = GetClosestSectionsToOrigin(obs2);
+
+ // Find solution in the given direction and its opposite direction.
+ for (int j = 0; null == foundLine && j < 2; j++)
+ {
+ if (mins1[j] != null && Math.Abs(mins1[j].Proximity) < minLength ||
+ mins2[j] != null && Math.Abs(mins2[j].Proximity) < minLength)
+ {
+ continue;
+ }
+
+ // Calculate the maximal height that the parallel line can be reached.
+ double maxHight = 1000 * pipe.Diameter;
+ if (mins1[j] != null && mins2[j] != null)
+ {
+ maxHight = Math.Min(Math.Abs(mins1[j].Proximity), Math.Abs(mins2[j].Proximity));
+ }
+ else if (mins1[j] != null)
+ {
+ maxHight = Math.Abs(mins1[j].Proximity);
+ }
+ else if (mins2[j] != null)
+ {
+ maxHight = Math.Abs(mins2[j].Proximity);
+ }
+
+ Autodesk.Revit.DB.XYZ dir = (j == 1) ? dirs[i] : -dirs[i];
+
+ // Calculate the parallel line which can avoid obstructions.
+ foundLine = FindParallelLine(pipe, section, dir, maxHight);
+ }
+ }
+ }
+ return foundLine;
+ }
+
+ ///
+ /// Find a line Parallel to pipe's centerline to avoid the obstruction.
+ ///
+ /// Pipe who has obstructions
+ /// Pipe's one obstruction
+ /// Offset Direction of the parallel line
+ /// Maximum offset distance
+ /// Parallel line which can avoid the obstruction
+ private Line? FindParallelLine(Pipe pipe, Section section, Autodesk.Revit.DB.XYZ dir, double maxLength)
+ {
+ double step = pipe.Diameter;
+ double hight = 2 * pipe.Diameter;
+ while (hight <= maxLength)
+ {
+ Autodesk.Revit.DB.XYZ detal = dir * hight;
+ Line line = Line.CreateBound(section.Start + detal, section.End + detal);
+ List refs = m_detector.Obstructions(line);
+ Filter(pipe, refs);
+
+ if (refs.Count == 0)
+ {
+ return line;
+ }
+ hight += step;
+ }
+ return null;
+ }
+
+ ///
+ /// Find out two References, whose ProximityParameter is negative or positive,
+ /// And Get the minimal value from all positive reference, and get the maximal value
+ /// from the negative reference. if there are no such reference, using null instead.
+ ///
+ /// References
+ /// Reference array
+ private ReferenceWithContext[] GetClosestSectionsToOrigin(List refs)
+ {
+ ReferenceWithContext[] mins = new ReferenceWithContext[2];
+ if (refs.Count == 0)
+ {
+ return mins;
+ }
+
+ if (refs[0].Proximity > 0)
+ {
+ mins[1] = refs[0];
+ return mins;
+ }
+
+ for (int i = 0; i < refs.Count - 1; i++)
+ {
+ if (refs[i].Proximity < 0 && refs[i + 1].Proximity > 0)
+ {
+ mins[0] = refs[i];
+ mins[1] = refs[i + 1];
+ return mins;
+ }
+ }
+
+ mins[0] = refs[refs.Count - 1];
+
+ return mins;
+ }
+
+
+ ///
+ /// Resolve one obstruction of Pipe.
+ ///
+ /// Pipe to resolve
+ /// One pipe's obstruction
+ private void Resolve(Pipe pipe, Section section)
+ {
+ if (m_rvtDoc == null)
+ return;
+ // Find out a parallel line of pipe centerline, which can avoid the obstruction.
+ Line offset = FindRoute(pipe, section);
+
+ // Construct a section line according to the given section.
+ Line sectionLine = Line.CreateBound(section.Start, section.End);
+
+ // Construct two side lines, which can avoid the obstruction too.
+ Line side1 = Line.CreateBound(sectionLine.GetEndPoint(0), offset.GetEndPoint(0));
+ Line side2 = Line.CreateBound(offset.GetEndPoint(1), sectionLine.GetEndPoint(1));
+
+ //
+ // Create an "U" shape, which connected with three pipes and two elbows, to round the obstruction.
+ //
+ PipeType pipeType = pipe.PipeType;
+ Autodesk.Revit.DB.XYZ start = side1.GetEndPoint(0);
+ Autodesk.Revit.DB.XYZ startOffset = offset.GetEndPoint(0);
+ Autodesk.Revit.DB.XYZ endOffset = offset.GetEndPoint(1);
+ Autodesk.Revit.DB.XYZ end = side2.GetEndPoint(1);
+
+ var parameter = pipe.get_Parameter(BuiltInParameter.RBS_START_LEVEL_PARAM);
+ var levelId = parameter.AsElementId();
+ // Create three side pipes of "U" shape.
+ var systemTypeId = m_pipingSystemType?.Id;
+ Pipe pipe1 = Pipe.Create(m_rvtDoc, systemTypeId, pipeType.Id, levelId, start, startOffset);
+ Pipe pipe2 = Pipe.Create(m_rvtDoc, systemTypeId, pipeType.Id, levelId, startOffset, endOffset);
+ Pipe pipe3 = Pipe.Create(m_rvtDoc, systemTypeId, pipeType.Id, levelId, endOffset, end);
+
+ // Copy parameters from pipe to other three created pipes.
+ CopyParameters(pipe, pipe1);
+ CopyParameters(pipe, pipe2);
+ CopyParameters(pipe, pipe3);
+
+ // Add the created three pipes to current section.
+ section.Pipes.Add(pipe1);
+ section.Pipes.Add(pipe2);
+ section.Pipes.Add(pipe3);
+
+ // Create the first elbow to connect two neighbor pipes of "U" shape.
+ Connector? conn1 = FindConnector(pipe1, startOffset);
+ Connector? conn2 = FindConnector(pipe2, startOffset);
+ m_rvtDoc.Create.NewElbowFitting(conn1, conn2);
+
+ // Create the second elbow to connect another two neighbor pipes of "U" shape.
+ Connector? conn3 = FindConnector(pipe2, endOffset);
+ Connector? conn4 = FindConnector(pipe3, endOffset);
+ m_rvtDoc.Create.NewElbowFitting(conn3, conn4);
+ }
+
+ ///
+ /// Copy parameters from source pipe to target pipe.
+ ///
+ /// Coping source
+ /// Coping target
+ private void CopyParameters(Pipe source, Pipe target)
+ {
+ double diameter = source.get_Parameter(BuiltInParameter.RBS_PIPE_DIAMETER_PARAM).AsDouble();
+ target.get_Parameter(BuiltInParameter.RBS_PIPE_DIAMETER_PARAM).Set(diameter);
+ }
+
+ ///
+ /// Find out a connector from pipe with a specified point.
+ ///
+ /// Pipe to find the connector
+ /// Specified point
+ /// Connector whose origin is conXYZ
+ private Connector? FindConnector(Pipe pipe, Autodesk.Revit.DB.XYZ conXYZ)
+ {
+ ConnectorSet conns = pipe.ConnectorManager.Connectors;
+ foreach (Connector conn in conns)
+ {
+ if (conn.Origin.IsAlmostEqualTo(conXYZ))
+ {
+ return conn;
+ }
+ }
+ return null;
+ }
+
+ ///
+ /// Find out the connector which the pipe's specified connector connected to.
+ /// The pipe's specified connector is given by point conxyz.
+ ///
+ /// Pipe to find the connector
+ /// Specified point
+ /// Connector whose origin is conXYZ
+ private Connector? FindConnectedTo(Pipe pipe, Autodesk.Revit.DB.XYZ conXYZ)
+ {
+ Connector? connItself = FindConnector(pipe, conXYZ);
+ ConnectorSet? connSet = connItself?.AllRefs;
+ if (connSet == null)
+ return null;
+ foreach (Connector conn in connSet)
+ {
+ if (conn.Owner.Id.Value != pipe.Id.Value &&
+ conn.ConnectorType == ConnectorType.End)
+ {
+ return conn;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/Section.cs b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/Section.cs
new file mode 100644
index 00000000..e180de55
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/Section.cs
@@ -0,0 +1,198 @@
+//
+// (C) Copyright 2003-2008 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Autodesk.Revit;
+using Autodesk.Revit.DB;
+using Autodesk.Revit.DB.Mechanical;
+using Autodesk.Revit.DB.Plumbing;
+
+namespace CS_AvoidObstruction
+{
+ ///
+ /// This class presents an obstruction of a Pipe.
+ ///
+ class Section
+ {
+ ///
+ /// Pipe centerline's direction.
+ ///
+ private XYZ m_dir;
+
+ ///
+ /// Extend factor in negative direction.
+ ///
+ private double m_startFactor;
+
+ ///
+ /// Extend factor in positive direction.
+ ///
+ private double m_endFactor;
+
+ ///
+ /// ReferenceWithContexts contained in this obstruction.
+ ///
+ private List m_refs;
+
+ ///
+ /// Pipes to avoid this obstruction, it is assigned when resolving this obstruction.
+ /// Its count will be three if resolved, the three pipe constructs a "U" shape to round the obstruction.
+ ///
+ private List m_pipes;
+
+ ///
+ /// Private constructor, just be called in static factory method BuildSections.
+ ///
+ /// Pipe's direction
+ private Section(XYZ dir)
+ {
+ m_dir = dir;
+ m_startFactor = 0;
+ m_endFactor = 0;
+ m_refs = new List();
+ m_pipes = new List();
+ }
+
+ ///
+ /// Pipe centerline's direction.
+ ///
+ public XYZ PipeCenterLineDirection
+ {
+ get { return m_dir; }
+ }
+
+ ///
+ /// Pipes to avoid this obstruction, it is assigned when resolving this obstruction.
+ /// Its count will be three if resolved, the three pipe constructs a "U" shape to round the obstruction.
+ ///
+ public List Pipes
+ {
+ get { return m_pipes; }
+ }
+
+ ///
+ /// Start point of this obstruction.
+ ///
+ public XYZ Start
+ {
+ get
+ {
+ return m_refs[0].GetReference().GlobalPoint.Add(m_dir.Multiply(m_startFactor));
+ }
+ }
+
+ ///
+ /// End point of this obstruction.
+ ///
+ public XYZ End
+ {
+ get
+ {
+ return m_refs[m_refs.Count - 1].GetReference().GlobalPoint.Add(m_dir.Multiply(m_endFactor));
+ }
+ }
+
+ ///
+ /// ReferenceWithContexts contained in this obstruction.
+ ///
+ public List Refs
+ {
+ get { return m_refs; }
+ }
+
+ ///
+ /// Extend this obstruction's interval in one direction.
+ ///
+ /// index of direction, 0 => start, 1 => end
+ public void Inflate(int index, double value)
+ {
+ if (index == 0)
+ {
+ m_startFactor -= value;
+ }
+ else if (index == 1)
+ {
+ m_endFactor += value;
+ }
+ else
+ {
+ throw new ArgumentOutOfRangeException("Index should be 0 or 1.");
+ }
+ }
+
+ ///
+ /// Build sections for ReferenceWithContexts, it's a factory method to build sections.
+ /// A section contains several points through which the ray passes the obstruction(s).
+ /// for example, a section may contain 2 points when the obstruction is stand alone,
+ /// or contain 4 points if 2 obstructions are intersects with each other in the direction of the ray.
+ ///
+ /// ReferenceWithContexts
+ /// Pipe's direction
+ /// List of Section
+ public static List BuildSections(List allrefs, XYZ dir)
+ {
+ List buildStack = new List();
+ List sections = new List();
+ Section? current = null;
+ foreach (ReferenceWithContext geoRef in allrefs)
+ {
+ if (buildStack.Count == 0)
+ {
+ current = new Section(dir);
+ sections.Add(current);
+ }
+
+ current?.Refs.Add(geoRef);
+
+ ReferenceWithContext? tmp = Find(buildStack, geoRef);
+ if (tmp != null)
+ {
+ buildStack.Remove(tmp);
+ }
+ else
+ buildStack.Add(geoRef);
+ }
+
+ return sections;
+ }
+
+ ///
+ /// Judge whether a ReferenceWithContext is already in the list of ReferenceWithContext, return the founded value.
+ ///
+ /// List of ReferenceWithContext
+ /// Reference to test
+ /// One ReferenceWithContext has the same element's Id with entry
+ private static ReferenceWithContext? Find(List arr, ReferenceWithContext entry)
+ {
+ foreach (ReferenceWithContext tmp in arr)
+ {
+ if (tmp.GetReference().ElementId.Value == entry.GetReference().ElementId.Value)
+ {
+ return tmp;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/ThisApplication.Designer.cs b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/ThisApplication.Designer.cs
new file mode 100644
index 00000000..ef52fb0b
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/ThisApplication.Designer.cs
@@ -0,0 +1,54 @@
+namespace MacroSamples_MEP
+{
+
+ public sealed partial class ThisApplication : Autodesk.Revit.UI.Macros.ApplicationEntryPoint
+ {
+
+ public event System.EventHandler Startup;
+
+ public event System.EventHandler Shutdown;
+
+ ///
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ private void OnStartup()
+ {
+ }
+
+ ///
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ protected override void FinishInitialization()
+ {
+ base.FinishInitialization();
+ this.OnStartup();
+ this.InternalStartup();
+ if ((this.Startup != null))
+ {
+ this.Startup(this, System.EventArgs.Empty);
+ }
+ }
+
+ ///
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ protected override void OnShutdown()
+ {
+ if ((this.Shutdown != null))
+ {
+ this.Shutdown(this, System.EventArgs.Empty);
+ }
+ base.OnShutdown();
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ protected override string PrimaryCookie
+ {
+ get
+ {
+ return "ThisApplication";
+ }
+ }
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/ThisApplication.cs b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/ThisApplication.cs
new file mode 100644
index 00000000..d7ce9bca
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_MEP/Source/MacroSamples_MEP/ThisApplication.cs
@@ -0,0 +1,48 @@
+using System;
+using Autodesk.Revit.UI;
+using Autodesk.Revit.DB;
+using Autodesk.Revit.UI.Selection;
+using System.Collections.Generic;
+using System.Linq;
+using Autodesk.Revit.DB.Mechanical;
+using Autodesk.Revit.DB.Plumbing;
+using CS_AvoidObstruction;
+
+namespace MacroSamples_MEP
+{
+ [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
+ [Autodesk.Revit.DB.Macros.AddInId("44E3EC19-A71D-402D-8FC0-054D32E35D85")]
+ public partial class ThisApplication
+ {
+ private void Module_Startup(object? sender, EventArgs e)
+ {
+
+ }
+
+ private void Module_Shutdown(object? sender, EventArgs e)
+ {
+
+ }
+
+ #region Revit Macros generated code
+ private void InternalStartup()
+ {
+ this.Startup += new System.EventHandler(Module_Startup);
+ this.Shutdown += new System.EventHandler(Module_Shutdown);
+ }
+ #endregion
+
+ public void AvoidObstruction()
+ {
+ using (Transaction trans = new Transaction(this.ActiveUIDocument.Document, "AvoidObstruction"))
+ {
+ trans.Start();
+
+ Resolver resolver = new Resolver(this.ActiveUIDocument.Document);
+ resolver.Resolve();
+
+ trans.Commit();
+ }
+ }
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Addin/MacroSamples_RFA.dat b/SDK/Macro Samples/MacroSamples_RFA/Addin/MacroSamples_RFA.dat
new file mode 100644
index 00000000..653cf499
Binary files /dev/null and b/SDK/Macro Samples/MacroSamples_RFA/Addin/MacroSamples_RFA.dat differ
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Addin/MacroSamples_RFA.dll b/SDK/Macro Samples/MacroSamples_RFA/Addin/MacroSamples_RFA.dll
new file mode 100644
index 00000000..64e3090b
Binary files /dev/null and b/SDK/Macro Samples/MacroSamples_RFA/Addin/MacroSamples_RFA.dll differ
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/.vscode/extensions.json b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/.vscode/extensions.json
new file mode 100644
index 00000000..61ae8a27
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/.vscode/extensions.json
@@ -0,0 +1,5 @@
+{
+ "recommendations": [
+ "ms-dotnettools.csharp",
+ ]
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/.vscode/launch.json b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/.vscode/launch.json
new file mode 100644
index 00000000..a19a9b99
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/.vscode/launch.json
@@ -0,0 +1,15 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Attach to Revit",
+ "type": "coreclr",
+ "request": "attach",
+ "processName": "revit.exe",
+ "justMyCode": true
+ }
+ ]
+}
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/.vscode/tasks.json b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/.vscode/tasks.json
new file mode 100644
index 00000000..ca683426
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/.vscode/tasks.json
@@ -0,0 +1,14 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ ]
+}
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/AutoParameter/FamilyParameterAssigner.cs b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/AutoParameter/FamilyParameterAssigner.cs
new file mode 100644
index 00000000..895f0722
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/AutoParameter/FamilyParameterAssigner.cs
@@ -0,0 +1,494 @@
+//
+// (C) Copyright 2003-2008 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+using System.Text.RegularExpressions;
+using System.Reflection;
+
+using Autodesk.Revit;
+using Autodesk.Revit.DB;
+
+using MacroSamples_RFA;
+
+namespace Revit.SDK.Samples.AutoParameter.CS
+{
+ ///
+ /// add parameters(family parameters/shared parameters) to the opened family file
+ /// the parameters are recorded in txt file following certain formats
+ ///
+ class FamilyParameterAssigner
+ {
+ #region Memeber Fields
+ private Autodesk.Revit.ApplicationServices.Application m_app;
+ private ThisApplication? m_thisapp;
+ private FamilyManager? m_manager = null;
+ string addInPath = String.Empty;
+ // indicate whether the parameter files have been loaded. If yes, no need to load again.
+ bool m_paramLoaded;
+
+ // set the paramName as key of dictionary for exclusiveness (the names of parameters should be unique)
+ private Dictionary m_familyParams;
+ private DefinitionFile? m_sharedFile;
+ private string m_familyFilePath = string.Empty;
+ private string m_sharedFilePath = string.Empty;
+ #endregion
+
+ ///
+ /// constructor
+ ///
+ ///
+ /// the active revit application
+ ///
+ ///
+ /// the family document which will have parameters added in
+ ///
+ public FamilyParameterAssigner(ThisApplication thisApp)
+ {
+ m_thisapp = thisApp;
+ m_app = thisApp.Application;
+ m_manager = thisApp.ActiveUIDocument.Document.FamilyManager;
+ m_familyParams = new Dictionary();
+
+ addInPath = thisApp.AddinFolder;
+
+ m_paramLoaded = false;
+ }
+
+ ///
+ /// load the family parameter file (if exists) and shared parameter file (if exists)
+ /// only need to load once
+ ///
+ ///
+ /// if succeeded, return true; otherwise false
+ ///
+ public bool LoadParametersFromFile()
+ {
+ if (m_paramLoaded)
+ {
+ return true;
+ }
+ // load family parameter file
+ bool famParamFileExist;
+ bool succeeded = LoadFamilyParameterFromFile(out famParamFileExist);
+ if (!succeeded)
+ {
+ return false;
+ }
+
+ // load shared parameter file
+ bool sharedParamFileExist;
+ succeeded = LoadSharedParameterFromFile(out sharedParamFileExist);
+ if (!(famParamFileExist || sharedParamFileExist))
+ {
+ MessageManager.MessageBuff.AppendLine("Neither familyParameter.txt nor sharedParameter.txt exists in the assembly folder.");
+ return false;
+ }
+ if (!succeeded)
+ {
+ return false;
+ }
+ m_paramLoaded = true;
+ return true;
+ }
+
+ ///
+ /// load family parameters from the text file
+ ///
+ ///
+ /// return true if succeeded; otherwise false
+ ///
+ private bool LoadFamilyParameterFromFile(out bool exist)
+ {
+ exist = true;
+ if (m_thisapp == null)
+ return false;
+ // step 1: find the file "FamilyParameter.txt" and open it
+ string fileName = Directory.GetParent(m_thisapp.ActiveUIDocument.Document.PathName) + "\\FamilyParameter.txt";
+ if (!File.Exists(fileName))
+ {
+ exist = false;
+ return true;
+ }
+
+ FileStream? file = null;
+ StreamReader? reader = null;
+ try
+ {
+ file = new FileStream(fileName, FileMode.Open, FileAccess.Read);
+ reader = new StreamReader(file);
+
+ // step 2: read each line, if the line records the family parameter data, store it
+ // record the content of the current line
+ string? line;
+ // record the row number of the current line
+ int lineNumber = 0;
+ while (null != (line = reader.ReadLine()))
+ {
+ ++lineNumber;
+ // step 2.1: verify the line
+ // check whether the line is blank line (contains only whitespaces)
+ Match match = Regex.Match(line, @"^\s*$");
+ if (true == match.Success)
+ {
+ continue;
+ }
+
+ // check whether the line starts from "#" or "*" (comment line)
+ match = Regex.Match(line, @"\s*['#''*'].*");
+ if (true == match.Success)
+ {
+ continue;
+ }
+
+ // step 2.2: get the parameter data
+ // it's a valid line (has the format of "paramName paramGroup paramType isInstance", separate by tab or by spaces)
+ // split the line to an array containing parameter items (format of string[] {"paramName", "paramGroup", "paramType", "isInstance"})
+ string[] lineData = Regex.Split(line, @"\s+");
+ // check whether the array has blank items (containing only spaces)
+ List values = new List();
+ foreach (string data in lineData)
+ {
+ match = Regex.Match(data, @"^\s*$");
+ if (true == match.Success)
+ {
+ continue;
+ }
+
+ values.Add(data);
+ }
+
+ // verify the parameter items (should have 4 items exactly: paramName, paramGroup, paramType and isInstance)
+ if (4 != values.Count)
+ {
+ MessageManager.MessageBuff.Append("Loading family parameter data from \"FamilyParam.txt\".");
+ MessageManager.MessageBuff.Append("Line [\"" + line + "]\"" + "doesn't follow the valid format.\n");
+ return false;
+ }
+
+ // get the paramName
+ string paramName = values[0];
+ // get the paramGroup
+ ForgeTypeId paramGroup = new ForgeTypeId(values[1]);
+
+ // get the paramType
+ ForgeTypeId paramType = new ForgeTypeId(values[2]);
+ // get data "isInstance"
+ string isInstanceString = values[3];
+ bool isInstance = Convert.ToBoolean(isInstanceString);
+
+ // step 2.3: store the parameter fetched, check for exclusiveness (as the names of parameters should keep unique)
+ FamilyParam param = new FamilyParam(paramName, paramGroup, paramType, isInstance, lineNumber);
+ // the family parameter with the same name has already been stored to the dictionary, raise an error
+ if (m_familyParams.ContainsKey(paramName))
+ {
+ FamilyParam duplicatedParam = m_familyParams[paramName];
+ string warning = "Line " + param.Line + "has a duplicate parameter name with Line " + duplicatedParam.Line + "\n";
+ MessageManager.MessageBuff.Append(warning);
+ continue;
+ }
+ m_familyParams.Add(paramName, param);
+ }
+ }
+ catch (System.Exception e)
+ {
+ MessageManager.MessageBuff.AppendLine(e.Message);
+ return false;
+ }
+ finally
+ {
+ if (null != reader)
+ {
+ reader.Close();
+ }
+ if (null != file)
+ {
+ file.Close();
+ }
+ }
+
+ return true;
+ }
+
+ ///
+ /// load family parameters from the text file
+ ///
+ ///
+ /// indicate whether the shared parameter file exists
+ ///
+ ///
+ /// return true if succeeded; otherwise false
+ ///
+ private bool LoadSharedParameterFromFile(out bool exist)
+ {
+ exist = true;
+ string filePath = addInPath + "\\SharedParameter.txt";
+ if (!File.Exists(filePath))
+ {
+ exist = false;
+ return true;
+ }
+
+ m_app.SharedParametersFilename = filePath;
+ try
+ {
+ m_sharedFile = m_app.OpenSharedParameterFile();
+ }
+ catch (System.Exception e)
+ {
+ MessageManager.MessageBuff.AppendLine(e.Message);
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// add parameters to the family file
+ ///
+ ///
+ /// if succeeded, return true; otherwise false
+ ///
+ public bool AddParameters()
+ {
+ // add the loaded family parameters to the family
+ bool succeeded = AddFamilyParameter();
+ if (!succeeded)
+ {
+ return false;
+ }
+
+ // add the loaded shared parameters to the family
+ succeeded = AddSharedParameter();
+ if (!succeeded)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// add family parameter to the family
+ ///
+ ///
+ /// if succeeded, return true; otherwise false
+ ///
+ private bool AddFamilyParameter()
+ {
+ if (m_manager == null)
+ return false;
+ bool allParamValid = true;
+ if (File.Exists(m_familyFilePath) &&
+ 0 == m_familyParams.Count)
+ {
+ MessageManager.MessageBuff.AppendLine("No family parameter available for adding.");
+ return false;
+ }
+
+ foreach (FamilyParameter param in m_manager.Parameters)
+ {
+ string name = param.Definition.Name;
+ if (m_familyParams.ContainsKey(name))
+ {
+ allParamValid = false;
+ FamilyParam famParam = m_familyParams[name];
+ MessageManager.MessageBuff.Append("Line " + famParam.Line + ": paramName \"" + famParam.Name + "\"already exists in the family document.\n");
+ }
+ }
+
+ // there're errors in the family parameter text file
+ if (!allParamValid)
+ {
+ return false;
+ }
+
+ foreach (FamilyParam param in m_familyParams.Values)
+ {
+ try
+ {
+ m_manager.AddParameter(param.Name, param.Group, param.Type, param.IsInstance);
+ }
+ catch (Exception e)
+ {
+ MessageManager.MessageBuff.AppendLine(e.Message);
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ ///
+ /// load shared parameters from shared parameter file and add them to family
+ ///
+ ///
+ /// if succeeded, return true; otherwise false
+ ///
+ private bool AddSharedParameter()
+ {
+ if (m_sharedFile == null)
+ return false;
+ if (File.Exists(m_sharedFilePath) &&
+ null == m_sharedFile)
+ {
+ MessageManager.MessageBuff.AppendLine("SharedParameter.txt has an invalid format.");
+ return false;
+ }
+
+ foreach (DefinitionGroup group in m_sharedFile.Groups)
+ {
+ foreach (ExternalDefinition def in group.Definitions)
+ {
+ // check whether the parameter already exists in the document
+ FamilyParameter? param = m_manager?.get_Parameter(def.Name);
+ if (null != param)
+ {
+ continue;
+ }
+
+ try
+ {
+ m_manager?.AddParameter(def, def.GetGroupTypeId(), true);
+ }
+ catch (System.Exception e)
+ {
+ MessageManager.MessageBuff.AppendLine(e.Message);
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ }// end of class "FamilyParameterAssigner"
+
+ ///
+ /// record the data of a parameter: its name, its group, etc
+ ///
+ class FamilyParam
+ {
+ string m_name = string.Empty;
+ ///
+ /// the caption of the parameter
+ ///
+ public string Name
+ {
+ get { return m_name; }
+ }
+
+ ForgeTypeId? m_group;
+ ///
+ /// the group of the parameter
+ ///
+ public ForgeTypeId? Group
+ {
+ get { return m_group; }
+ }
+
+ ForgeTypeId? m_type;
+ ///
+ /// the type of the parameter
+ ///
+ public ForgeTypeId? Type
+ {
+ get { return m_type; }
+ }
+
+ bool m_isInstance;
+ ///
+ /// indicate whether the parameter is an instance parameter or a type parameter
+ ///
+ public bool IsInstance
+ {
+ get { return m_isInstance; }
+ }
+
+ int m_line;
+ ///
+ /// record the location of this parameter in the family parameter file
+ ///
+ public int Line
+ {
+ get { return m_line; }
+ }
+
+ ///
+ /// default constructor, hide this by making it "private"
+ ///
+ private FamilyParam()
+ {
+ }
+
+ ///
+ /// constructor which exposes for invoking
+ ///
+ ///
+ /// parameter name
+ ///
+ ///
+ /// indicate which group the parameter belongs to
+ ///
+ ///
+ /// the type of the parameter
+ ///
+ ///
+ /// indicate whethe the parameter is an instance parameter
+ ///
+ ///
+ /// record the location of this parameter in the family parameter file
+ ///
+ public FamilyParam(string name, ForgeTypeId group, ForgeTypeId type, bool isInstance, int line)
+ {
+ m_name = name;
+ m_group = group;
+ m_type = type;
+ m_isInstance = isInstance;
+ m_line = line;
+ }
+ }
+
+ ///
+ /// store the warning/error messeges when executing the sample
+ ///
+ static class MessageManager
+ {
+ static StringBuilder m_messageBuff = new StringBuilder();
+ ///
+ /// store the warning/error messages
+ ///
+ public static StringBuilder MessageBuff
+ {
+ get
+ {
+ return m_messageBuff;
+ }
+ set
+ {
+ m_messageBuff = value;
+ }
+ }
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/GenericModelCreation/GenericModelCreation.cs b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/GenericModelCreation/GenericModelCreation.cs
new file mode 100644
index 00000000..e4036b59
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/GenericModelCreation/GenericModelCreation.cs
@@ -0,0 +1,430 @@
+//
+// (C) Copyright 2003-2008 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+using System.IO;
+using Autodesk.Revit;
+using Autodesk.Revit.DB;
+
+using MacroSamples_RFA;
+
+namespace Revit.SDK.Samples.GenericModelCreation.CS
+{
+ ///
+ /// This class show how to create Generic Model Family by Revit API.
+ ///
+ public class GenericModelCreation
+ {
+ #region Class Memeber Variables
+ // Application of Revit
+ private Autodesk.Revit.ApplicationServices.Application? m_revit;
+ private ThisApplication? m_thisApp;
+ // the document to create generic model family
+ private Autodesk.Revit.DB.Document? m_familyDocument;
+ // FamilyItemFactory used to create family
+ private Autodesk.Revit.Creation.FamilyItemFactory? m_creationFamily = null;
+ // Count error numbers
+ private int m_errCount = 0;
+ // Error information
+ private string m_errorInfo = "";
+ #endregion
+
+
+ public GenericModelCreation(ThisApplication thisApp)
+ {
+ m_thisApp = thisApp;
+ m_revit = thisApp.ActiveUIDocument.Document.Application;
+ }
+
+ #region Class Interface Implementation
+ ///
+ /// Implement this method as an external command for Revit.
+ ///
+ /// An object that is passed to the external application
+ /// which contains data related to the command,
+ /// such as the application object and active view.
+ /// A message that can be set by the external application
+ /// which will be displayed if a failure or cancellation is returned by
+ /// the external command.
+ /// A set of elements to which the external application
+ /// can add elements that are to be highlighted in case of failure or cancellation.
+ /// Return the status of the external command.
+ /// A result of Succeeded means that the API external method functioned as expected.
+ /// Cancelled can be used to signify that the user cancelled the external operation
+ /// at some point. Failure should be returned if the application is unable to proceed with
+ /// the operation.
+ public void Run()
+ {
+ try
+ {
+ if (m_thisApp == null)
+ return;
+ m_familyDocument = m_thisApp.ActiveUIDocument.Document;
+ if (!m_familyDocument.IsFamilyDocument)
+ {
+ System.Windows.Forms.MessageBox.Show("ActiveDocument is not family document.");
+ return;
+ }
+ m_creationFamily = m_familyDocument.FamilyCreate;
+ // create generic model family in the document
+ CreateGenericModel();
+ if (0 == m_errCount)
+ {
+ return;
+ }
+ else
+ {
+ System.Windows.Forms.MessageBox.Show(m_errorInfo);
+ return;
+ }
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+
+ }
+ #endregion
+
+ #region Class Implementation
+
+ ///
+ /// Examples for form creation in generic model families.
+ /// Create extrusion, sweep, blend, swept blend
+ ///
+ public void CreateGenericModel()
+ {
+ // use transaction if the family document is not active document
+ CreateExtrusion();
+ CreateBlend();
+ CreateRevolution();
+ CreateSweep();
+ CreateSweptBlend();
+ return;
+ }
+
+ ///
+ /// Create one rectangular extrusion
+ ///
+ private void CreateExtrusion()
+ {
+ if (m_revit == null || m_creationFamily == null)
+ return;
+ try
+ {
+ #region Create rectangle profile
+ CurveArrArray curveArrArray = m_revit.Create.NewCurveArrArray();
+ CurveArray curveArray1 = m_revit.Create.NewCurveArray();
+ CurveArray curveArray2 = m_revit.Create.NewCurveArray();
+ CurveArray curveArray3 = m_revit.Create.NewCurveArray();
+
+ XYZ normal = XYZ.BasisZ;
+ SketchPlane sketchPlane = CreateSketchPlane(normal, XYZ.Zero);
+
+ // create one rectangular extrusion
+ XYZ p0 = XYZ.Zero;
+ XYZ p1 = m_revit.Create.NewXYZ(10, 0, 0);
+ XYZ p2 = m_revit.Create.NewXYZ(10, 10, 0);
+ XYZ p3 = m_revit.Create.NewXYZ(0, 10, 0);
+ Line line1 = Line.CreateBound(p0, p1);
+ Line line2 = Line.CreateBound(p1, p2);
+ Line line3 = Line.CreateBound(p2, p3);
+ Line line4 = Line.CreateBound(p3, p0);
+ curveArray1.Append(line1);
+ curveArray1.Append(line2);
+ curveArray1.Append(line3);
+ curveArray1.Append(line4);
+
+ curveArrArray.Append(curveArray1);
+ #endregion
+ // here create rectangular extrusion
+ Extrusion rectExtrusion = m_creationFamily.NewExtrusion(true, curveArrArray, sketchPlane, 10);
+ // move to proper place
+ XYZ transPoint1 = m_revit.Create.NewXYZ(-16, 0, 0);
+ ElementTransformUtils.MoveElement(m_familyDocument, rectExtrusion.Id, transPoint1);
+ }
+ catch (Exception e)
+ {
+ m_errCount++;
+ m_errorInfo += "Unexpected exceptions occur in CreateExtrusion: " + e.ToString() + "\r\n";
+ }
+ }
+
+ ///
+ /// Create one blend
+ ///
+ private void CreateBlend()
+ {
+ try
+ {
+ #region Create top and base profiles
+ if (m_revit == null)
+ return;
+ CurveArray topProfile = m_revit.Create.NewCurveArray();
+ CurveArray baseProfile = m_revit.Create.NewCurveArray();
+
+ XYZ normal = XYZ.BasisZ;
+ SketchPlane sketchPlane = CreateSketchPlane(normal, XYZ.Zero);
+
+ // create one blend
+ XYZ p00 = XYZ.Zero;
+ XYZ p01 = m_revit.Create.NewXYZ(10, 0, 0);
+ XYZ p02 = m_revit.Create.NewXYZ(10, 10, 0);
+ XYZ p03 = m_revit.Create.NewXYZ(0, 10, 0);
+ Line line01 = Line.CreateBound(p00, p01);
+ Line line02 = Line.CreateBound(p01, p02);
+ Line line03 = Line.CreateBound(p02, p03);
+ Line line04 = Line.CreateBound(p03, p00);
+
+ baseProfile.Append(line01);
+ baseProfile.Append(line02);
+ baseProfile.Append(line03);
+ baseProfile.Append(line04);
+
+ XYZ p10 = m_revit.Create.NewXYZ(5, 2, 10);
+ XYZ p11 = m_revit.Create.NewXYZ(8, 5, 10);
+ XYZ p12 = m_revit.Create.NewXYZ(5, 8, 10);
+ XYZ p13 = m_revit.Create.NewXYZ(2, 5, 10);
+ Line line11 = Line.CreateBound(p10, p11);
+ Line line12 = Line.CreateBound(p11, p12);
+ Line line13 = Line.CreateBound(p12, p13);
+ Line line14 = Line.CreateBound(p13, p10);
+
+ topProfile.Append(line11);
+ topProfile.Append(line12);
+ topProfile.Append(line13);
+ topProfile.Append(line14);
+ #endregion
+ // here create rectangular blend
+ if (m_creationFamily == null)
+ return;
+ Blend blend = m_creationFamily.NewBlend(true, topProfile, baseProfile, sketchPlane);
+ // move to proper place
+ XYZ transPoint1 = m_revit.Create.NewXYZ(0, 11, 0);
+ ElementTransformUtils.MoveElement(m_familyDocument, blend.Id, transPoint1);
+ }
+ catch (Exception e)
+ {
+ m_errCount++;
+ m_errorInfo += "Unexpected exceptions occur in CreateBlend: " + e.ToString() + "\r\n";
+ }
+ }
+
+ ///
+ /// Create one rectangular profile revolution
+ ///
+ private void CreateRevolution()
+ {
+ try
+ {
+ #region Create rectangular profile
+ if (m_revit == null)
+ return;
+ CurveArrArray curveArrArray = m_revit.Create.NewCurveArrArray();
+ CurveArray curveArray = m_revit.Create.NewCurveArray();
+
+ XYZ normal = XYZ.BasisZ;
+ SketchPlane sketchPlane = CreateSketchPlane(normal, XYZ.Zero);
+
+ // create one rectangular profile revolution
+ XYZ p0 = XYZ.Zero;
+ XYZ p1 = m_revit.Create.NewXYZ(10, 0, 0);
+ XYZ p2 = m_revit.Create.NewXYZ(10, 10, 0);
+ XYZ p3 = m_revit.Create.NewXYZ(0, 10, 0);
+ Line line1 = Line.CreateBound(p0, p1);
+ Line line2 = Line.CreateBound(p1, p2);
+ Line line3 = Line.CreateBound(p2, p3);
+ Line line4 = Line.CreateBound(p3, p0);
+
+ XYZ pp = m_revit.Create.NewXYZ(1, -1, 0);
+ Line axis1 = Line.CreateBound(XYZ.Zero, pp);
+ curveArray.Append(line1);
+ curveArray.Append(line2);
+ curveArray.Append(line3);
+ curveArray.Append(line4);
+
+ curveArrArray.Append(curveArray);
+ #endregion
+ // here create rectangular revolution
+ if (m_creationFamily == null)
+ return;
+ Revolution revolution1 = m_creationFamily.NewRevolution(true, curveArrArray, sketchPlane, axis1, -Math.PI, 0);
+ // move to proper place
+ XYZ transPoint1 = m_revit.Create.NewXYZ(0, 32, 0);
+ ElementTransformUtils.MoveElement(m_familyDocument, revolution1.Id, transPoint1);
+ }
+ catch (Exception e)
+ {
+ m_errCount++;
+ m_errorInfo += "Unexpected exceptions occur in CreateRevolution: " + e.ToString() + "\r\n";
+ }
+ }
+
+ ///
+ /// Create one sweep
+ ///
+ private void CreateSweep()
+ {
+ try
+ {
+ if (m_revit == null)
+ return;
+ #region Create rectangular profile and path curve
+ CurveArrArray arrarr = m_revit.Create.NewCurveArrArray();
+ CurveArray arr = m_revit.Create.NewCurveArray();
+
+ XYZ normal = XYZ.BasisZ;
+ SketchPlane sketchPlane = CreateSketchPlane(normal, XYZ.Zero);
+
+ XYZ pnt1 = m_revit.Create.NewXYZ(0, 0, 0);
+ XYZ pnt2 = m_revit.Create.NewXYZ(2, 0, 0);
+ XYZ pnt3 = m_revit.Create.NewXYZ(1, 1, 0);
+ arr.Append(Arc.Create(pnt2, 1.0d, 0.0d, 3.14d, XYZ.BasisX, XYZ.BasisY));
+ arr.Append(Arc.Create(pnt1, pnt3, pnt2));
+ arrarr.Append(arr);
+ SweepProfile profile = m_revit.Create.NewCurveLoopsProfile(arrarr);
+
+ XYZ pnt4 = m_revit.Create.NewXYZ(10, 0, 0);
+ XYZ pnt5 = m_revit.Create.NewXYZ(0, 10, 0);
+ Curve curve = Line.CreateBound(pnt4, pnt5);
+
+ CurveArray curves = m_revit.Create.NewCurveArray();
+ curves.Append(curve);
+ #endregion
+ // here create rectangular sweep
+ if (m_creationFamily == null)
+ return;
+ Sweep sweep1 = m_creationFamily.NewSweep(true, curves, sketchPlane, profile, 0, ProfilePlaneLocation.Start);
+ // move to proper place
+ XYZ transPoint1 = m_revit.Create.NewXYZ(11, 0, 0);
+ ElementTransformUtils.MoveElement(m_familyDocument, sweep1.Id, transPoint1);
+ }
+ catch (Exception e)
+ {
+ m_errCount++;
+ m_errorInfo += "Unexpected exceptions occur in CreateSweep: " + e.ToString() + "\r\n";
+ }
+ }
+
+ ///
+ /// Create one SweptBlend
+ ///
+ private void CreateSweptBlend()
+ {
+ try
+ {
+ if (m_revit == null)
+ return;
+ #region Create top and bottom profiles and path curve
+ XYZ pnt1 = m_revit.Create.NewXYZ(0, 0, 0);
+ XYZ pnt2 = m_revit.Create.NewXYZ(1, 0, 0);
+ XYZ pnt3 = m_revit.Create.NewXYZ(1, 1, 0);
+ XYZ pnt4 = m_revit.Create.NewXYZ(0, 1, 0);
+ XYZ pnt5 = m_revit.Create.NewXYZ(0, 0, 1);
+
+ CurveArrArray arrarr1 = m_revit.Create.NewCurveArrArray();
+ CurveArray arr1 = m_revit.Create.NewCurveArray();
+ arr1.Append(Line.CreateBound(pnt1, pnt2));
+ arr1.Append(Line.CreateBound(pnt2, pnt3));
+ arr1.Append(Line.CreateBound(pnt3, pnt4));
+ arr1.Append(Line.CreateBound(pnt4, pnt1));
+ arrarr1.Append(arr1);
+
+ XYZ pnt6 = m_revit.Create.NewXYZ(0.5, 0, 0);
+ XYZ pnt7 = m_revit.Create.NewXYZ(1, 0.5, 0);
+ XYZ pnt8 = m_revit.Create.NewXYZ(0.5, 1, 0);
+ XYZ pnt9 = m_revit.Create.NewXYZ(0, 0.5, 0);
+ CurveArrArray arrarr2 = m_revit.Create.NewCurveArrArray();
+ CurveArray arr2 = m_revit.Create.NewCurveArray();
+ arr2.Append(Line.CreateBound(pnt6, pnt7));
+ arr2.Append(Line.CreateBound(pnt7, pnt8));
+ arr2.Append(Line.CreateBound(pnt8, pnt9));
+ arr2.Append(Line.CreateBound(pnt9, pnt6));
+ arrarr2.Append(arr2);
+
+ SweepProfile bottomProfile = m_revit.Create.NewCurveLoopsProfile(arrarr1);
+ SweepProfile topProfile = m_revit.Create.NewCurveLoopsProfile(arrarr2);
+
+ XYZ pnt10 = m_revit.Create.NewXYZ(5, 0, 0);
+ XYZ pnt11 = m_revit.Create.NewXYZ(0, 20, 0);
+ Curve curve = Line.CreateBound(pnt10, pnt11);
+
+ XYZ normal = XYZ.BasisZ;
+ SketchPlane sketchPlane = CreateSketchPlane(normal, XYZ.Zero);
+ #endregion
+ // here create rectangular sweep blend
+ if (m_creationFamily == null)
+ return;
+ SweptBlend newSweptBlend1 = m_creationFamily.NewSweptBlend(true, curve, sketchPlane, bottomProfile, topProfile);
+ // move to proper place
+ XYZ transPoint1 = m_revit.Create.NewXYZ(11, 32, 0);
+ ElementTransformUtils.MoveElement(m_familyDocument, newSweptBlend1.Id, transPoint1);
+ }
+ catch (Exception e)
+ {
+ m_errCount++;
+ m_errorInfo += "Unexpected exceptions occur in CreateSweptBlend: " + e.ToString() + "\r\n";
+ }
+ }
+
+
+ ///
+ /// Get element by its id
+ ///
+ private T? GetElement(Int64 eid) where T : Autodesk.Revit.DB.Element
+ {
+ ElementId elementId = new ElementId(eid);
+ return m_familyDocument?.GetElement(elementId) as T;
+ }
+
+ ///
+ /// Create sketch plane for generic model profile
+ ///
+ /// plane normal
+ /// origin point
+ ///
+ internal SketchPlane CreateSketchPlane(XYZ normal, XYZ origin)
+ {
+ // First create a Geometry.Plane which need in NewSketchPlane() method
+ Plane geometryPlane = Plane.CreateByNormalAndOrigin(normal, origin);
+ if (null == geometryPlane) // assert the creation is successful
+ {
+ throw new Exception("Create the geometry plane failed.");
+ }
+ // Then create a sketch plane using the Geometry.Plane
+ SketchPlane plane = SketchPlane.Create(m_familyDocument, geometryPlane);
+ // throw exception if creation failed
+ if (null == plane)
+ {
+ throw new Exception("Create the sketch plane failed.");
+ }
+ return plane;
+ }
+
+ #endregion
+
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/MacroSamples_RFA.csproj b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/MacroSamples_RFA.csproj
new file mode 100644
index 00000000..ed18e367
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/MacroSamples_RFA.csproj
@@ -0,0 +1,39 @@
+
+
+ net8.0-windows
+ enable
+ enable
+ true
+
+
+ x64
+ false
+ false
+ False
+ True
+ Portable
+ ..\..\Addin\
+ MacroSamples_RFA
+ obj\
+ DEBUG;TRACE
+ obj\Debug
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+
+
+
+ False
+
+
+ False
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/Properties/AssemblyInfo.cs b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..7f4a7cce
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/Properties/AssemblyInfo.cs
@@ -0,0 +1,31 @@
+#region Using directives
+
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+#endregion
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("NewModule")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("NewModule")]
+[assembly: AssemblyCopyright("Copyright 2023")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all the values or you can use the default the Revision and
+// Build Numbers by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.*")]
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ThisApplication.Designer.cs b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ThisApplication.Designer.cs
new file mode 100644
index 00000000..023bad04
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ThisApplication.Designer.cs
@@ -0,0 +1,54 @@
+namespace MacroSamples_RFA
+{
+
+ public sealed partial class ThisApplication : Autodesk.Revit.UI.Macros.ApplicationEntryPoint
+ {
+
+ public event System.EventHandler Startup;
+
+ public event System.EventHandler Shutdown;
+
+ ///
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ private void OnStartup()
+ {
+ }
+
+ ///
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ protected override void FinishInitialization()
+ {
+ base.FinishInitialization();
+ this.OnStartup();
+ this.InternalStartup();
+ if ((this.Startup != null))
+ {
+ this.Startup(this, System.EventArgs.Empty);
+ }
+ }
+
+ ///
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ protected override void OnShutdown()
+ {
+ if ((this.Shutdown != null))
+ {
+ this.Shutdown(this, System.EventArgs.Empty);
+ }
+ base.OnShutdown();
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
+ protected override string PrimaryCookie
+ {
+ get
+ {
+ return "ThisApplication";
+ }
+ }
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ThisApplication.cs b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ThisApplication.cs
new file mode 100644
index 00000000..9582aa0f
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ThisApplication.cs
@@ -0,0 +1,165 @@
+using System;
+using Autodesk.Revit.UI;
+using Autodesk.Revit.DB;
+using Autodesk.Revit.UI.Selection;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+
+using Revit.SDK.Samples.AutoParameter.CS;
+using Revit.SDK.Samples.GenericModelCreation.CS;
+using Revit.SDK.Samples.TypeRegeneration.CS;
+using Revit.SDK.Samples.ValidateParameters.CS;
+
+namespace MacroSamples_RFA
+{
+ [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
+ [Autodesk.Revit.DB.Macros.AddInId("B0302F6B-64AC-438F-93CB-61F3C632FD57")]
+ public partial class ThisApplication
+ {
+ private void Module_Startup(object? sender, EventArgs e)
+ {
+
+ }
+
+ private void Module_Shutdown(object? sender, EventArgs e)
+ {
+
+ }
+
+ #region Revit Macros generated code
+ private void InternalStartup()
+ {
+ this.Startup += new System.EventHandler(Module_Startup);
+ this.Shutdown += new System.EventHandler(Module_Shutdown);
+ }
+ #endregion
+ ///
+ /// AutoJoin
+ ///
+ public void AutoJoin()
+ {
+ using (Transaction trans = new Transaction(this.ActiveUIDocument.Document, "AutoJoin"))
+ {
+ trans.Start();
+ CombinableElementArray solids = this.ActiveUIDocument.Document.Application.Create.NewCombinableElementArray();
+ foreach (Autodesk.Revit.DB.ElementId elementId in this.ActiveUIDocument.Selection.GetElementIds())
+ {
+ Element element = this.ActiveUIDocument.Document.GetElement(elementId);
+ System.Diagnostics.Trace.WriteLine(element.GetType().ToString());
+
+ GenericForm? gf = element as GenericForm;
+ if (null != gf && !gf.IsSolid)
+ {
+ continue;
+ }
+
+ CombinableElement? ce = element as CombinableElement;
+ if (null != ce)
+ {
+ solids.Append(ce);
+ }
+ }
+
+ if (solids.Size < 2)
+ {
+ MessageBox.Show("At least 2 combinable elements should be selected.");
+ return;
+ }
+
+ this.ActiveUIDocument.Document.CombineElements(solids);
+ trans.Commit();
+ }
+ }
+
+ ///
+ /// AutoParameter
+ ///
+ public void AutoParameter()
+ {
+ using (Transaction trans = new Transaction(this.ActiveUIDocument.Document, "AutoParameter"))
+ {
+ trans.Start();
+ MessageManager.MessageBuff = new StringBuilder();
+ bool succeeded = AddParameters();
+ if (!succeeded)
+ {
+ MessageBox.Show(MessageManager.MessageBuff.ToString());
+ }
+ trans.Commit();
+ }
+ }
+
+ ///
+ /// add parameters to the active document
+ ///
+ ///
+ /// if succeeded, return true; otherwise false
+ ///
+ private bool AddParameters()
+ {
+ Document doc = this.ActiveUIDocument.Document;
+ if (null == doc)
+ {
+ MessageManager.MessageBuff.Append("There's no available document. \n");
+ return false;
+ }
+
+ if (!doc.IsFamilyDocument)
+ {
+ MessageManager.MessageBuff.Append("The active document is not a family document. \n");
+ return false;
+ }
+
+ FamilyParameterAssigner assigner = new FamilyParameterAssigner(this);
+ // the parameters to be added are defined and recorded in a text file, read them from that file and load to memory
+ bool succeeded = assigner.LoadParametersFromFile();
+ if (!succeeded)
+ {
+ return false;
+ }
+
+ succeeded = assigner.AddParameters();
+ if (succeeded)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// GenericModelCreation
+ ///
+ public void GenericModelCreation()
+ {
+ using (Transaction trans = new Transaction(this.ActiveUIDocument.Document, "GenericModelCreation"))
+ {
+ trans.Start();
+ GenericModelCreation sample = new GenericModelCreation(this);
+ sample.Run();
+ trans.Commit();
+ }
+ }
+
+ ///
+ /// TypeRegeneration
+ ///
+ public void TypeRegeneration()
+ {
+ TypeRegeneration sample = new TypeRegeneration(this);
+ sample.Run();
+ }
+
+ ///
+ /// ValidateParameters
+ ///
+ public void ValidateParameters()
+ {
+ ValidateParameters sample = new ValidateParameters(this);
+ sample.Run();
+ }
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/TypeRegeneration/MessageForm.Designer.cs b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/TypeRegeneration/MessageForm.Designer.cs
new file mode 100644
index 00000000..c6c24ac4
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/TypeRegeneration/MessageForm.Designer.cs
@@ -0,0 +1,90 @@
+//
+// (C) Copyright 2003-2008 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+namespace Revit.SDK.Samples.TypeRegeneration.CS
+{
+ partial class MessageForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.messageRichTextBox = new System.Windows.Forms.RichTextBox();
+ this.SuspendLayout();
+ //
+ // messageRichTextBox
+ //
+ this.messageRichTextBox.BackColor = System.Drawing.SystemColors.Info;
+ this.messageRichTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.messageRichTextBox.EnableAutoDragDrop = true;
+ this.messageRichTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.messageRichTextBox.ForeColor = System.Drawing.SystemColors.InfoText;
+ this.messageRichTextBox.Location = new System.Drawing.Point(0, 0);
+ this.messageRichTextBox.Name = "messageRichTextBox";
+ this.messageRichTextBox.Size = new System.Drawing.Size(313, 186);
+ this.messageRichTextBox.TabIndex = 1;
+ this.messageRichTextBox.Text = "";
+ //
+ // MessageForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(313, 186);
+ this.Controls.Add(this.messageRichTextBox);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "MessageForm";
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "MessageForm";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.RichTextBox messageRichTextBox;
+ }
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/TypeRegeneration/MessageForm.cs b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/TypeRegeneration/MessageForm.cs
new file mode 100644
index 00000000..65a99e29
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/TypeRegeneration/MessageForm.cs
@@ -0,0 +1,80 @@
+//
+// (C) Copyright 2003-2008 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using System.Threading;
+using System.Runtime.InteropServices;
+
+namespace Revit.SDK.Samples.TypeRegeneration.CS
+{
+ ///
+ /// The form is used to show the result
+ ///
+ public partial class MessageForm : Form
+ {
+ ///
+ /// new a Timer,set the interval 2 seconds;
+ ///
+ System.Timers.Timer timer = new System.Timers.Timer(2000);
+
+ ///
+ /// construction of MessageForm
+ ///
+ public MessageForm()
+ {
+ InitializeComponent();
+ this.Text = "Type Regeneration Message Form";
+ //set the timer elapsed event
+ timer.Elapsed += new System.Timers.ElapsedEventHandler(onTimeOut);//Set the executed event when time is out;
+ timer.Enabled = false;
+ CheckForIllegalCrossThreadCalls = false;
+ }
+
+ ///
+ /// add text to the richtextbox and set time enable is true, then timer starts timing
+ ///
+ /// message from the regeneration
+ /// enable or disable the timer elapsed event
+ public void AddMessage(string message, bool enableTimer)
+ {
+ messageRichTextBox.AppendText(message);
+ timer.Enabled = enableTimer;
+ }
+
+ ///
+ /// the method is executed when time is out, and set the timer enabled false,then timer stop timing
+ ///
+ ///
+ /// time elapsed event args
+ private void onTimeOut(object? source, System.Timers.ElapsedEventArgs e)
+ {
+ timer.Enabled = false;
+ this.Close();
+ }
+ }
+}
diff --git a/SDK/Samples/SlabProperties/CS/SlabProperitiesForm.resx b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/TypeRegeneration/MessageForm.resx
similarity index 100%
rename from SDK/Samples/SlabProperties/CS/SlabProperitiesForm.resx
rename to SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/TypeRegeneration/MessageForm.resx
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/TypeRegeneration/TypeRegeneration.cs b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/TypeRegeneration/TypeRegeneration.cs
new file mode 100644
index 00000000..ac82ac60
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/TypeRegeneration/TypeRegeneration.cs
@@ -0,0 +1,176 @@
+//
+// (C) Copyright 2003-2008 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+
+using System.Windows.Forms;
+using System.IO;
+using System.Reflection;
+
+using Autodesk.Revit;
+using Autodesk.Revit.DB;
+using MacroSamples_RFA;
+
+namespace Revit.SDK.Samples.TypeRegeneration.CS
+{
+ ///
+ /// this class controls the class which subscribes handle events and the events' information UI.
+ /// like a bridge between them.
+ ///
+ public class TypeRegeneration
+ {
+ #region Class Memeber Variables
+ ///
+ /// store family manager
+ ///
+ private FamilyManager? m_familyManager;
+ private Autodesk.Revit.ApplicationServices.Application m_revit;
+ private ThisApplication? m_thisApp;
+
+ ///
+ /// store the log file name
+ ///
+ string m_logFileName = string.Empty;
+ #endregion
+
+ public TypeRegeneration(ThisApplication thisApp)
+ {
+ m_thisApp = thisApp;
+ m_revit = thisApp.ActiveUIDocument.Document.Application;
+ }
+
+ #region Class Interface Implementation
+
+ ///
+ /// Run
+ ///
+ public void Run()
+ {
+ if (m_thisApp == null)
+ return;
+ Document document = m_thisApp.ActiveUIDocument.Document;
+ String? docPath = String.Empty;
+
+ if (document.PathName != null)
+ {
+ docPath = System.IO.Path.GetDirectoryName(document.PathName);
+ }
+ m_logFileName = docPath + "\\RegenerationLog.txt";
+
+ //only a family document can retrieve family manager
+ if (document.IsFamilyDocument)
+ {
+ m_familyManager = document.FamilyManager;
+ //create regeneration log file
+ StreamWriter writer = File.CreateText(m_logFileName);
+ writer.WriteLine("Family Type Result");
+ writer.WriteLine("-------------------------");
+ writer.Close();
+ using (MessageForm msgForm = new MessageForm())
+ {
+ CheckTypeRegeneration(msgForm);
+ return;
+ }
+ }
+ else
+ {
+ System.Windows.Forms.MessageBox.Show("Current document is not family document.");
+ return;
+ }
+ }
+ #endregion
+
+ #region Class Implementation
+ ///
+ /// After setting CurrentType property, the CurrentType has changed to the new one,the Revit model will change along with the current type
+ ///
+ /// the form is used to show the regeneration result
+ private void CheckTypeRegeneration(MessageForm msgForm)
+ {
+ //the list to record the error messages
+ List errorInfo = new List();
+ try
+ {
+ if (m_familyManager == null)
+ return;
+ foreach (FamilyType type in m_familyManager.Types)
+ {
+ if (!(type.Name.ToString().Trim() == ""))
+ {
+ try
+ {
+ m_familyManager.CurrentType = type;
+ msgForm.AddMessage(type.Name + " Successful\n", true);
+ WriteLog(type.Name + " Successful");
+ }
+ catch
+ {
+ errorInfo.Add(type.Name);
+ msgForm.AddMessage(type.Name + " Failed \n", true);
+ WriteLog(type.Name + " Failed");
+ }
+ msgForm.ShowDialog();
+ }
+ }
+
+ //add a conclusion regeneration result
+ string resMsg;
+ if (errorInfo.Count > 0)
+ {
+ resMsg = "\nResult: " + errorInfo.Count + " family types regeneration failed!";
+ foreach (string error in errorInfo)
+ {
+ resMsg += "\n " + error;
+ }
+ }
+ else
+ {
+ resMsg = "\nResult: All types in the family can regenerate successfully.";
+ }
+ WriteLog(resMsg.ToString());
+ resMsg += "\nIf you want to know the detail regeneration result please get log file at " + m_logFileName;
+ msgForm.AddMessage(resMsg, false);
+ msgForm.ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ WriteLog("There is some problem when regeneration:" + ex.ToString());
+ msgForm.AddMessage("There is some problem when regeneration:" + ex.ToString(), true);
+ msgForm.ShowDialog();
+ }
+ }
+
+ ///
+ /// The method to write line to log file
+ ///
+ /// the log string
+ private void WriteLog(string logStr)
+ {
+ StreamWriter? writer = null;
+ writer = File.AppendText(m_logFileName);
+ writer.WriteLine(logStr);
+ writer.Close();
+ }
+ #endregion
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ValidateParameters/MessageForm.Designer.cs b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ValidateParameters/MessageForm.Designer.cs
new file mode 100644
index 00000000..09ad604b
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ValidateParameters/MessageForm.Designer.cs
@@ -0,0 +1,88 @@
+//
+// (C) Copyright 2003-2008 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+namespace Revit.SDK.Samples.ValidateParameters.CS
+{
+ partial class MessageForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.messageRichTextBox = new System.Windows.Forms.RichTextBox();
+ this.SuspendLayout();
+ //
+ // messageRichTextBox
+ //
+ this.messageRichTextBox.BackColor = System.Drawing.SystemColors.Info;
+ this.messageRichTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.messageRichTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.messageRichTextBox.ForeColor = System.Drawing.SystemColors.InfoText;
+ this.messageRichTextBox.Location = new System.Drawing.Point(0, 0);
+ this.messageRichTextBox.Name = "messageRichTextBox";
+ this.messageRichTextBox.Size = new System.Drawing.Size(415, 216);
+ this.messageRichTextBox.TabIndex = 0;
+ this.messageRichTextBox.Text = "";
+ //
+ // MessageForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(415, 216);
+ this.Controls.Add(this.messageRichTextBox);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "MessageForm";
+ this.ShowInTaskbar = false;
+ this.Text = "MessageForm";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.RichTextBox messageRichTextBox;
+ }
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ValidateParameters/MessageForm.cs b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ValidateParameters/MessageForm.cs
new file mode 100644
index 00000000..f3353a0c
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ValidateParameters/MessageForm.cs
@@ -0,0 +1,108 @@
+//
+// (C) Copyright 2003-2008 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Windows.Forms;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+using MacroSamples_RFA;
+
+namespace Revit.SDK.Samples.ValidateParameters.CS
+{
+ ///
+ /// The form is used to show the result
+ ///
+ public partial class MessageForm : Form
+ {
+ ///
+ /// store the log file name
+ ///
+ string m_logFileName = string.Empty;
+
+ ///
+ /// construction of form
+ ///
+ public MessageForm(ThisApplication thisApp)
+ {
+ InitializeComponent();
+ //create regeneration log file
+ if (thisApp.ActiveUIDocument.Document.PathName != null)
+ {
+ m_logFileName = Path.GetDirectoryName(thisApp.ActiveUIDocument.Document.PathName) + "\\ValidateParametersLog.txt";
+ }
+ }
+ ///
+ /// construction method with parameter
+ ///
+ /// messages
+ public MessageForm(string[] messages, ThisApplication thisApp)
+ : this(thisApp)
+ {
+ string msgText = "";
+ //If the size of error messages is 0, means the validate parameters is successful
+ this.Text = "Validate Parameters Message Form";
+
+ StreamWriter writer = File.CreateText(m_logFileName);
+ writer.Close();
+ if (messages.Length == 0)
+ {
+ msgText = "All types and parameters passed the validation for API";
+ WriteLog(msgText);
+ messageRichTextBox.Text = msgText;
+ }
+ else
+ {
+ foreach (string row in messages)
+ {
+ if (row == null) continue;
+ else
+ {
+ WriteLog(row);
+ msgText += row + "\n";
+ }
+ }
+ }
+ msgText += "\n\nIf you want to know the validating parameters result, please get the log file at \n"+m_logFileName;
+ messageRichTextBox.Text = msgText;
+ this.StartPosition = FormStartPosition.CenterParent;
+ CheckForIllegalCrossThreadCalls = false;
+ }
+
+ ///
+ /// The method is used to write line to log file
+ ///
+ /// the log string
+ private void WriteLog(string logStr)
+ {
+ StreamWriter? writer = null;
+ writer = File.AppendText(m_logFileName);
+ writer.WriteLine(logStr);
+ writer.Close();
+ }
+ }
+}
diff --git a/SDK/Macro Samples/Rooms/Source/Rooms/Properties/Resources.resx b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ValidateParameters/MessageForm.resx
similarity index 95%
rename from SDK/Macro Samples/Rooms/Source/Rooms/Properties/Resources.resx
rename to SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ValidateParameters/MessageForm.resx
index 29dcb1b3..ff31a6db 100644
--- a/SDK/Macro Samples/Rooms/Source/Rooms/Properties/Resources.resx
+++ b/SDK/Macro Samples/MacroSamples_RFA/Source/MacroSamples_RFA/ValidateParameters/MessageForm.resx
@@ -1,4 +1,4 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/DeleteObject/DeleteObject.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/DeleteObject/DeleteObject.cs
new file mode 100644
index 00000000..85bd7026
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/DeleteObject/DeleteObject.cs
@@ -0,0 +1,111 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Windows.Forms;
+using System.Collections;
+using System.Collections.Generic;
+
+using Autodesk.Revit;
+using Autodesk.Revit.DB;
+
+using MacroSamples_RVT;
+
+namespace Revit.SDK.Samples.DeleteObject.CS
+{
+ ///
+ /// Delete the elements that were selected
+ ///
+ public class DeleteObject
+ {
+ ThisApplication? m_app; //ThisDocument data for Macro
+
+ ///
+ /// Ctro without parameter is not allowed
+ ///
+ private DeleteObject()
+ {
+ }
+
+ ///
+ /// Ctor with ThisDocument as
+ ///
+ /// ThisDocument handler
+ public DeleteObject(ThisApplication App)
+ {
+ m_app = App;
+ }
+
+ ///
+ /// Run this sample
+ ///
+ public void Run()
+ {
+ if (m_app == null)
+ return;
+ ICollection collection = m_app.ActiveUIDocument.Selection.GetElementIds();
+ // check user selection
+ if (collection.Count < 1)
+ {
+ MessageBox.Show("Please select an object to delete.", "DeleteObject");
+ return;
+ }
+
+ bool error = true;
+ try
+ {
+ error = true;
+
+ // delete selection
+ IEnumerator e = collection.GetEnumerator();
+ bool MoreValue = e.MoveNext();
+ while (MoreValue)
+ {
+ m_app.ActiveUIDocument.Document.Delete(e.Current as ElementId);
+ MoreValue = e.MoveNext();
+ }
+
+ error = false;
+ }
+ catch
+ {
+ // if revit threw an exception, try to catch it
+ foreach (ElementId id in collection)
+ {
+ m_app.ActiveUIDocument.Selection.GetElementIds().Add(id);
+ }
+ MessageBox.Show("Element(s) can't be deleted.", "DeleteObject");
+ return;
+ }
+ finally
+ {
+ // if revit threw an exception, display error and return failed
+ if (error)
+ {
+ MessageBox.Show("Deletion failed.");
+ }
+ }
+
+ return;
+ }
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateOrthogonalGridsData.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateOrthogonalGridsData.cs
new file mode 100644
index 00000000..c2ebdf20
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateOrthogonalGridsData.cs
@@ -0,0 +1,455 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Collections;
+using System.Windows.Forms;
+
+using Autodesk.Revit;
+using Autodesk.Revit.DB;
+
+using MacroCSharpSamples;
+
+using Application = Autodesk.Revit.ApplicationServices.Application;
+
+using SamplePropertis = MacroCSharpSamples.GridCreation.GridCreationProperties;
+using MacroSamples_RVT;
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ ///
+ /// Data class which stores information for creating orthogonal grids
+ ///
+ public class CreateOrthogonalGridsData
+ {
+ #region Fields
+ // X coordinate of origin
+ private double m_xOrigin;
+ // Y coordinate of origin
+ private double m_yOrigin;
+ // Spacing between horizontal grids
+ private double m_xSpacing;
+ // Spacing between vertical grids
+ private double m_ySpacing;
+ // Number of horizontal grids
+ private uint m_xNumber;
+ // Number of vertical grids
+ private uint m_yNumber;
+ // Bubble location of horizontal grids
+ private BubbleLocation m_xBubbleLoc;
+ // Bubble location of vertical grids
+ private BubbleLocation m_yBubbleLoc;
+ // Label of first horizontal grid
+ private String? m_xFirstLabel;
+ // Label of first vertical grid
+ private String? m_yFirstLabel;
+ // Array list contains all grid labels in current document
+ private ArrayList m_labelsList;
+ // Revit application
+ private ThisApplication? m_thisApp;
+ // Current display unit type
+ ForgeTypeId? m_unit;
+ #endregion
+
+ #region Properties
+ ///
+ /// X coordinate of origin
+ ///
+ public double XOrigin
+ {
+ get
+ {
+ return m_xOrigin;
+ }
+ set
+ {
+ m_xOrigin = value;
+ }
+ }
+
+ ///
+ /// Y coordinate of origin
+ ///
+ public double YOrigin
+ {
+ get
+ {
+ return m_yOrigin;
+ }
+ set
+ {
+ m_yOrigin = value;
+ }
+ }
+
+ ///
+ /// Spacing between horizontal grids
+ ///
+ public double XSpacing
+ {
+ get
+ {
+ return m_xSpacing;
+ }
+ set
+ {
+ m_xSpacing = value;
+ }
+ }
+
+ ///
+ /// Spacing between vertical grids
+ ///
+ public double YSpacing
+ {
+ get
+ {
+ return m_ySpacing;
+ }
+ set
+ {
+ m_ySpacing = value;
+ }
+ }
+
+ ///
+ /// Number of horizontal grids
+ ///
+ public uint XNumber
+ {
+ get
+ {
+ return m_xNumber;
+ }
+ set
+ {
+ m_xNumber = value;
+ }
+ }
+
+ ///
+ /// Number of vertical grids
+ ///
+ public uint YNumber
+ {
+ get
+ {
+ return m_yNumber;
+ }
+ set
+ {
+ m_yNumber = value;
+ }
+ }
+
+ ///
+ /// Bubble location of horizontal grids
+ ///
+ public BubbleLocation XBubbleLoc
+ {
+ get
+ {
+ return m_xBubbleLoc;
+ }
+ set
+ {
+ m_xBubbleLoc = value;
+ }
+ }
+
+ ///
+ /// Bubble location of vertical grids
+ ///
+ public BubbleLocation YBubbleLoc
+ {
+ get
+ {
+ return m_yBubbleLoc;
+ }
+ set
+ {
+ m_yBubbleLoc = value;
+ }
+ }
+
+ ///
+ /// Label of first horizontal grid
+ ///
+ public String XFirstLabel
+ {
+ get
+ {
+ return m_xFirstLabel == null ? string.Empty : m_xFirstLabel;
+ }
+ set
+ {
+ m_xFirstLabel = value;
+ }
+ }
+
+ ///
+ /// Label of first vertical grid
+ ///
+ public String YFirstLabel
+ {
+ get
+ {
+ return m_yFirstLabel == null ? string.Empty : m_yFirstLabel;
+ }
+ set
+ {
+ m_yFirstLabel = value;
+ }
+ }
+
+ ///
+ /// Get array list contains all grid labels in current document
+ ///
+ public ArrayList LabelsList
+ {
+ get
+ {
+ return m_labelsList;
+ }
+ }
+
+ ///
+ /// Current display unit type
+ ///
+ public ForgeTypeId? Unit
+ {
+ get
+ {
+ return m_unit;
+ }
+ }
+ #endregion
+
+ #region Methods
+ ///
+ /// Constructor
+ ///
+ /// Application object
+ /// Current length display unit type
+ /// All existing labels in Revit's document
+ public CreateOrthogonalGridsData(ThisApplication? thisApp, ForgeTypeId? unit, ArrayList labels)
+ {
+ m_thisApp = thisApp;
+ m_labelsList = labels;
+ m_unit = unit;
+ }
+
+ ///
+ /// Create grids
+ ///
+ public void CreateGrids()
+ {
+ ArrayList failureReasons = new ArrayList();
+ if (CreateXGrids(ref failureReasons) + CreateYGrids(ref failureReasons) != 0)
+ {
+ String? failureReason = SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToCreateGrids");
+ if (failureReasons.Count != 0)
+ {
+ failureReason += SamplePropertis.GridCreationResources.ResourceManager.GetString("Reasons") + "\r";
+ failureReason += "\r";
+ foreach (String reason in failureReasons)
+ {
+ failureReason += reason + "\r";
+ }
+ }
+
+ failureReason += "\r" + SamplePropertis.GridCreationResources.ResourceManager.GetString("AjustValues");
+
+ MessageBox.Show(failureReason,
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionCreateGrids"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ }
+
+ ///
+ /// Create horizontal grids
+ ///
+ /// ArrayList contains failure reasons
+ /// Number of grids failed to create
+ private int CreateXGrids(ref ArrayList failureReasons)
+ {
+ int errorCount = 0;
+
+ for (int i = 0; i < m_xNumber; ++i)
+ {
+ XYZ? startPoint;
+ XYZ? endPoint;
+ Line line;
+ Grid grid;
+
+ try
+ {
+ if (m_yNumber != 0)
+ {
+ // Grids will have an extension distance of m_ySpacing / 2
+ startPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin - m_ySpacing / 2, m_yOrigin + i * m_xSpacing, 0);
+ endPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + (m_yNumber - 1) * m_ySpacing + m_ySpacing / 2, m_yOrigin + i * m_xSpacing, 0);
+ }
+ else
+ {
+ startPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin, m_yOrigin + i * m_xSpacing, 0);
+ endPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + m_xSpacing / 2, m_yOrigin + i * m_xSpacing, 0);
+ }
+
+ try
+ {
+ // Create a line according to the bubble location
+ if (m_xBubbleLoc == BubbleLocation.StartPoint)
+ {
+ line = Line.CreateBound(startPoint, endPoint);
+ }
+ else
+ {
+ line = Line.CreateBound(endPoint, startPoint);
+ }
+ }
+ catch (System.ArgumentException)
+ {
+ String? failureReason = SamplePropertis.GridCreationResources.ResourceManager.GetString("SpacingsTooSmall");
+ if (!failureReasons.Contains(failureReason))
+ {
+ failureReasons.Add(failureReason);
+ }
+ errorCount++;
+ continue;
+ }
+
+ // Create grid with line
+ grid = Grid.Create(m_thisApp?.ActiveUIDocument.Document, line);
+
+ // Set label of first horizontal grid
+ if (grid != null && i == 0)
+ {
+ try
+ {
+ grid.Name = m_xFirstLabel;
+ }
+ catch (System.ArgumentException)
+ {
+ MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_xFirstLabel + "!",
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ }
+ }
+ catch (Exception)
+ {
+ ++errorCount;
+ continue;
+ }
+ }
+
+ return errorCount;
+ }
+
+ ///
+ /// Create vertical grids
+ ///
+ /// ArrayList contains failure reasons
+ /// Number of grids failed to create
+ private int CreateYGrids(ref ArrayList failureReasons)
+ {
+ int errorCount = 0;
+
+ for (int j = 0; j < m_yNumber; ++j)
+ {
+ XYZ? startPoint;
+ XYZ? endPoint;
+ Line line;
+ Grid grid;
+
+ try
+ {
+ if (m_xNumber != 0)
+ {
+ startPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + j * m_ySpacing, m_yOrigin - m_xSpacing / 2, 0);
+ endPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + j * m_ySpacing, m_yOrigin + (m_xNumber - 1) * m_xSpacing + m_xSpacing / 2, 0);
+ }
+ else
+ {
+ startPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + j * m_ySpacing, m_yOrigin, 0);
+ endPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + j * m_ySpacing, m_yOrigin + m_ySpacing / 2, 0);
+ }
+
+ try
+ {
+ // Create a line according to the bubble location
+ if (m_yBubbleLoc == BubbleLocation.StartPoint)
+ {
+ line = Line.CreateBound(startPoint, endPoint);
+ }
+ else
+ {
+ line = Line.CreateBound(endPoint, startPoint);
+ }
+ }
+ catch (System.ArgumentException)
+ {
+ String? failureReason = SamplePropertis.GridCreationResources.ResourceManager.GetString("SpacingsTooSmall");
+ if (!failureReasons.Contains(failureReason))
+ {
+ failureReasons.Add(failureReason);
+ }
+ errorCount++;
+ continue;
+ }
+
+ // Create grid with line
+ grid = Grid.Create(m_thisApp?.ActiveUIDocument.Document, line);
+
+ // Set label of first vertical grid
+ if (grid != null && j == 0)
+ {
+ try
+ {
+ grid.Name = m_yFirstLabel;
+ }
+ catch (System.ArgumentException)
+ {
+ MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_yFirstLabel + "!",
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ }
+ }
+ catch (Exception)
+ {
+ ++errorCount;
+ continue;
+ }
+ }
+
+ return errorCount;
+ }
+ #endregion
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateOrthogonalGridsForm.Designer.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateOrthogonalGridsForm.Designer.cs
new file mode 100644
index 00000000..295bd19a
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateOrthogonalGridsForm.Designer.cs
@@ -0,0 +1,425 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ partial class CreateOrthogonalGridsForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.labelYCoordUnit = new System.Windows.Forms.Label();
+ this.labelXCoordUnit = new System.Windows.Forms.Label();
+ this.textBoxYCoord = new System.Windows.Forms.TextBox();
+ this.textBoxXCoord = new System.Windows.Forms.TextBox();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label1 = new System.Windows.Forms.Label();
+ this.textBoxYNumber = new System.Windows.Forms.TextBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.textBoxXNumber = new System.Windows.Forms.TextBox();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.labelUnitY = new System.Windows.Forms.Label();
+ this.textBoxYSpacing = new System.Windows.Forms.TextBox();
+ this.textBoxYFirstLabel = new System.Windows.Forms.TextBox();
+ this.comboBoxYBubbleLocation = new System.Windows.Forms.ComboBox();
+ this.label10 = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
+ this.label9 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.groupBox3 = new System.Windows.Forms.GroupBox();
+ this.labelUnitX = new System.Windows.Forms.Label();
+ this.textBoxXSpacing = new System.Windows.Forms.TextBox();
+ this.textBoxXFirstLabel = new System.Windows.Forms.TextBox();
+ this.comboBoxXBubbleLocation = new System.Windows.Forms.ComboBox();
+ this.label6 = new System.Windows.Forms.Label();
+ this.label7 = new System.Windows.Forms.Label();
+ this.label8 = new System.Windows.Forms.Label();
+ this.buttonCreate = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.groupBox1.SuspendLayout();
+ this.groupBox2.SuspendLayout();
+ this.groupBox3.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.labelYCoordUnit);
+ this.groupBox1.Controls.Add(this.labelXCoordUnit);
+ this.groupBox1.Controls.Add(this.textBoxYCoord);
+ this.groupBox1.Controls.Add(this.textBoxXCoord);
+ this.groupBox1.Controls.Add(this.label2);
+ this.groupBox1.Controls.Add(this.label1);
+ this.groupBox1.Location = new System.Drawing.Point(13, 12);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(520, 55);
+ this.groupBox1.TabIndex = 0;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Origin of the Grids";
+ //
+ // labelYCoordUnit
+ //
+ this.labelYCoordUnit.Location = new System.Drawing.Point(484, 23);
+ this.labelYCoordUnit.Name = "labelYCoordUnit";
+ this.labelYCoordUnit.Size = new System.Drawing.Size(23, 13);
+ this.labelYCoordUnit.TabIndex = 7;
+ //
+ // labelXCoordUnit
+ //
+ this.labelXCoordUnit.Location = new System.Drawing.Point(227, 23);
+ this.labelXCoordUnit.Name = "labelXCoordUnit";
+ this.labelXCoordUnit.Size = new System.Drawing.Size(23, 13);
+ this.labelXCoordUnit.TabIndex = 7;
+ //
+ // textBoxYCoord
+ //
+ this.textBoxYCoord.Location = new System.Drawing.Point(385, 20);
+ this.textBoxYCoord.Name = "textBoxYCoord";
+ this.textBoxYCoord.Size = new System.Drawing.Size(98, 20);
+ this.textBoxYCoord.TabIndex = 1;
+ this.textBoxYCoord.Tag = "0";
+ this.textBoxYCoord.Text = "0";
+ //
+ // textBoxXCoord
+ //
+ this.textBoxXCoord.Location = new System.Drawing.Point(109, 20);
+ this.textBoxXCoord.Name = "textBoxXCoord";
+ this.textBoxXCoord.Size = new System.Drawing.Size(112, 20);
+ this.textBoxXCoord.TabIndex = 0;
+ this.textBoxXCoord.Tag = "0";
+ this.textBoxXCoord.Text = "0";
+ //
+ // label2
+ //
+ this.label2.Location = new System.Drawing.Point(261, 24);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(122, 13);
+ this.label2.TabIndex = 0;
+ this.label2.Text = "Y coordinate:";
+ //
+ // label1
+ //
+ this.label1.Location = new System.Drawing.Point(7, 24);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(95, 13);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "X coordinate:";
+ //
+ // textBoxYNumber
+ //
+ this.textBoxYNumber.Location = new System.Drawing.Point(385, 24);
+ this.textBoxYNumber.Name = "textBoxYNumber";
+ this.textBoxYNumber.Size = new System.Drawing.Size(120, 20);
+ this.textBoxYNumber.TabIndex = 1;
+ this.textBoxYNumber.Tag = "3";
+ this.textBoxYNumber.Text = "3";
+ //
+ // label3
+ //
+ this.label3.Location = new System.Drawing.Point(261, 27);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(122, 13);
+ this.label3.TabIndex = 7;
+ this.label3.Text = "Number:";
+ //
+ // textBoxXNumber
+ //
+ this.textBoxXNumber.Location = new System.Drawing.Point(385, 23);
+ this.textBoxXNumber.Name = "textBoxXNumber";
+ this.textBoxXNumber.Size = new System.Drawing.Size(120, 20);
+ this.textBoxXNumber.TabIndex = 1;
+ this.textBoxXNumber.Tag = "3";
+ this.textBoxXNumber.Text = "3";
+ //
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.labelUnitY);
+ this.groupBox2.Controls.Add(this.textBoxYNumber);
+ this.groupBox2.Controls.Add(this.textBoxYSpacing);
+ this.groupBox2.Controls.Add(this.textBoxYFirstLabel);
+ this.groupBox2.Controls.Add(this.label3);
+ this.groupBox2.Controls.Add(this.comboBoxYBubbleLocation);
+ this.groupBox2.Controls.Add(this.label10);
+ this.groupBox2.Controls.Add(this.label5);
+ this.groupBox2.Controls.Add(this.label9);
+ this.groupBox2.Location = new System.Drawing.Point(14, 165);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(519, 85);
+ this.groupBox2.TabIndex = 2;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Y direction Grids";
+ //
+ // labelUnitY
+ //
+ this.labelUnitY.Location = new System.Drawing.Point(227, 26);
+ this.labelUnitY.Name = "labelUnitY";
+ this.labelUnitY.Size = new System.Drawing.Size(23, 13);
+ this.labelUnitY.TabIndex = 7;
+ //
+ // textBoxYSpacing
+ //
+ this.textBoxYSpacing.Location = new System.Drawing.Point(110, 24);
+ this.textBoxYSpacing.Name = "textBoxYSpacing";
+ this.textBoxYSpacing.Size = new System.Drawing.Size(112, 20);
+ this.textBoxYSpacing.TabIndex = 0;
+ this.textBoxYSpacing.Tag = "10.0";
+ this.textBoxYSpacing.Text = "10.0";
+ //
+ // textBoxYFirstLabel
+ //
+ this.textBoxYFirstLabel.Location = new System.Drawing.Point(385, 53);
+ this.textBoxYFirstLabel.Name = "textBoxYFirstLabel";
+ this.textBoxYFirstLabel.Size = new System.Drawing.Size(120, 20);
+ this.textBoxYFirstLabel.TabIndex = 3;
+ this.textBoxYFirstLabel.Tag = "A";
+ this.textBoxYFirstLabel.Text = "A";
+ //
+ // comboBoxYBubbleLocation
+ //
+ this.comboBoxYBubbleLocation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBoxYBubbleLocation.FormattingEnabled = true;
+ this.comboBoxYBubbleLocation.Items.AddRange(new object[] {
+ "At start point of lines",
+ "At end point of lines"});
+ this.comboBoxYBubbleLocation.Location = new System.Drawing.Point(108, 53);
+ this.comboBoxYBubbleLocation.Name = "comboBoxYBubbleLocation";
+ this.comboBoxYBubbleLocation.Size = new System.Drawing.Size(146, 21);
+ this.comboBoxYBubbleLocation.TabIndex = 2;
+ //
+ // label10
+ //
+ this.label10.Location = new System.Drawing.Point(7, 55);
+ this.label10.Name = "label10";
+ this.label10.Size = new System.Drawing.Size(95, 13);
+ this.label10.TabIndex = 6;
+ this.label10.Text = "Bubble location:";
+ //
+ // label5
+ //
+ this.label5.Location = new System.Drawing.Point(6, 26);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(95, 13);
+ this.label5.TabIndex = 7;
+ this.label5.Text = "Spacing:";
+ //
+ // label9
+ //
+ this.label9.Location = new System.Drawing.Point(261, 55);
+ this.label9.Name = "label9";
+ this.label9.Size = new System.Drawing.Size(122, 13);
+ this.label9.TabIndex = 6;
+ this.label9.Text = "Label of first grid:";
+ //
+ // label4
+ //
+ this.label4.Location = new System.Drawing.Point(261, 26);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(122, 13);
+ this.label4.TabIndex = 6;
+ this.label4.Text = "Number:";
+ //
+ // groupBox3
+ //
+ this.groupBox3.Controls.Add(this.labelUnitX);
+ this.groupBox3.Controls.Add(this.textBoxXNumber);
+ this.groupBox3.Controls.Add(this.textBoxXSpacing);
+ this.groupBox3.Controls.Add(this.textBoxXFirstLabel);
+ this.groupBox3.Controls.Add(this.comboBoxXBubbleLocation);
+ this.groupBox3.Controls.Add(this.label6);
+ this.groupBox3.Controls.Add(this.label7);
+ this.groupBox3.Controls.Add(this.label4);
+ this.groupBox3.Controls.Add(this.label8);
+ this.groupBox3.Location = new System.Drawing.Point(13, 73);
+ this.groupBox3.Name = "groupBox3";
+ this.groupBox3.Size = new System.Drawing.Size(520, 86);
+ this.groupBox3.TabIndex = 1;
+ this.groupBox3.TabStop = false;
+ this.groupBox3.Text = "X direction Grids";
+ //
+ // labelUnitX
+ //
+ this.labelUnitX.Location = new System.Drawing.Point(227, 25);
+ this.labelUnitX.Name = "labelUnitX";
+ this.labelUnitX.Size = new System.Drawing.Size(23, 13);
+ this.labelUnitX.TabIndex = 7;
+ //
+ // textBoxXSpacing
+ //
+ this.textBoxXSpacing.Location = new System.Drawing.Point(109, 23);
+ this.textBoxXSpacing.Name = "textBoxXSpacing";
+ this.textBoxXSpacing.Size = new System.Drawing.Size(112, 20);
+ this.textBoxXSpacing.TabIndex = 0;
+ this.textBoxXSpacing.Tag = "10.0";
+ this.textBoxXSpacing.Text = "10.0";
+ //
+ // textBoxXFirstLabel
+ //
+ this.textBoxXFirstLabel.Location = new System.Drawing.Point(385, 53);
+ this.textBoxXFirstLabel.Name = "textBoxXFirstLabel";
+ this.textBoxXFirstLabel.Size = new System.Drawing.Size(120, 20);
+ this.textBoxXFirstLabel.TabIndex = 3;
+ this.textBoxXFirstLabel.Tag = "";
+ this.textBoxXFirstLabel.Text = "1";
+ //
+ // comboBoxXBubbleLocation
+ //
+ this.comboBoxXBubbleLocation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBoxXBubbleLocation.FormattingEnabled = true;
+ this.comboBoxXBubbleLocation.Items.AddRange(new object[] {
+ "At start point of lines",
+ "At end point of lines"});
+ this.comboBoxXBubbleLocation.Location = new System.Drawing.Point(108, 53);
+ this.comboBoxXBubbleLocation.Name = "comboBoxXBubbleLocation";
+ this.comboBoxXBubbleLocation.Size = new System.Drawing.Size(147, 21);
+ this.comboBoxXBubbleLocation.TabIndex = 2;
+ //
+ // label6
+ //
+ this.label6.Location = new System.Drawing.Point(7, 25);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(95, 13);
+ this.label6.TabIndex = 6;
+ this.label6.Text = "Spacing:";
+ //
+ // label7
+ //
+ this.label7.Location = new System.Drawing.Point(7, 55);
+ this.label7.Name = "label7";
+ this.label7.Size = new System.Drawing.Size(95, 13);
+ this.label7.TabIndex = 6;
+ this.label7.Text = "Bubble location:";
+ //
+ // label8
+ //
+ this.label8.Location = new System.Drawing.Point(261, 55);
+ this.label8.Name = "label8";
+ this.label8.Size = new System.Drawing.Size(122, 13);
+ this.label8.TabIndex = 6;
+ this.label8.Text = "Label of first grid:";
+ //
+ // buttonCreate
+ //
+ this.buttonCreate.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.buttonCreate.Location = new System.Drawing.Point(327, 269);
+ this.buttonCreate.Name = "buttonCreate";
+ this.buttonCreate.Size = new System.Drawing.Size(94, 23);
+ this.buttonCreate.TabIndex = 3;
+ this.buttonCreate.Text = "Create &Grids";
+ this.buttonCreate.UseVisualStyleBackColor = true;
+ this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.buttonCancel.Location = new System.Drawing.Point(439, 269);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(94, 23);
+ this.buttonCancel.TabIndex = 4;
+ this.buttonCancel.Text = "&Cancel";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // CreateOrthogonalGridsForm
+ //
+ this.AcceptButton = this.buttonCreate;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.CancelButton = this.buttonCancel;
+ this.ClientSize = new System.Drawing.Size(545, 304);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonCreate);
+ this.Controls.Add(this.groupBox3);
+ this.Controls.Add(this.groupBox2);
+ this.Controls.Add(this.groupBox1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "CreateOrthogonalGridsForm";
+ this.ShowIcon = false;
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Create Orthogonal Grids";
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
+ this.groupBox3.ResumeLayout(false);
+ this.groupBox3.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.TextBox textBoxYCoord;
+ private System.Windows.Forms.TextBox textBoxXCoord;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.TextBox textBoxYNumber;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.TextBox textBoxXNumber;
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.GroupBox groupBox3;
+ private System.Windows.Forms.TextBox textBoxXSpacing;
+ private System.Windows.Forms.TextBox textBoxYSpacing;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.Label label7;
+ private System.Windows.Forms.Label label8;
+ private System.Windows.Forms.TextBox textBoxXFirstLabel;
+ private System.Windows.Forms.ComboBox comboBoxXBubbleLocation;
+ private System.Windows.Forms.Button buttonCreate;
+ private System.Windows.Forms.Button buttonCancel;
+ private System.Windows.Forms.TextBox textBoxYFirstLabel;
+ private System.Windows.Forms.ComboBox comboBoxYBubbleLocation;
+ private System.Windows.Forms.Label label10;
+ private System.Windows.Forms.Label label9;
+ private System.Windows.Forms.Label labelUnitY;
+ private System.Windows.Forms.Label labelUnitX;
+ private System.Windows.Forms.Label labelYCoordUnit;
+ private System.Windows.Forms.Label labelXCoordUnit;
+ }
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateOrthogonalGridsForm.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateOrthogonalGridsForm.cs
new file mode 100644
index 00000000..8af0899b
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateOrthogonalGridsForm.cs
@@ -0,0 +1,173 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+using SamplePropertis = MacroCSharpSamples.GridCreation.GridCreationProperties;
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ ///
+ /// The dialog which provides the options of creating orthogonal grids
+ ///
+ public partial class CreateOrthogonalGridsForm : Form
+ {
+ // data class object
+ private CreateOrthogonalGridsData m_data;
+
+ ///
+ /// Constructor
+ ///
+ /// Data class object
+ public CreateOrthogonalGridsForm(CreateOrthogonalGridsData data)
+ {
+ m_data = data;
+
+ InitializeComponent();
+ // Set state of controls
+ InitializeControls();
+ }
+
+ ///
+ /// Set state of controls
+ ///
+ private void InitializeControls()
+ {
+ // Set length unit related labels
+ if (m_data.Unit != null)
+ {
+ string? tmp = m_data.Unit.ToString();
+ string tmp2 = string.Empty;
+ if (tmp != null)
+ tmp2 = tmp;
+ String? unit = SamplePropertis.GridCreationResources.ResourceManager.GetString(tmp2);
+ labelUnitX.Text = unit;
+ labelUnitY.Text = unit;
+ labelXCoordUnit.Text = unit;
+ labelYCoordUnit.Text = unit;
+
+
+ // Set spacing values
+ textBoxXSpacing.Text = Unit.CovertFromAPI(m_data.Unit, 10).ToString();
+ textBoxYSpacing.Text = textBoxXSpacing.Text;
+
+ // Set bubble locations to end point
+ comboBoxXBubbleLocation.SelectedIndex = 1;
+ comboBoxYBubbleLocation.SelectedIndex = 1;
+ }
+ }
+
+ private void buttonCreate_Click(object sender, EventArgs e)
+ {
+ // Check if input are validated
+ if (ValidateValues())
+ {
+ // Transfer data back into data class
+ SetData();
+ }
+ else
+ {
+ this.DialogResult = DialogResult.None;
+ }
+ }
+
+ ///
+ /// Transfer data back into data class
+ ///
+ private void SetData()
+ {
+ if (m_data.Unit != null)
+ {
+ m_data.XOrigin = Unit.CovertToAPI(Convert.ToDouble(textBoxXCoord.Text), m_data.Unit);
+ m_data.YOrigin = Unit.CovertToAPI(Convert.ToDouble(textBoxYCoord.Text), m_data.Unit);
+ m_data.XNumber = Convert.ToUInt32(textBoxXNumber.Text);
+ m_data.YNumber = Convert.ToUInt32(textBoxYNumber.Text);
+
+ if (Convert.ToUInt32(textBoxXNumber.Text) != 0)
+ {
+ m_data.XSpacing = Unit.CovertToAPI(Convert.ToDouble(textBoxXSpacing.Text), m_data.Unit);
+ m_data.XBubbleLoc = (BubbleLocation)comboBoxXBubbleLocation.SelectedIndex;
+ m_data.XFirstLabel = textBoxXFirstLabel.Text;
+ }
+
+ if (Convert.ToUInt32(textBoxYNumber.Text) != 0)
+ {
+ m_data.YSpacing = Unit.CovertToAPI(Convert.ToDouble(textBoxYSpacing.Text), m_data.Unit);
+ m_data.YBubbleLoc = (BubbleLocation)comboBoxYBubbleLocation.SelectedIndex;
+ m_data.YFirstLabel = textBoxYFirstLabel.Text;
+ }
+ }
+
+ }
+
+ ///
+ /// Check if input are validated
+ ///
+ /// Whether input is validated
+ private bool ValidateValues()
+ {
+ if (!Validation.ValidateNumbers(textBoxXNumber, textBoxYNumber))
+ {
+ return false;
+ }
+
+ if (!Validation.ValidateCoord(textBoxXCoord) || !Validation.ValidateCoord(textBoxYCoord))
+ {
+ return false;
+ }
+
+ if (Convert.ToUInt32(textBoxXNumber.Text) != 0)
+ {
+ if (!Validation.ValidateLength(textBoxXSpacing, "Spacing", false) ||
+ !Validation.ValidateLabel(textBoxXFirstLabel, m_data.LabelsList))
+ {
+ return false;
+ }
+ }
+
+ if (Convert.ToUInt32(textBoxYNumber.Text) != 0)
+ {
+ if (!Validation.ValidateLength(textBoxYSpacing, "Spacing", false) ||
+ !Validation.ValidateLabel(textBoxYFirstLabel, m_data.LabelsList))
+ {
+ return false;
+ }
+ }
+
+ if (Convert.ToUInt32(textBoxXNumber.Text) != 0 && Convert.ToUInt32(textBoxYNumber.Text) != 0)
+ {
+ if (!Validation.ValidateLabels(textBoxXFirstLabel, textBoxYFirstLabel))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateOrthogonalGridsForm.resx b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateOrthogonalGridsForm.resx
new file mode 100644
index 00000000..ff31a6db
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateOrthogonalGridsForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateRadialAndArcGridsData.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateRadialAndArcGridsData.cs
new file mode 100644
index 00000000..a17cd6e6
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateRadialAndArcGridsData.cs
@@ -0,0 +1,598 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Collections;
+using System.Windows.Forms;
+
+using Autodesk.Revit;
+using Autodesk.Revit.DB;
+
+using MacroCSharpSamples;
+
+using Application = Autodesk.Revit.ApplicationServices.Application;
+
+using SamplePropertis = MacroCSharpSamples.GridCreation.GridCreationProperties;
+using MacroSamples_RVT;
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ ///
+ /// The dialog which provides the options of creating radial and arc grids
+ ///
+ public class CreateRadialAndArcGridsData
+ {
+ #region Fields
+ // X coordinate of origin
+ private double m_xOrigin;
+ // Y coordinate of origin
+ private double m_yOrigin;
+ // Start degree of arc grids and radial grids
+ private double m_startDegree;
+ // End degree of arc grids and radial grids
+ private double m_endDegree;
+ // Spacing between arc grids
+ private double m_arcSpacing;
+ // Number of arc grids
+ private uint m_arcNumber = 0;
+ // Number of radial grids
+ private uint m_lineNumber = 0;
+ // Radius of first arc grid
+ private double m_arcFirstRadius;
+ // Distance from origin to start point
+ private double m_LineFirstDistance;
+ // Bubble location of arc grids
+ private BubbleLocation m_arcFirstBubbleLoc;
+ // Bubble location of radial grids
+ private BubbleLocation m_lineFirstBubbleLoc;
+ // Label of first arc grid
+ private String m_arcFirstLabel = string.Empty;
+ // Label of first radial grid
+ private String m_lineFirstLabel = string.Empty;
+ // Array list contains all grid labels in current document
+ private ArrayList m_labelsList;
+ // Revit application
+ private ThisApplication? m_app;
+ // Current display unit type
+ ForgeTypeId? m_unit;
+ #endregion
+
+ #region Properties
+ ///
+ /// X coordinate of origin
+ ///
+ public double XOrigin
+ {
+ get
+ {
+ return m_xOrigin;
+ }
+ set
+ {
+ m_xOrigin = value;
+ }
+ }
+
+ ///
+ /// Y coordinate of origin
+ ///
+ public double YOrigin
+ {
+ get
+ {
+ return m_yOrigin;
+ }
+ set
+ {
+ m_yOrigin = value;
+ }
+ }
+
+ ///
+ /// Start degree of arc grids and radial grids
+ ///
+ public double StartDegree
+ {
+ get
+ {
+ return m_startDegree;
+ }
+ set
+ {
+ m_startDegree = value;
+ }
+ }
+
+ ///
+ /// End degree of arc grids and radial grids
+ ///
+ public double EndDegree
+ {
+ get
+ {
+ return m_endDegree;
+ }
+ set
+ {
+ m_endDegree = value;
+ }
+ }
+
+ ///
+ /// Spacing between arc grids
+ ///
+ public double ArcSpacing
+ {
+ get
+ {
+ return m_arcSpacing;
+ }
+ set
+ {
+ m_arcSpacing = value;
+ }
+ }
+
+ ///
+ /// Number of arc grids
+ ///
+ public uint ArcNumber
+ {
+ get
+ {
+ return m_arcNumber;
+ }
+ set
+ {
+ m_arcNumber = value;
+ }
+ }
+
+ ///
+ /// Number of radial grids
+ ///
+ public uint LineNumber
+ {
+ get
+ {
+ return m_lineNumber;
+ }
+ set
+ {
+ m_lineNumber = value;
+ }
+ }
+
+ ///
+ /// Radius of first arc grid
+ ///
+ public double ArcFirstRadius
+ {
+ get
+ {
+ return m_arcFirstRadius;
+ }
+ set
+ {
+ m_arcFirstRadius = value;
+ }
+ }
+
+ ///
+ /// Distance from origin to start point
+ ///
+ public double LineFirstDistance
+ {
+ get
+ {
+ return m_LineFirstDistance;
+ }
+ set
+ {
+ m_LineFirstDistance = value;
+ }
+ }
+
+ ///
+ /// Bubble location of arc grids
+ ///
+ public BubbleLocation ArcFirstBubbleLoc
+ {
+ get
+ {
+ return m_arcFirstBubbleLoc;
+ }
+ set
+ {
+ m_arcFirstBubbleLoc = value;
+ }
+ }
+
+ ///
+ /// Bubble location of radial grids
+ ///
+ public BubbleLocation LineFirstBubbleLoc
+ {
+ get
+ {
+ return m_lineFirstBubbleLoc;
+ }
+ set
+ {
+ m_lineFirstBubbleLoc = value;
+ }
+ }
+
+ ///
+ /// Label of first arc grid
+ ///
+ public String ArcFirstLabel
+ {
+ get
+ {
+ return m_arcFirstLabel;
+ }
+ set
+ {
+ m_arcFirstLabel = value;
+ }
+ }
+
+ ///
+ /// Label of first radial grid
+ ///
+ public String LineFirstLabel
+ {
+ get
+ {
+ return m_lineFirstLabel;
+ }
+ set
+ {
+ m_lineFirstLabel = value;
+ }
+ }
+
+ ///
+ /// Get array list contains all grid labels in current document
+ ///
+ public ArrayList LabelsList
+ {
+ get
+ {
+ return m_labelsList;
+ }
+ }
+
+ ///
+ /// Current display unit type
+ ///
+ public ForgeTypeId? Unit
+ {
+ get
+ {
+ return m_unit;
+ }
+ }
+ #endregion
+
+ #region Methods
+ ///
+ /// Constructor
+ ///
+ /// Application object
+ /// Current length display unit type
+ /// All existing labels in Revit's document
+ public CreateRadialAndArcGridsData(ThisApplication? app, ForgeTypeId? unit, ArrayList labels)
+ {
+ m_app = app;
+ m_labelsList = labels;
+ m_unit = unit;
+ }
+
+ ///
+ /// Create grids
+ ///
+ public void CreateGrids()
+ {
+ if (CreateRadialGrids() != 0)
+ {
+ String failureReason = SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToCreateRadialGrids") + "\r";
+ failureReason += SamplePropertis.GridCreationResources.ResourceManager.GetString("AjustValues");
+
+ MessageBox.Show(failureReason,
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionCreateGrids"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+
+ ArrayList failureReasons = new ArrayList();
+ if (CreateArcGrids(ref failureReasons) != 0)
+ {
+ String failureReason = SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToCreateArcGrids") +
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("Reasons") + "\r";
+ if (failureReasons.Count != 0)
+ {
+ failureReason += "\r";
+ foreach (String reason in failureReasons)
+ {
+ failureReason += reason + "\r";
+ }
+ }
+ failureReason += "\r" + SamplePropertis.GridCreationResources.ResourceManager.GetString("AjustValues");
+
+ MessageBox.Show(failureReason,
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionCreateGrids"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ }
+
+ ///
+ /// Create radial grids
+ ///
+ /// Number of grids failed to create
+ private int CreateRadialGrids()
+ {
+ int errorCount = 0;
+
+ for (int i = 0; i < m_lineNumber; ++i)
+ {
+ try
+ {
+ double angel;
+ if (m_lineNumber == 1)
+ {
+ angel = (m_startDegree + m_endDegree) / 2;
+ }
+ else
+ {
+ // The number of space between radial grids will be m_lineNumber if arc is a circle
+ if (m_endDegree - m_startDegree == 2 * Values.PI)
+ {
+ angel = m_startDegree + i * (m_endDegree - m_startDegree) / m_lineNumber;
+ }
+ // The number of space between radial grids will be m_lineNumber-1 if arc is not a circle
+ else
+ {
+ angel = m_startDegree + i * (m_endDegree - m_startDegree) / (m_lineNumber - 1);
+ }
+ }
+
+ XYZ? startPoint;
+ XYZ? endPoint;
+ double cos = Math.Cos(angel);
+ double sin = Math.Sin(angel);
+
+ if (m_arcNumber != 0)
+ {
+ // Grids will have an extension distance of m_ySpacing / 2
+ startPoint = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + m_LineFirstDistance * cos, m_yOrigin + m_LineFirstDistance * sin, 0);
+ endPoint = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + (m_arcFirstRadius + (m_arcNumber - 1) * m_arcSpacing + m_arcSpacing / 2) * cos,
+ m_yOrigin + (m_arcFirstRadius + (m_arcNumber - 1) * m_arcSpacing + m_arcSpacing / 2) * sin, 0);
+ }
+ else
+ {
+ startPoint = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + m_LineFirstDistance * cos, m_yOrigin + m_LineFirstDistance * sin, 0);
+ endPoint = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + (m_arcFirstRadius + 5) * cos, m_yOrigin + (m_arcFirstRadius + 5) * sin, 0);
+ }
+
+ Line line;
+ // Create a line according to the bubble location
+ if (m_lineFirstBubbleLoc == BubbleLocation.StartPoint)
+ {
+ line = Line.CreateBound(startPoint, endPoint);
+ }
+ else
+ {
+ line = Line.CreateBound(endPoint, startPoint);
+ }
+
+ // Create grid with line
+ Grid grid = Grid.Create(m_app?.ActiveUIDocument.Document, line);
+
+ // Set label of first radial grid
+ if (grid != null && i == 0)
+ {
+ try
+ {
+ grid.Name = m_lineFirstLabel;
+ }
+ catch (System.ArgumentException)
+ {
+ MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_lineFirstLabel + "!",
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ }
+ }
+ catch (Exception)
+ {
+ ++errorCount;
+ continue;
+ }
+ }
+
+ return errorCount;
+ }
+
+ ///
+ /// Create Arc Grids
+ ///
+ /// ArrayList contains failure reasons
+ /// Number of grids failed to create
+ private int CreateArcGrids(ref ArrayList failureReasons)
+ {
+ int errorCount = 0;
+
+ for (int i = 0; i < m_arcNumber; ++i)
+ {
+ try
+ {
+ XYZ? origin = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin, m_yOrigin, 0);
+ double radius = m_arcFirstRadius + i * m_arcSpacing;
+
+ // In Revit UI user can select a circle to create a grid, but actually two grids
+ // (One from 0 to 180 degree and the other from 180 degree to 360) will be created.
+ // In RevitAPI using NewGrid method with a circle as its argument will raise an exception.
+ // Therefore in this sample we will create two arcs from the upper and lower parts of the
+ // circle, and then create two grids on the base of the two arcs to accord with UI.
+ if (m_endDegree - m_startDegree == 2 * Values.PI) // Create circular grids
+ {
+ Grid? gridUpper = CreateArcGrid(origin, radius, 0, Values.PI, m_arcFirstBubbleLoc);
+ if (gridUpper != null && i == 0)
+ {
+ try
+ {
+ gridUpper.Name = m_arcFirstLabel;
+ }
+ catch (System.ArgumentException)
+ {
+ MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_arcFirstLabel + "!",
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ }
+ CreateArcGrid(origin, radius, Values.PI, 2 * Values.PI, m_arcFirstBubbleLoc);
+ }
+ else // Create arc grids
+ {
+ // Each arc grid will has extension degree of 15 degree
+ double extensionDegree = 15 * Values.DEGTORAD;
+ Grid? grid;
+
+ if (m_lineNumber != 0)
+ {
+ // If the range of arc degree is too close to a circle, the arc grids will not have
+ // extension degrees.
+ // Also the room for bubble should be considered, so a room size of 3 * extensionDegree
+ // is reserved here
+ if (m_endDegree - m_startDegree < 2 * Values.PI - 3 * extensionDegree)
+ {
+ double startDegreeWithExtension = m_startDegree - extensionDegree;
+ double endDegreeWithExtension = m_endDegree + extensionDegree;
+ grid = CreateArcGrid(origin, radius, startDegreeWithExtension, endDegreeWithExtension, m_arcFirstBubbleLoc);
+ }
+ else
+ {
+ try
+ {
+ grid = CreateArcGrid(origin, radius, m_startDegree, m_endDegree, m_arcFirstBubbleLoc);
+ }
+ catch (System.ArgumentException)
+ {
+ String? failureReason = SamplePropertis.GridCreationResources.ResourceManager.GetString("EndPointsTooClose");
+ if (!failureReasons.Contains(failureReason))
+ {
+ failureReasons.Add(failureReason);
+ }
+ errorCount++;
+ continue;
+ }
+ }
+ }
+ else
+ {
+ try
+ {
+ grid = CreateArcGrid(origin, radius, m_startDegree, m_endDegree, m_arcFirstBubbleLoc);
+ }
+ catch (System.ArgumentException)
+ {
+ String? failureReason = SamplePropertis.GridCreationResources.ResourceManager.GetString("EndPointsTooClose");
+ if (!failureReasons.Contains(failureReason))
+ {
+ failureReasons.Add(failureReason);
+ }
+ errorCount++;
+ continue;
+ }
+ }
+
+
+ if (grid != null && i == 0)
+ {
+ try
+ {
+ grid.Name = m_arcFirstLabel;
+ }
+ catch (System.ArgumentException)
+ {
+ MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_arcFirstLabel + "!",
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ }
+ }
+ }
+ catch (Exception)
+ {
+ ++errorCount;
+ continue;
+ }
+ }
+
+ return errorCount;
+ }
+
+ ///
+ /// Create an arc grid with its origin, radius, start degree, end degree and bubble location
+ ///
+ /// Arc grid's origin
+ /// Arc grid's radius
+ /// Arc grid's start degree
+ /// Arc grid's end degree
+ /// Arc grid's Bubble location
+ /// The newly created grid
+ private Grid? CreateArcGrid(XYZ? origin, double radius, double startDegree, double endDegree, BubbleLocation bubLoc)
+ {
+ // Get start point and end point of the arc and the middle point on the arc
+ if (origin == null)
+ return null;
+ XYZ? startPoint = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(origin.X + radius * Math.Cos(startDegree),
+ origin.Y + radius * Math.Sin(startDegree), origin.Z);
+ XYZ? midPoint = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(origin.X + radius * Math.Cos((startDegree + endDegree) / 2),
+ origin.Y + radius * Math.Sin((startDegree + endDegree) / 2), origin.Z);
+ XYZ? endPoint = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(origin.X + radius * Math.Cos(endDegree),
+ origin.Y + radius * Math.Sin(endDegree), origin.Z);
+
+ Arc arc;
+
+ if (bubLoc == BubbleLocation.StartPoint)
+ {
+ arc = Arc.Create(startPoint, endPoint, midPoint);
+ }
+ else
+ {
+ arc = Arc.Create(endPoint, startPoint, midPoint);
+ }
+
+ return Grid.Create(m_app?.ActiveUIDocument.Document, arc);
+ }
+ #endregion
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateRadialAndArcGridsForm.Designer.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateRadialAndArcGridsForm.Designer.cs
new file mode 100644
index 00000000..c58dbadf
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateRadialAndArcGridsForm.Designer.cs
@@ -0,0 +1,546 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ ///
+ /// The dialog which provides the options of creating radial and arc grids
+ ///
+ partial class CreateRadialAndArcGridsForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.textBoxArcSpacing = new System.Windows.Forms.TextBox();
+ this.labelspace = new System.Windows.Forms.Label();
+ this.groupBox3 = new System.Windows.Forms.GroupBox();
+ this.labelUnitFirstRadius = new System.Windows.Forms.Label();
+ this.labelUnitX = new System.Windows.Forms.Label();
+ this.textBoxArcFirstRadius = new System.Windows.Forms.TextBox();
+ this.comboBoxArcBubbleLocation = new System.Windows.Forms.ComboBox();
+ this.labelradius = new System.Windows.Forms.Label();
+ this.textBoxArcFirstLabel = new System.Windows.Forms.TextBox();
+ this.textBoxArcNumber = new System.Windows.Forms.TextBox();
+ this.labelfirstgrid = new System.Windows.Forms.Label();
+ this.labelbubble = new System.Windows.Forms.Label();
+ this.labelnumber = new System.Windows.Forms.Label();
+ this.labelr_number = new System.Windows.Forms.Label();
+ this.textBoxYCoord = new System.Windows.Forms.TextBox();
+ this.textBoxXCoord = new System.Windows.Forms.TextBox();
+ this.labely = new System.Windows.Forms.Label();
+ this.labelx = new System.Windows.Forms.Label();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.labelUnitY = new System.Windows.Forms.Label();
+ this.textBoxLineFirstDistance = new System.Windows.Forms.TextBox();
+ this.comboBoxLineBubbleLocation = new System.Windows.Forms.ComboBox();
+ this.label1r_distance = new System.Windows.Forms.Label();
+ this.textBoxLineNumber = new System.Windows.Forms.TextBox();
+ this.textBoxLineFirstLabel = new System.Windows.Forms.TextBox();
+ this.label1r_firstgrid = new System.Windows.Forms.Label();
+ this.labelr_bubble = new System.Windows.Forms.Label();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.labelYCoordUnit = new System.Windows.Forms.Label();
+ this.labelXCoordUnit = new System.Windows.Forms.Label();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonCreate = new System.Windows.Forms.Button();
+ this.groupBox4 = new System.Windows.Forms.GroupBox();
+ this.textBoxEndDegree = new System.Windows.Forms.TextBox();
+ this.textBoxStartDegree = new System.Windows.Forms.TextBox();
+ this.labelEndDegree = new System.Windows.Forms.Label();
+ this.labelStartDegree = new System.Windows.Forms.Label();
+ this.radioButtonCustomize = new System.Windows.Forms.RadioButton();
+ this.radioButton360 = new System.Windows.Forms.RadioButton();
+ this.groupBox3.SuspendLayout();
+ this.groupBox2.SuspendLayout();
+ this.groupBox1.SuspendLayout();
+ this.groupBox4.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // textBoxArcSpacing
+ //
+ this.textBoxArcSpacing.Location = new System.Drawing.Point(132, 17);
+ this.textBoxArcSpacing.Name = "textBoxArcSpacing";
+ this.textBoxArcSpacing.Size = new System.Drawing.Size(108, 20);
+ this.textBoxArcSpacing.TabIndex = 0;
+ this.textBoxArcSpacing.Tag = "10.0";
+ this.textBoxArcSpacing.Text = "10.0";
+ //
+ // labelspace
+ //
+ this.labelspace.Location = new System.Drawing.Point(13, 20);
+ this.labelspace.Name = "labelspace";
+ this.labelspace.Size = new System.Drawing.Size(113, 18);
+ this.labelspace.TabIndex = 6;
+ this.labelspace.Text = "Spacing:";
+ //
+ // groupBox3
+ //
+ this.groupBox3.Controls.Add(this.labelUnitFirstRadius);
+ this.groupBox3.Controls.Add(this.labelUnitX);
+ this.groupBox3.Controls.Add(this.textBoxArcFirstRadius);
+ this.groupBox3.Controls.Add(this.comboBoxArcBubbleLocation);
+ this.groupBox3.Controls.Add(this.labelradius);
+ this.groupBox3.Controls.Add(this.textBoxArcFirstLabel);
+ this.groupBox3.Controls.Add(this.textBoxArcNumber);
+ this.groupBox3.Controls.Add(this.labelfirstgrid);
+ this.groupBox3.Controls.Add(this.textBoxArcSpacing);
+ this.groupBox3.Controls.Add(this.labelbubble);
+ this.groupBox3.Controls.Add(this.labelnumber);
+ this.groupBox3.Controls.Add(this.labelspace);
+ this.groupBox3.Location = new System.Drawing.Point(12, 175);
+ this.groupBox3.Name = "groupBox3";
+ this.groupBox3.Size = new System.Drawing.Size(544, 116);
+ this.groupBox3.TabIndex = 2;
+ this.groupBox3.TabStop = false;
+ this.groupBox3.Text = "Arc Grids";
+ //
+ // labelUnitFirstRadius
+ //
+ this.labelUnitFirstRadius.Location = new System.Drawing.Point(240, 52);
+ this.labelUnitFirstRadius.Name = "labelUnitFirstRadius";
+ this.labelUnitFirstRadius.Size = new System.Drawing.Size(23, 23);
+ this.labelUnitFirstRadius.TabIndex = 31;
+ //
+ // labelUnitX
+ //
+ this.labelUnitX.Location = new System.Drawing.Point(240, 20);
+ this.labelUnitX.Name = "labelUnitX";
+ this.labelUnitX.Size = new System.Drawing.Size(23, 23);
+ this.labelUnitX.TabIndex = 13;
+ //
+ // textBoxArcFirstRadius
+ //
+ this.textBoxArcFirstRadius.Location = new System.Drawing.Point(132, 50);
+ this.textBoxArcFirstRadius.Name = "textBoxArcFirstRadius";
+ this.textBoxArcFirstRadius.Size = new System.Drawing.Size(108, 20);
+ this.textBoxArcFirstRadius.TabIndex = 2;
+ this.textBoxArcFirstRadius.Text = "10.0";
+ //
+ // comboBoxArcBubbleLocation
+ //
+ this.comboBoxArcBubbleLocation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBoxArcBubbleLocation.FormattingEnabled = true;
+ this.comboBoxArcBubbleLocation.Items.AddRange(new object[] {
+ "At start point of arcs",
+ "At end point of arcs"});
+ this.comboBoxArcBubbleLocation.Location = new System.Drawing.Point(133, 83);
+ this.comboBoxArcBubbleLocation.Name = "comboBoxArcBubbleLocation";
+ this.comboBoxArcBubbleLocation.Size = new System.Drawing.Size(373, 21);
+ this.comboBoxArcBubbleLocation.TabIndex = 4;
+ //
+ // labelradius
+ //
+ this.labelradius.Location = new System.Drawing.Point(13, 52);
+ this.labelradius.Name = "labelradius";
+ this.labelradius.Size = new System.Drawing.Size(113, 18);
+ this.labelradius.TabIndex = 7;
+ this.labelradius.Text = "Radius of first grid:";
+ //
+ // textBoxArcFirstLabel
+ //
+ this.textBoxArcFirstLabel.Location = new System.Drawing.Point(398, 50);
+ this.textBoxArcFirstLabel.Name = "textBoxArcFirstLabel";
+ this.textBoxArcFirstLabel.Size = new System.Drawing.Size(108, 20);
+ this.textBoxArcFirstLabel.TabIndex = 3;
+ this.textBoxArcFirstLabel.Tag = "";
+ this.textBoxArcFirstLabel.Text = "1";
+ //
+ // textBoxArcNumber
+ //
+ this.textBoxArcNumber.Location = new System.Drawing.Point(398, 17);
+ this.textBoxArcNumber.Name = "textBoxArcNumber";
+ this.textBoxArcNumber.Size = new System.Drawing.Size(108, 20);
+ this.textBoxArcNumber.TabIndex = 1;
+ this.textBoxArcNumber.Text = "3";
+ //
+ // labelfirstgrid
+ //
+ this.labelfirstgrid.Location = new System.Drawing.Point(279, 52);
+ this.labelfirstgrid.Name = "labelfirstgrid";
+ this.labelfirstgrid.Size = new System.Drawing.Size(113, 18);
+ this.labelfirstgrid.TabIndex = 30;
+ this.labelfirstgrid.Text = "Label of first grid:";
+ //
+ // labelbubble
+ //
+ this.labelbubble.Location = new System.Drawing.Point(13, 85);
+ this.labelbubble.Name = "labelbubble";
+ this.labelbubble.Size = new System.Drawing.Size(113, 18);
+ this.labelbubble.TabIndex = 29;
+ this.labelbubble.Text = "Bubble location:";
+ //
+ // labelnumber
+ //
+ this.labelnumber.Location = new System.Drawing.Point(279, 20);
+ this.labelnumber.Name = "labelnumber";
+ this.labelnumber.Size = new System.Drawing.Size(113, 18);
+ this.labelnumber.TabIndex = 6;
+ this.labelnumber.Text = "Number:";
+ //
+ // labelr_number
+ //
+ this.labelr_number.Location = new System.Drawing.Point(279, 23);
+ this.labelr_number.Name = "labelr_number";
+ this.labelr_number.Size = new System.Drawing.Size(113, 18);
+ this.labelr_number.TabIndex = 6;
+ this.labelr_number.Text = "Number:";
+ //
+ // textBoxYCoord
+ //
+ this.textBoxYCoord.Location = new System.Drawing.Point(398, 22);
+ this.textBoxYCoord.Name = "textBoxYCoord";
+ this.textBoxYCoord.Size = new System.Drawing.Size(108, 20);
+ this.textBoxYCoord.TabIndex = 1;
+ this.textBoxYCoord.Text = "0";
+ //
+ // textBoxXCoord
+ //
+ this.textBoxXCoord.Location = new System.Drawing.Point(132, 21);
+ this.textBoxXCoord.Name = "textBoxXCoord";
+ this.textBoxXCoord.Size = new System.Drawing.Size(108, 20);
+ this.textBoxXCoord.TabIndex = 0;
+ this.textBoxXCoord.Text = "0";
+ //
+ // labely
+ //
+ this.labely.Location = new System.Drawing.Point(279, 25);
+ this.labely.Name = "labely";
+ this.labely.Size = new System.Drawing.Size(113, 18);
+ this.labely.TabIndex = 0;
+ this.labely.Text = "Y coordinate:";
+ //
+ // labelx
+ //
+ this.labelx.Location = new System.Drawing.Point(13, 25);
+ this.labelx.Name = "labelx";
+ this.labelx.Size = new System.Drawing.Size(112, 18);
+ this.labelx.TabIndex = 0;
+ this.labelx.Text = "X coordinate:";
+ //
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.labelUnitY);
+ this.groupBox2.Controls.Add(this.textBoxLineFirstDistance);
+ this.groupBox2.Controls.Add(this.comboBoxLineBubbleLocation);
+ this.groupBox2.Controls.Add(this.label1r_distance);
+ this.groupBox2.Controls.Add(this.textBoxLineNumber);
+ this.groupBox2.Controls.Add(this.textBoxLineFirstLabel);
+ this.groupBox2.Controls.Add(this.label1r_firstgrid);
+ this.groupBox2.Controls.Add(this.labelr_number);
+ this.groupBox2.Controls.Add(this.labelr_bubble);
+ this.groupBox2.Location = new System.Drawing.Point(13, 297);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(543, 119);
+ this.groupBox2.TabIndex = 3;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Radial Grids";
+ //
+ // labelUnitY
+ //
+ this.labelUnitY.Location = new System.Drawing.Point(508, 88);
+ this.labelUnitY.Name = "labelUnitY";
+ this.labelUnitY.Size = new System.Drawing.Size(23, 23);
+ this.labelUnitY.TabIndex = 13;
+ //
+ // textBoxLineFirstDistance
+ //
+ this.textBoxLineFirstDistance.Location = new System.Drawing.Point(236, 86);
+ this.textBoxLineFirstDistance.Name = "textBoxLineFirstDistance";
+ this.textBoxLineFirstDistance.Size = new System.Drawing.Size(270, 20);
+ this.textBoxLineFirstDistance.TabIndex = 3;
+ this.textBoxLineFirstDistance.Text = "8.0";
+ //
+ // comboBoxLineBubbleLocation
+ //
+ this.comboBoxLineBubbleLocation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBoxLineBubbleLocation.FormattingEnabled = true;
+ this.comboBoxLineBubbleLocation.Items.AddRange(new object[] {
+ "At start point of lines",
+ "At end point of lines"});
+ this.comboBoxLineBubbleLocation.Location = new System.Drawing.Point(131, 54);
+ this.comboBoxLineBubbleLocation.Name = "comboBoxLineBubbleLocation";
+ this.comboBoxLineBubbleLocation.Size = new System.Drawing.Size(374, 21);
+ this.comboBoxLineBubbleLocation.TabIndex = 2;
+ //
+ // label1r_distance
+ //
+ this.label1r_distance.Location = new System.Drawing.Point(6, 88);
+ this.label1r_distance.Name = "label1r_distance";
+ this.label1r_distance.Size = new System.Drawing.Size(224, 18);
+ this.label1r_distance.TabIndex = 7;
+ this.label1r_distance.Text = "Distance from origin to start point:";
+ //
+ // textBoxLineNumber
+ //
+ this.textBoxLineNumber.Location = new System.Drawing.Point(398, 23);
+ this.textBoxLineNumber.Name = "textBoxLineNumber";
+ this.textBoxLineNumber.Size = new System.Drawing.Size(108, 20);
+ this.textBoxLineNumber.TabIndex = 1;
+ this.textBoxLineNumber.Tag = "3";
+ this.textBoxLineNumber.Text = "3";
+ //
+ // textBoxLineFirstLabel
+ //
+ this.textBoxLineFirstLabel.Location = new System.Drawing.Point(131, 20);
+ this.textBoxLineFirstLabel.Name = "textBoxLineFirstLabel";
+ this.textBoxLineFirstLabel.Size = new System.Drawing.Size(108, 20);
+ this.textBoxLineFirstLabel.TabIndex = 0;
+ this.textBoxLineFirstLabel.Tag = "A";
+ this.textBoxLineFirstLabel.Text = "A";
+ //
+ // label1r_firstgrid
+ //
+ this.label1r_firstgrid.Location = new System.Drawing.Point(6, 23);
+ this.label1r_firstgrid.Name = "label1r_firstgrid";
+ this.label1r_firstgrid.Size = new System.Drawing.Size(119, 18);
+ this.label1r_firstgrid.TabIndex = 30;
+ this.label1r_firstgrid.Text = "Label of first grid:";
+ //
+ // labelr_bubble
+ //
+ this.labelr_bubble.Location = new System.Drawing.Point(6, 57);
+ this.labelr_bubble.Name = "labelr_bubble";
+ this.labelr_bubble.Size = new System.Drawing.Size(119, 18);
+ this.labelr_bubble.TabIndex = 29;
+ this.labelr_bubble.Text = "Bubble location:";
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.textBoxYCoord);
+ this.groupBox1.Controls.Add(this.labelYCoordUnit);
+ this.groupBox1.Controls.Add(this.labelXCoordUnit);
+ this.groupBox1.Controls.Add(this.textBoxXCoord);
+ this.groupBox1.Controls.Add(this.labely);
+ this.groupBox1.Controls.Add(this.labelx);
+ this.groupBox1.Location = new System.Drawing.Point(13, 12);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(543, 55);
+ this.groupBox1.TabIndex = 0;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Center of Arc Grids";
+ //
+ // labelYCoordUnit
+ //
+ this.labelYCoordUnit.Location = new System.Drawing.Point(508, 22);
+ this.labelYCoordUnit.Name = "labelYCoordUnit";
+ this.labelYCoordUnit.Size = new System.Drawing.Size(23, 23);
+ this.labelYCoordUnit.TabIndex = 13;
+ //
+ // labelXCoordUnit
+ //
+ this.labelXCoordUnit.Location = new System.Drawing.Point(240, 24);
+ this.labelXCoordUnit.Name = "labelXCoordUnit";
+ this.labelXCoordUnit.Size = new System.Drawing.Size(23, 23);
+ this.labelXCoordUnit.TabIndex = 13;
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.buttonCancel.Location = new System.Drawing.Point(463, 436);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(94, 23);
+ this.buttonCancel.TabIndex = 5;
+ this.buttonCancel.Text = "&Cancel";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // buttonCreate
+ //
+ this.buttonCreate.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.buttonCreate.Location = new System.Drawing.Point(356, 436);
+ this.buttonCreate.Name = "buttonCreate";
+ this.buttonCreate.Size = new System.Drawing.Size(94, 23);
+ this.buttonCreate.TabIndex = 4;
+ this.buttonCreate.Text = "Create &Grids";
+ this.buttonCreate.UseVisualStyleBackColor = true;
+ this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
+ //
+ // groupBox4
+ //
+ this.groupBox4.Controls.Add(this.textBoxEndDegree);
+ this.groupBox4.Controls.Add(this.textBoxStartDegree);
+ this.groupBox4.Controls.Add(this.labelEndDegree);
+ this.groupBox4.Controls.Add(this.labelStartDegree);
+ this.groupBox4.Controls.Add(this.radioButtonCustomize);
+ this.groupBox4.Controls.Add(this.radioButton360);
+ this.groupBox4.Location = new System.Drawing.Point(13, 74);
+ this.groupBox4.Name = "groupBox4";
+ this.groupBox4.Size = new System.Drawing.Size(543, 95);
+ this.groupBox4.TabIndex = 1;
+ this.groupBox4.TabStop = false;
+ this.groupBox4.Text = "Span of Grids";
+ //
+ // textBoxEndDegree
+ //
+ this.textBoxEndDegree.Location = new System.Drawing.Point(397, 62);
+ this.textBoxEndDegree.Name = "textBoxEndDegree";
+ this.textBoxEndDegree.Size = new System.Drawing.Size(108, 20);
+ this.textBoxEndDegree.TabIndex = 3;
+ this.textBoxEndDegree.Text = "360";
+ //
+ // textBoxStartDegree
+ //
+ this.textBoxStartDegree.Location = new System.Drawing.Point(131, 62);
+ this.textBoxStartDegree.Name = "textBoxStartDegree";
+ this.textBoxStartDegree.Size = new System.Drawing.Size(108, 20);
+ this.textBoxStartDegree.TabIndex = 2;
+ this.textBoxStartDegree.Text = "0";
+ //
+ // labelEndDegree
+ //
+ this.labelEndDegree.Location = new System.Drawing.Point(279, 64);
+ this.labelEndDegree.Name = "labelEndDegree";
+ this.labelEndDegree.Size = new System.Drawing.Size(113, 18);
+ this.labelEndDegree.TabIndex = 2;
+ this.labelEndDegree.Text = "End degree:";
+ //
+ // labelStartDegree
+ //
+ this.labelStartDegree.Location = new System.Drawing.Point(24, 64);
+ this.labelStartDegree.Name = "labelStartDegree";
+ this.labelStartDegree.Size = new System.Drawing.Size(101, 18);
+ this.labelStartDegree.TabIndex = 2;
+ this.labelStartDegree.Text = "Start degree:";
+ //
+ // radioButtonCustomize
+ //
+ this.radioButtonCustomize.Location = new System.Drawing.Point(9, 41);
+ this.radioButtonCustomize.Name = "radioButtonCustomize";
+ this.radioButtonCustomize.Size = new System.Drawing.Size(104, 24);
+ this.radioButtonCustomize.TabIndex = 1;
+ this.radioButtonCustomize.Text = "Customize";
+ this.radioButtonCustomize.UseVisualStyleBackColor = true;
+ this.radioButtonCustomize.CheckedChanged += new System.EventHandler(this.radioButtonCustomize_CheckedChanged);
+ //
+ // radioButton360
+ //
+ this.radioButton360.AutoSize = true;
+ this.radioButton360.Checked = true;
+ this.radioButton360.Location = new System.Drawing.Point(9, 20);
+ this.radioButton360.Name = "radioButton360";
+ this.radioButton360.Size = new System.Drawing.Size(79, 17);
+ this.radioButton360.TabIndex = 0;
+ this.radioButton360.TabStop = true;
+ this.radioButton360.Text = "360 degree";
+ this.radioButton360.UseVisualStyleBackColor = true;
+ this.radioButton360.MouseClick += new System.Windows.Forms.MouseEventHandler(this.radioButton360_MouseClick);
+ //
+ // CreateRadialAndArcGridsForm
+ //
+ this.AcceptButton = this.buttonCreate;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.CancelButton = this.buttonCancel;
+ this.ClientSize = new System.Drawing.Size(568, 466);
+ this.Controls.Add(this.groupBox4);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonCreate);
+ this.Controls.Add(this.groupBox3);
+ this.Controls.Add(this.groupBox2);
+ this.Controls.Add(this.groupBox1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "CreateRadialAndArcGridsForm";
+ this.ShowIcon = false;
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Create Radial and Arc Grids";
+ this.groupBox3.ResumeLayout(false);
+ this.groupBox3.PerformLayout();
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.groupBox4.ResumeLayout(false);
+ this.groupBox4.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TextBox textBoxArcSpacing;
+ private System.Windows.Forms.Label labelspace;
+ private System.Windows.Forms.GroupBox groupBox3;
+ private System.Windows.Forms.Label labelr_number;
+ private System.Windows.Forms.TextBox textBoxYCoord;
+ private System.Windows.Forms.TextBox textBoxXCoord;
+ private System.Windows.Forms.Label labely;
+ private System.Windows.Forms.Label labelx;
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.TextBox textBoxLineNumber;
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.TextBox textBoxArcNumber;
+ private System.Windows.Forms.Button buttonCancel;
+ private System.Windows.Forms.Button buttonCreate;
+ private System.Windows.Forms.Label labelnumber;
+ private System.Windows.Forms.GroupBox groupBox4;
+ private System.Windows.Forms.TextBox textBoxEndDegree;
+ private System.Windows.Forms.TextBox textBoxStartDegree;
+ private System.Windows.Forms.Label labelEndDegree;
+ private System.Windows.Forms.Label labelStartDegree;
+ private System.Windows.Forms.RadioButton radioButtonCustomize;
+ private System.Windows.Forms.RadioButton radioButton360;
+ private System.Windows.Forms.TextBox textBoxArcFirstRadius;
+ private System.Windows.Forms.Label labelradius;
+ private System.Windows.Forms.TextBox textBoxLineFirstDistance;
+ private System.Windows.Forms.Label label1r_distance;
+ private System.Windows.Forms.ComboBox comboBoxArcBubbleLocation;
+ private System.Windows.Forms.TextBox textBoxArcFirstLabel;
+ private System.Windows.Forms.Label labelfirstgrid;
+ private System.Windows.Forms.Label labelbubble;
+ private System.Windows.Forms.ComboBox comboBoxLineBubbleLocation;
+ private System.Windows.Forms.TextBox textBoxLineFirstLabel;
+ private System.Windows.Forms.Label label1r_firstgrid;
+ private System.Windows.Forms.Label labelr_bubble;
+ private System.Windows.Forms.Label labelUnitX;
+ private System.Windows.Forms.Label labelUnitY;
+ private System.Windows.Forms.Label labelUnitFirstRadius;
+ private System.Windows.Forms.Label labelYCoordUnit;
+ private System.Windows.Forms.Label labelXCoordUnit;
+
+
+ }
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateRadialAndArcGridsForm.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateRadialAndArcGridsForm.cs
new file mode 100644
index 00000000..dec7381c
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateRadialAndArcGridsForm.cs
@@ -0,0 +1,213 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+using SamplePropertis = MacroCSharpSamples.GridCreation.GridCreationProperties;
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ public partial class CreateRadialAndArcGridsForm : Form
+ {
+ // data class object
+ private CreateRadialAndArcGridsData m_data;
+
+ ///
+ /// Constructor
+ ///
+ /// Data class object
+ public CreateRadialAndArcGridsForm(CreateRadialAndArcGridsData data)
+ {
+ m_data = data;
+
+ InitializeComponent();
+ // Set state of controls
+ InitializeControls();
+ }
+
+ ///
+ /// Set state of controls
+ ///
+ private void InitializeControls()
+ {
+ // Set length unit related labels
+ if (m_data.Unit != null)
+ {
+ string? tmp = m_data.Unit.ToString();
+ string tmp2 = string.Empty;
+ if (tmp != null)
+ tmp2 = tmp;
+ String? unit = SamplePropertis.GridCreationResources.ResourceManager.GetString(tmp2);
+ labelUnitX.Text = unit;
+ labelUnitY.Text = unit;
+ labelUnitFirstRadius.Text = unit;
+ labelXCoordUnit.Text = unit;
+ labelYCoordUnit.Text = unit;
+
+
+ // Set length values
+ textBoxArcSpacing.Text = Unit.CovertFromAPI(m_data.Unit, 10).ToString();
+ textBoxArcFirstRadius.Text = textBoxArcSpacing.Text;
+ textBoxLineFirstDistance.Text = Unit.CovertFromAPI(m_data.Unit, 8).ToString();
+
+ radioButton360.Checked = true;
+ radioButtonCustomize.Checked = false;
+ labelStartDegree.Enabled = false;
+ textBoxStartDegree.Enabled = false;
+ labelEndDegree.Enabled = false;
+ textBoxEndDegree.Enabled = false;
+ comboBoxArcBubbleLocation.SelectedIndex = 1;
+ comboBoxLineBubbleLocation.SelectedIndex = 1;
+ }
+ }
+
+ private void radioButtonCustomize_CheckedChanged(object sender, EventArgs e)
+ {
+ bool IsCustomize = radioButtonCustomize.Checked;
+ labelStartDegree.Enabled = IsCustomize;
+ textBoxStartDegree.Enabled = IsCustomize;
+ labelEndDegree.Enabled = IsCustomize;
+ textBoxEndDegree.Enabled = IsCustomize;
+ }
+
+ private void radioButton360_MouseClick(object sender, MouseEventArgs e)
+ {
+ radioButtonCustomize.Checked = !radioButton360.Checked;
+ }
+
+ private void buttonCreate_Click(object sender, EventArgs e)
+ {
+ // Check if input are validated
+ if (ValidateValues())
+ {
+ // Transfer data back into data class
+ SetData();
+ }
+ else
+ {
+ this.DialogResult = DialogResult.None;
+ }
+ }
+
+ ///
+ /// Transfer data back into data class
+ ///
+ private void SetData()
+ {
+ if (m_data.Unit != null)
+ {
+ m_data.XOrigin = Unit.CovertToAPI(Convert.ToDouble(textBoxXCoord.Text), m_data.Unit);
+ m_data.YOrigin = Unit.CovertToAPI(Convert.ToDouble(textBoxYCoord.Text), m_data.Unit);
+
+ if (radioButton360.Checked)
+ {
+ m_data.StartDegree = 0;
+ m_data.EndDegree = 2 * Values.PI;
+ }
+ else
+ {
+ m_data.StartDegree = Convert.ToDouble(textBoxStartDegree.Text) * Values.DEGTORAD;
+ m_data.EndDegree = Convert.ToDouble(textBoxEndDegree.Text) * Values.DEGTORAD;
+ }
+
+ m_data.ArcNumber = Convert.ToUInt32(textBoxArcNumber.Text);
+ m_data.LineNumber = Convert.ToUInt32(textBoxLineNumber.Text);
+
+
+ if (Convert.ToUInt32(textBoxArcNumber.Text) != 0)
+ {
+ m_data.ArcSpacing = Unit.CovertToAPI(Convert.ToDouble(textBoxArcSpacing.Text), m_data.Unit);
+ m_data.ArcFirstRadius = Unit.CovertToAPI(Convert.ToDouble(textBoxArcFirstRadius.Text), m_data.Unit);
+ m_data.ArcFirstBubbleLoc = (BubbleLocation)comboBoxArcBubbleLocation.SelectedIndex;
+ m_data.ArcFirstLabel = textBoxArcFirstLabel.Text;
+ }
+
+ if (Convert.ToUInt32(textBoxLineNumber.Text) != 0)
+ {
+ m_data.LineFirstDistance = Unit.CovertToAPI(Convert.ToDouble(textBoxLineFirstDistance.Text), m_data.Unit);
+ m_data.LineFirstBubbleLoc = (BubbleLocation)comboBoxLineBubbleLocation.SelectedIndex;
+ m_data.LineFirstLabel = textBoxLineFirstLabel.Text;
+ }
+ }
+ }
+
+ ///
+ /// Check if input are validated
+ ///
+ /// Whether input is validated
+ private bool ValidateValues()
+ {
+ if (!Validation.ValidateNumbers(textBoxArcNumber, textBoxLineNumber))
+ {
+ return false;
+ }
+
+ if (!Validation.ValidateCoord(textBoxXCoord) || !Validation.ValidateCoord(textBoxYCoord))
+ {
+ return false;
+ }
+
+ if (Convert.ToUInt32(textBoxArcNumber.Text) != 0)
+ {
+ if (!Validation.ValidateLength(textBoxArcSpacing, "Spacing", false) ||
+ !Validation.ValidateLength(textBoxArcFirstRadius, "Radius", false) ||
+ !Validation.ValidateLabel(textBoxArcFirstLabel, m_data.LabelsList))
+ {
+ return false;
+ }
+ }
+
+ if (Convert.ToUInt32(textBoxLineNumber.Text) != 0)
+ {
+ if (!Validation.ValidateLength(textBoxLineFirstDistance, "Distance", true) ||
+ !Validation.ValidateLabel(textBoxLineFirstLabel, m_data.LabelsList))
+ {
+ return false;
+ }
+ }
+
+ if (Convert.ToUInt32(textBoxArcNumber.Text) != 0 && Convert.ToUInt32(textBoxLineNumber.Text) != 0)
+ {
+ if (!Validation.ValidateLabels(textBoxArcFirstLabel, textBoxLineFirstLabel))
+ {
+ return false;
+ }
+ }
+
+ if (radioButtonCustomize.Checked)
+ {
+ if (!Validation.ValidateDegrees(textBoxStartDegree, textBoxEndDegree))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateRadialAndArcGridsForm.resx b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateRadialAndArcGridsForm.resx
new file mode 100644
index 00000000..ff31a6db
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateRadialAndArcGridsForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateWithSelectedCurvesForm.Designer.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateWithSelectedCurvesForm.Designer.cs
new file mode 100644
index 00000000..904e9240
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateWithSelectedCurvesForm.Designer.cs
@@ -0,0 +1,183 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ partial class CreateWithSelectedCurvesForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonOK = new System.Windows.Forms.Button();
+ this.textBoxFirstLabel = new System.Windows.Forms.TextBox();
+ this.comboBoxBubbleLocation = new System.Windows.Forms.ComboBox();
+ this.labelBubbleLocation = new System.Windows.Forms.Label();
+ this.labelFirstLabel = new System.Windows.Forms.Label();
+ this.groupBoxGridSettings = new System.Windows.Forms.GroupBox();
+ this.checkBoxDeleteElements = new System.Windows.Forms.CheckBox();
+ this.groupBoxGridSettings.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.buttonCancel.Location = new System.Drawing.Point(232, 144);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(90, 23);
+ this.buttonCancel.TabIndex = 1;
+ this.buttonCancel.Text = "&Cancel";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // buttonOK
+ //
+ this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.buttonOK.Location = new System.Drawing.Point(126, 144);
+ this.buttonOK.Name = "buttonOK";
+ this.buttonOK.Size = new System.Drawing.Size(90, 23);
+ this.buttonOK.TabIndex = 0;
+ this.buttonOK.Text = "Create &Grids";
+ this.buttonOK.UseVisualStyleBackColor = true;
+ this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
+ //
+ // textBoxFirstLabel
+ //
+ this.textBoxFirstLabel.Location = new System.Drawing.Point(124, 53);
+ this.textBoxFirstLabel.Name = "textBoxFirstLabel";
+ this.textBoxFirstLabel.Size = new System.Drawing.Size(171, 20);
+ this.textBoxFirstLabel.TabIndex = 1;
+ this.textBoxFirstLabel.Tag = "";
+ this.textBoxFirstLabel.Text = "1";
+ //
+ // comboBoxBubbleLocation
+ //
+ this.comboBoxBubbleLocation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBoxBubbleLocation.FormattingEnabled = true;
+ this.comboBoxBubbleLocation.Items.AddRange(new object[] {
+ "At start point of lines/arcs",
+ "At end point of lines/arcs"});
+ this.comboBoxBubbleLocation.Location = new System.Drawing.Point(124, 19);
+ this.comboBoxBubbleLocation.Name = "comboBoxBubbleLocation";
+ this.comboBoxBubbleLocation.Size = new System.Drawing.Size(171, 21);
+ this.comboBoxBubbleLocation.TabIndex = 0;
+ //
+ // labelBubbleLocation
+ //
+ this.labelBubbleLocation.Location = new System.Drawing.Point(6, 21);
+ this.labelBubbleLocation.Name = "labelBubbleLocation";
+ this.labelBubbleLocation.Size = new System.Drawing.Size(112, 19);
+ this.labelBubbleLocation.TabIndex = 16;
+ this.labelBubbleLocation.Text = "Bubble location:";
+ //
+ // labelFirstLabel
+ //
+ this.labelFirstLabel.Location = new System.Drawing.Point(6, 56);
+ this.labelFirstLabel.Name = "labelFirstLabel";
+ this.labelFirstLabel.Size = new System.Drawing.Size(112, 19);
+ this.labelFirstLabel.TabIndex = 15;
+ this.labelFirstLabel.Text = "Label of first grid:";
+ //
+ // groupBoxGridSettings
+ //
+ this.groupBoxGridSettings.Controls.Add(this.checkBoxDeleteElements);
+ this.groupBoxGridSettings.Controls.Add(this.labelBubbleLocation);
+ this.groupBoxGridSettings.Controls.Add(this.textBoxFirstLabel);
+ this.groupBoxGridSettings.Controls.Add(this.labelFirstLabel);
+ this.groupBoxGridSettings.Controls.Add(this.comboBoxBubbleLocation);
+ this.groupBoxGridSettings.Location = new System.Drawing.Point(12, 12);
+ this.groupBoxGridSettings.Name = "groupBoxGridSettings";
+ this.groupBoxGridSettings.Size = new System.Drawing.Size(310, 113);
+ this.groupBoxGridSettings.TabIndex = 18;
+ this.groupBoxGridSettings.TabStop = false;
+ this.groupBoxGridSettings.Text = "Settings";
+ //
+ // checkBoxDeleteElements
+ //
+ this.checkBoxDeleteElements.AutoSize = true;
+ this.checkBoxDeleteElements.Checked = true;
+ this.checkBoxDeleteElements.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.checkBoxDeleteElements.Location = new System.Drawing.Point(9, 87);
+ this.checkBoxDeleteElements.Name = "checkBoxDeleteElements";
+ this.checkBoxDeleteElements.Size = new System.Drawing.Size(232, 17);
+ this.checkBoxDeleteElements.TabIndex = 2;
+ this.checkBoxDeleteElements.Text = "Delete the selected lines/arcs after creation";
+ this.checkBoxDeleteElements.UseVisualStyleBackColor = true;
+ //
+ // CreateWithSelectedCurvesForm
+ //
+ this.AcceptButton = this.buttonOK;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.CancelButton = this.buttonCancel;
+ this.ClientSize = new System.Drawing.Size(334, 177);
+ this.Controls.Add(this.groupBoxGridSettings);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonOK);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "CreateWithSelectedCurvesForm";
+ this.ShowIcon = false;
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Create Grids with Lines/Arcs";
+ this.groupBoxGridSettings.ResumeLayout(false);
+ this.groupBoxGridSettings.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button buttonCancel;
+ private System.Windows.Forms.Button buttonOK;
+ private System.Windows.Forms.TextBox textBoxFirstLabel;
+ private System.Windows.Forms.ComboBox comboBoxBubbleLocation;
+ private System.Windows.Forms.Label labelBubbleLocation;
+ private System.Windows.Forms.Label labelFirstLabel;
+ private System.Windows.Forms.GroupBox groupBoxGridSettings;
+ private System.Windows.Forms.CheckBox checkBoxDeleteElements;
+ }
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateWithSelectedCurvesForm.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateWithSelectedCurvesForm.cs
new file mode 100644
index 00000000..18057bb8
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateWithSelectedCurvesForm.cs
@@ -0,0 +1,95 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ ///
+ /// The dialog which provides the options of creating grids with selected lines/arcs
+ ///
+ public partial class CreateWithSelectedCurvesForm : Form
+ {
+ // data class object
+ private CreateWithSelectedCurvesData m_data;
+
+ ///
+ /// Constructor
+ ///
+ /// Data class object
+ public CreateWithSelectedCurvesForm(CreateWithSelectedCurvesData data)
+ {
+ m_data = data;
+
+ InitializeComponent();
+ // Set state of controls
+ InitializeControls();
+ }
+
+ ///
+ /// Set state of controls
+ ///
+ private void InitializeControls()
+ {
+ comboBoxBubbleLocation.SelectedIndex = 1;
+ }
+
+ private void buttonOK_Click(object sender, EventArgs e)
+ {
+ // Check if input are validated
+ if (ValidateValues())
+ {
+ // Transfer data back into data class
+ SetData();
+ }
+ else
+ {
+ this.DialogResult = DialogResult.None;
+ }
+ }
+
+ ///
+ /// Check if input are validated
+ ///
+ /// Whether input is validated
+ private bool ValidateValues()
+ {
+ return Validation.ValidateLabel(textBoxFirstLabel, m_data.LabelsList);
+ }
+
+ ///
+ /// Transfer data back into data class
+ ///
+ private void SetData()
+ {
+ m_data.BubbleLocation = (BubbleLocation)comboBoxBubbleLocation.SelectedIndex;
+ m_data.FirstLabel = textBoxFirstLabel.Text;
+ m_data.DeleteSelectedElements = checkBoxDeleteElements.Checked;
+ }
+ }
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateWithSelectedCurvesForm.resx b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateWithSelectedCurvesForm.resx
new file mode 100644
index 00000000..ff31a6db
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateWithSelectedCurvesForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateWithSeletedCurvesData.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateWithSeletedCurvesData.cs
new file mode 100644
index 00000000..3466b036
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/CreateWithSeletedCurvesData.cs
@@ -0,0 +1,386 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Collections;
+using System.Windows.Forms;
+
+using Autodesk.Revit;
+using Autodesk.Revit.DB;
+
+using Autodesk.Revit.UI;
+using Autodesk.Revit.UI.Macros;
+
+using MacroCSharpSamples;
+using Application = Autodesk.Revit.ApplicationServices.Application;
+using SamplePropertis = MacroCSharpSamples.GridCreation.GridCreationProperties;
+using MacroSamples_RVT;
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ ///
+ /// The dialog which provides the options of creating grids with selected lines/arcs
+ ///
+ public class CreateWithSelectedCurvesData
+ {
+ #region Fields
+ // Selected curves in current document
+ private CurveArray? m_selectedCurves;
+ // Whether to delete selected lines/arc after creation
+ private bool m_deleteSelectedElements;
+ // Label of first grid
+ private String m_firstLabel = string.Empty;
+ // Bubble location of grids
+ private BubbleLocation m_bubbleLocation;
+ // Array list contains all grid labels in current document
+ private ArrayList m_labelsList;
+ // Revit application
+ private ThisApplication? m_thisApp;
+ private Application? m_revit;
+ #endregion
+
+ #region Properties
+ ///
+ /// Whether to delete selected lines/arc after creation
+ ///
+ public bool DeleteSelectedElements
+ {
+ get
+ {
+ return m_deleteSelectedElements;
+ }
+ set
+ {
+ m_deleteSelectedElements = value;
+ }
+ }
+
+ ///
+ /// Bubble location of grids
+ ///
+ public BubbleLocation BubbleLocation
+ {
+ get
+ {
+ return m_bubbleLocation;
+ }
+ set
+ {
+ m_bubbleLocation = value;
+ }
+ }
+
+ ///
+ /// Label of first grid
+ ///
+ public String FirstLabel
+ {
+ get
+ {
+ return m_firstLabel;
+ }
+ set
+ {
+ m_firstLabel = value;
+ }
+ }
+
+ ///
+ /// Get array list contains all grid labels in current document
+ ///
+ public ArrayList LabelsList
+ {
+ get
+ {
+ return m_labelsList;
+ }
+ }
+ #endregion
+
+ #region Methods
+ ///
+ /// Constructor
+ ///
+ /// Revit application
+ /// Array contains geometry curves of selected lines or arcs
+ /// List contains all existing labels in Revit document
+ public CreateWithSelectedCurvesData(ThisApplication? thisApp, CurveArray? selectedCurves, ArrayList labels)
+ {
+ m_thisApp = thisApp;
+ m_revit = thisApp?.ActiveUIDocument.Document.Application;
+
+ m_selectedCurves = selectedCurves;
+ m_labelsList = labels;
+ }
+
+ ///
+ /// Create grids
+ ///
+ public void CreateGrids()
+ {
+ int errorCount = 0;
+
+ int i = 0;
+ if (m_selectedCurves != null)
+ {
+ foreach (Curve curve in m_selectedCurves)
+ {
+ try
+ {
+ Line? line = curve as Line;
+ if (line != null) // Selected curve is a line
+ {
+ Grid grid;
+ // Create linear grid
+ grid = CreateLinearGrid(line);
+
+ // Set label of first grid
+ if (i == 0 && grid != null)
+ {
+ try
+ {
+ grid.Name = m_firstLabel;
+ }
+ catch (System.ArgumentException)
+ {
+ MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_firstLabel + "!",
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ }
+ }
+ else // Selected curve is an arc
+ {
+ Arc? arc = curve as Arc;
+ if (arc != null)
+ {
+ if (arc.IsBound) // Part of a circle
+ {
+ Grid grid;
+ // Create arc grid
+ grid = CreateArcGrid(arc);
+
+ // Set label of first grid
+ if (i == 0 && grid != null)
+ {
+ try
+ {
+ grid.Name = m_firstLabel;
+ }
+ catch (System.ArgumentException)
+ {
+ MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_firstLabel + "!",
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ }
+ }
+ else // Arc is a circle
+ {
+ // In Revit UI user can select a circle to create a grid, but actually two grids
+ // (One from 0 to 180 degree and the other from 180 degree to 360) will be created.
+ // In RevitAPI using NewGrid method with a circle as its argument will raise an exception.
+ // Therefore in this sample we will create two arcs from the upper and lower parts of the
+ // circle, and then create two grids on the base of the two arcs to accord with UI.
+ Grid? gridUpper = null;
+ Grid? gridLower = null;
+ bool isFirstGrid = (i == 0);
+ // Create grids
+ CreateGridsForCircle(arc, ref gridUpper, ref gridLower, isFirstGrid);
+ }
+ }
+ }
+ }
+ catch (Exception)
+ {
+ ++errorCount;
+ continue;
+ }
+
+ ++i;
+ }
+ }
+
+
+ if (m_deleteSelectedElements)
+ {
+ try
+ {
+ m_thisApp?.ActiveUIDocument.Document.Delete(GridCreation.GetSelectedModelLinesAndArcs(m_thisApp));
+ }
+ catch (Exception)
+ {
+ MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToDeletedLinesOrArcs"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionDeletedLinesOrArcs"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ }
+
+ if (errorCount != 0)
+ {
+ MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToCreateGrids"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionCreateGrids"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ }
+
+ ///
+ /// Create two grids if the selected curve is a circle
+ ///
+ /// The circular curve to be transferred to grid
+ /// The grid to be created base on the upper part of the circular curve
+ /// The grid to be created base on the lower part of the circular curve
+ /// Whether the circular curve is the first curve to be transferred
+ private void CreateGridsForCircle(Arc arc, ref Grid? gridUpper, ref Grid? gridLower, bool isFirst)
+ {
+ XYZ center = arc.Center;
+ double radius = arc.Radius;
+
+ XYZ? XRightPoint = m_revit?.Create.NewXYZ(center.X + radius, center.Y, 0);
+ XYZ? XLeftPoint = m_revit?.Create.NewXYZ(center.X - radius, center.Y, 0);
+ XYZ? YUpperPoint = m_revit?.Create.NewXYZ(center.X, center.Y + radius, 0);
+ XYZ? YLowerPoint = m_revit?.Create.NewXYZ(center.X, center.Y - radius, 0);
+ Arc upperArc;
+ Arc lowerArc;
+ if (m_bubbleLocation == BubbleLocation.StartPoint)
+ {
+ upperArc = Arc.Create(XRightPoint, XLeftPoint, YUpperPoint);
+ lowerArc = Arc.Create(XLeftPoint, XRightPoint, YLowerPoint);
+ }
+ else
+ {
+ upperArc = Arc.Create(XLeftPoint, XRightPoint, YUpperPoint);
+ lowerArc = Arc.Create(XRightPoint, XLeftPoint, YLowerPoint);
+ }
+
+ // Create arc grids
+ gridUpper = Grid.Create(m_thisApp?.ActiveUIDocument.Document, upperArc);
+ gridLower = Grid.Create(m_thisApp?.ActiveUIDocument.Document, lowerArc);
+
+ if (gridUpper != null && isFirst)
+ {
+ try
+ {
+ gridUpper.Name = m_firstLabel;
+ }
+ catch (System.ArgumentException)
+ {
+ MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_firstLabel + "!",
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ }
+ }
+
+ ///
+ /// Create arc grid
+ ///
+ /// The arc curve to be transferred to grid
+ /// The newly created grid
+ private Grid CreateArcGrid(Arc arc)
+ {
+ Grid grid;
+
+ if (m_bubbleLocation == BubbleLocation.StartPoint)
+ {
+ grid = Grid.Create(m_thisApp?.ActiveUIDocument.Document, arc);
+ }
+ else
+ {
+ // Get start point, end point of the arc and the middle point on it
+ XYZ startPoint = arc.GetEndPoint(0);
+ XYZ endPoint = arc.GetEndPoint(1);
+ bool clockwise = (arc.Normal.Z == -1);
+
+ // Get start angel and end angel of arc
+ double startDegree = arc.GetEndParameter(0);
+ double endDegree = arc.GetEndParameter(1);
+
+ // Handle the case that the arc is clockwise
+ if (clockwise && startDegree > 0 && endDegree > 0)
+ {
+ startDegree = 2 * Values.PI - startDegree;
+ endDegree = 2 * Values.PI - endDegree;
+ }
+ else if (clockwise && startDegree < 0)
+ {
+ double temp = endDegree;
+ endDegree = -1 * startDegree;
+ startDegree = -1 * temp;
+ }
+
+ double sumDegree = (startDegree + endDegree) / 2;
+ while (sumDegree > 2 * Values.PI)
+ {
+ sumDegree -= 2 * Values.PI;
+ }
+
+ while (sumDegree < -2 * Values.PI)
+ {
+ sumDegree += 2 * Values.PI;
+ }
+
+ XYZ? midPoint = m_revit?.Create.NewXYZ(arc.Center.X + arc.Radius * Math.Cos(sumDegree),
+ arc.Center.Y + arc.Radius * Math.Sin(sumDegree), 0);
+ Arc reversedArc = Arc.Create(endPoint, startPoint, midPoint);
+
+ //Create grid
+ grid = Grid.Create(m_thisApp?.ActiveUIDocument.Document, reversedArc);
+ }
+
+ return grid;
+ }
+
+ ///
+ /// Create linear grid
+ ///
+ /// The linear curve to be transferred to grid
+ /// The newly created grid
+ private Grid CreateLinearGrid(Line line)
+ {
+ Grid grid;
+
+ // Create grid according to the bubble location
+ if (m_bubbleLocation == BubbleLocation.StartPoint)
+ {
+ grid = Grid.Create(m_thisApp?.ActiveUIDocument.Document, line);
+ }
+ else
+ {
+ XYZ startPoint = line.GetEndPoint(1);
+ XYZ endPoint = line.GetEndPoint(0);
+ Line reversedLine = Line.CreateBound(startPoint, endPoint);
+ grid = Grid.Create(m_thisApp?.ActiveUIDocument.Document, reversedLine);
+ }
+
+ return grid;
+ }
+ #endregion
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/EnumsAndValues.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/EnumsAndValues.cs
new file mode 100644
index 00000000..c3d0c6ec
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/EnumsAndValues.cs
@@ -0,0 +1,72 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ ///
+ /// An enumerate type listing the ways to create grids.
+ ///
+ public enum CreateMode
+ {
+ ///
+ /// Create grids with selected lines/arcs
+ ///
+ Select,
+ ///
+ /// Create orthogonal grids
+ ///
+ Orthogonal,
+ ///
+ /// Create radial and arc grids
+ ///
+ RadialAndArc
+ }
+
+ ///
+ /// An enumerate type listing bubble locations of grids.
+ ///
+ public enum BubbleLocation
+ {
+ ///
+ /// Place bubble at the start point
+ ///
+ StartPoint,
+ ///
+ /// Place bubble at the end point
+ ///
+ EndPoint
+ }
+
+ ///
+ /// Class contains common const values
+ ///
+ static class Values
+ {
+ public const double PI = 3.1415926535897900;
+ // ratio from degree to radian
+ public const double DEGTORAD = PI / 180;
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreation.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreation.cs
new file mode 100644
index 00000000..fc68d598
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreation.cs
@@ -0,0 +1,247 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Windows.Forms;
+using System.Collections;
+using System.Collections.Generic;
+
+using Autodesk.Revit;
+using Autodesk.Revit.DB;
+
+using Application = Autodesk.Revit.ApplicationServices.Application;
+using Element = Autodesk.Revit.DB.Element;
+
+using SamplePropertis = MacroCSharpSamples.GridCreation.GridCreationProperties;
+
+using MacroCSharpSamples;
+using System.Diagnostics;
+using MacroSamples_RVT;
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ ///
+ /// Implements the Revit add-in interface IExternalCommand
+ ///
+ public class GridCreation
+ {
+ #region
+ ThisApplication? m_app;
+ #endregion
+
+ ///
+ /// Default constructor without parameter is not allowed
+ ///
+ private GridCreation()
+ {
+ }
+
+ ///
+ /// GridCreation init
+ ///
+ ///
+ public GridCreation(ThisApplication App)
+ {
+ m_app = App;
+ }
+
+ ///
+ /// Run this sample now
+ ///
+ public void Run()
+ {
+ try
+ {
+ Document? document = m_app?.ActiveUIDocument.Document;
+
+ // Get all selected lines and arcs
+ CurveArray? selectedCurves = GetSelectedCurves(m_app);
+
+ // Show UI
+ GridCreationOptionData? gridCreationOption = new GridCreationOptionData(selectedCurves == null || selectedCurves.IsEmpty);
+ using (GridCreationOptionForm gridCreationOptForm = new GridCreationOptionForm(gridCreationOption))
+ {
+ DialogResult result = gridCreationOptForm.ShowDialog();
+ if (result == DialogResult.Cancel)
+ {
+ return;
+ }
+
+ ArrayList labels = GetAllLabelsOfGrids(document);
+ ForgeTypeId? dut = GetLengthUnitType(document);
+ switch (gridCreationOption.CreateGridsMode)
+ {
+ case CreateMode.Select: // Create grids with selected lines/arcs
+ CreateWithSelectedCurvesData data = new CreateWithSelectedCurvesData(m_app, selectedCurves, labels);
+ using (CreateWithSelectedCurvesForm createWithSelected = new CreateWithSelectedCurvesForm(data))
+ {
+ result = createWithSelected.ShowDialog();
+ if (result == DialogResult.OK)
+ {
+ // Create grids
+ data.CreateGrids();
+ }
+ }
+ break;
+
+ case CreateMode.Orthogonal: // Create orthogonal grids
+ CreateOrthogonalGridsData orthogonalData = new CreateOrthogonalGridsData(m_app, dut, labels);
+ using (CreateOrthogonalGridsForm orthogonalGridForm = new CreateOrthogonalGridsForm(orthogonalData))
+ {
+ result = orthogonalGridForm.ShowDialog();
+ if (result == DialogResult.OK)
+ {
+ // Create grids
+ orthogonalData.CreateGrids();
+ }
+ }
+ break;
+
+ case CreateMode.RadialAndArc: // Create radial and arc grids
+ CreateRadialAndArcGridsData radArcData = new CreateRadialAndArcGridsData(m_app, dut, labels);
+ using (CreateRadialAndArcGridsForm radArcForm = new CreateRadialAndArcGridsForm(radArcData))
+ {
+ result = radArcForm.ShowDialog();
+ if (result == DialogResult.OK)
+ {
+ // Create grids
+ radArcData.CreateGrids();
+ }
+ }
+ break;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ }
+
+ ///
+ /// Get all selected lines and arcs
+ ///
+ /// Revit's document
+ /// CurveArray contains all selected lines and arcs
+ private CurveArray? GetSelectedCurves(ThisApplication? document)
+ {
+ CurveArray? selectedCurves = m_app?.ActiveUIDocument.Document.Application.Create.NewCurveArray();
+ ICollection? elements = document?.ActiveUIDocument.Selection.GetElementIds();
+ if (elements == null)
+ {
+ return null;
+ }
+ foreach (Autodesk.Revit.DB.ElementId elementId in elements)
+ {
+ Element? element = document?.ActiveUIDocument.Document.GetElement(elementId);
+ if ((element is ModelLine) || (element is ModelArc))
+ {
+ ModelCurve? modelCurve = element as ModelCurve;
+ Curve? curve = modelCurve?.GeometryCurve;
+ if (curve != null)
+ {
+ selectedCurves?.Append(curve);
+ }
+ }
+ else if ((element is DetailLine) || (element is DetailArc))
+ {
+ DetailCurve? detailCurve = element as DetailCurve;
+ Curve? curve = detailCurve?.GeometryCurve;
+ if (curve != null)
+ {
+ selectedCurves?.Append(curve);
+ }
+ }
+ }
+
+ return selectedCurves;
+ }
+
+ ///
+ /// Get all model and detail lines/arcs within selected elements
+ ///
+ /// Revit's document
+ /// ElementSet contains all model and detail lines/arcs within selected elements
+ public static ICollection GetSelectedModelLinesAndArcs(ThisApplication thisDocument)
+ {
+ var tmpIds = new List();
+ ICollection elements = thisDocument.ActiveUIDocument.Selection.GetElementIds();
+ foreach (ElementId id in elements)
+ {
+ Element element = thisDocument.ActiveUIDocument.Document.GetElement(id);
+ if ((element is ModelLine) || (element is ModelArc) || (element is DetailLine) || (element is DetailArc))
+ {
+ tmpIds.Add(element.Id);
+ }
+ }
+
+ return tmpIds;
+ }
+
+ ///
+ /// Get current length display unit type
+ ///
+ /// Revit's document
+ /// Current length display unit type
+ private static ForgeTypeId? GetLengthUnitType(Document? document)
+ {
+ ForgeTypeId specTypeId = SpecTypeId.Length;
+ Units? projectUnit = document?.GetUnits();
+ try
+ {
+ Autodesk.Revit.DB.FormatOptions? formatOption = projectUnit?.GetFormatOptions(specTypeId);
+ return formatOption?.GetUnitTypeId();
+ }
+ catch (System.Exception /*e*/)
+ {
+ return UnitTypeId.Feet;
+ }
+ }
+
+ ///
+ /// Get all grid labels in current document
+ ///
+ /// Revit's document
+ /// ArrayList contains all grid labels in current document
+ private static ArrayList GetAllLabelsOfGrids(Document? document)
+ {
+ ArrayList labels = new ArrayList();
+
+ ElementClassFilter gridFilter = new ElementClassFilter(typeof(Grid));
+ FilteredElementCollector collector = new FilteredElementCollector(document);
+ collector.WherePasses(gridFilter);
+ FilteredElementIterator iter = collector.GetElementIterator();
+
+ iter.Reset();
+ while (iter.MoveNext())
+ {
+ Grid? grid = iter.Current as Grid;
+ if (null != grid)
+ {
+ labels.Add(grid.Name);
+ }
+ }
+ return labels;
+ }
+ }
+}
+
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationOptionData.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationOptionData.cs
new file mode 100644
index 00000000..19626a21
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationOptionData.cs
@@ -0,0 +1,83 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using Autodesk.Revit;
+using Autodesk.Revit.DB;
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ ///
+ /// Data class which stores the information of the way to create grids
+ ///
+ public class GridCreationOptionData
+ {
+ #region Fields
+ // The way to create grids
+ private CreateMode m_createGridsMode;
+ // If lines/arcs have been selected
+ private bool m_hasSelectedLinesOrArcs;
+ #endregion
+
+ #region Properties
+ ///
+ /// Creating mode
+ ///
+ public CreateMode CreateGridsMode
+ {
+ get
+ {
+ return m_createGridsMode;
+ }
+ set
+ {
+ m_createGridsMode = value;
+ }
+ }
+
+ ///
+ /// State whether lines/arcs have been selected
+ ///
+ public bool HasSelectedLinesOrArcs
+ {
+ get
+ {
+ return m_hasSelectedLinesOrArcs;
+ }
+ }
+ #endregion
+
+ #region Methods
+ ///
+ /// Constructor
+ ///
+ /// Whether lines or arcs have been selected
+ public GridCreationOptionData(bool hasSelectedLinesOrArcs)
+ {
+ m_hasSelectedLinesOrArcs = hasSelectedLinesOrArcs;
+ }
+ #endregion
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationOptionForm.Designer.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationOptionForm.Designer.cs
new file mode 100644
index 00000000..5462cf4c
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationOptionForm.Designer.cs
@@ -0,0 +1,160 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ partial class GridCreationOptionForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.radioButtonSelect = new System.Windows.Forms.RadioButton();
+ this.radioButtonRadialAndCircularGrids = new System.Windows.Forms.RadioButton();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonOK = new System.Windows.Forms.Button();
+ this.groupBoxCreateOptions = new System.Windows.Forms.GroupBox();
+ this.radioButtonOrthogonalGrids = new System.Windows.Forms.RadioButton();
+ this.groupBoxCreateOptions.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // radioButtonSelect
+ //
+ this.radioButtonSelect.AutoSize = true;
+ this.radioButtonSelect.Checked = true;
+ this.radioButtonSelect.Location = new System.Drawing.Point(6, 19);
+ this.radioButtonSelect.Name = "radioButtonSelect";
+ this.radioButtonSelect.Size = new System.Drawing.Size(205, 17);
+ this.radioButtonSelect.TabIndex = 0;
+ this.radioButtonSelect.TabStop = true;
+ this.radioButtonSelect.Text = "Create grids with selected lines or arcs";
+ this.radioButtonSelect.UseVisualStyleBackColor = true;
+ //
+ // radioButtonRadialAndCircularGrids
+ //
+ this.radioButtonRadialAndCircularGrids.AutoSize = true;
+ this.radioButtonRadialAndCircularGrids.Location = new System.Drawing.Point(6, 69);
+ this.radioButtonRadialAndCircularGrids.Name = "radioButtonRadialAndCircularGrids";
+ this.radioButtonRadialAndCircularGrids.Size = new System.Drawing.Size(199, 17);
+ this.radioButtonRadialAndCircularGrids.TabIndex = 2;
+ this.radioButtonRadialAndCircularGrids.Text = "Create a batch of radial and arc grids";
+ this.radioButtonRadialAndCircularGrids.UseVisualStyleBackColor = true;
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.buttonCancel.Location = new System.Drawing.Point(159, 129);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(90, 23);
+ this.buttonCancel.TabIndex = 1;
+ this.buttonCancel.Text = "&Cancel";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // buttonOK
+ //
+ this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.buttonOK.Location = new System.Drawing.Point(58, 129);
+ this.buttonOK.Name = "buttonOK";
+ this.buttonOK.Size = new System.Drawing.Size(90, 23);
+ this.buttonOK.TabIndex = 0;
+ this.buttonOK.Text = "&OK";
+ this.buttonOK.UseVisualStyleBackColor = true;
+ this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
+ //
+ // groupBoxCreateOptions
+ //
+ this.groupBoxCreateOptions.Controls.Add(this.radioButtonSelect);
+ this.groupBoxCreateOptions.Controls.Add(this.radioButtonOrthogonalGrids);
+ this.groupBoxCreateOptions.Controls.Add(this.radioButtonRadialAndCircularGrids);
+ this.groupBoxCreateOptions.Location = new System.Drawing.Point(12, 12);
+ this.groupBoxCreateOptions.Name = "groupBoxCreateOptions";
+ this.groupBoxCreateOptions.Size = new System.Drawing.Size(237, 96);
+ this.groupBoxCreateOptions.TabIndex = 13;
+ this.groupBoxCreateOptions.TabStop = false;
+ this.groupBoxCreateOptions.Text = "Choose the way to create grids";
+ //
+ // radioButtonOrthogonalGrids
+ //
+ this.radioButtonOrthogonalGrids.AutoSize = true;
+ this.radioButtonOrthogonalGrids.Location = new System.Drawing.Point(6, 44);
+ this.radioButtonOrthogonalGrids.Name = "radioButtonOrthogonalGrids";
+ this.radioButtonOrthogonalGrids.Size = new System.Drawing.Size(185, 17);
+ this.radioButtonOrthogonalGrids.TabIndex = 1;
+ this.radioButtonOrthogonalGrids.Text = "Create a batch of orthogonal grids";
+ this.radioButtonOrthogonalGrids.UseVisualStyleBackColor = true;
+ //
+ // GridCreationOptionForm
+ //
+ this.AcceptButton = this.buttonOK;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.CancelButton = this.buttonCancel;
+ this.ClientSize = new System.Drawing.Size(265, 164);
+ this.Controls.Add(this.groupBoxCreateOptions);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonOK);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "GridCreationOptionForm";
+ this.ShowIcon = false;
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Grid Creation";
+ this.groupBoxCreateOptions.ResumeLayout(false);
+ this.groupBoxCreateOptions.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.RadioButton radioButtonSelect;
+ private System.Windows.Forms.RadioButton radioButtonRadialAndCircularGrids;
+ private System.Windows.Forms.Button buttonCancel;
+ private System.Windows.Forms.Button buttonOK;
+ private System.Windows.Forms.GroupBox groupBoxCreateOptions;
+ private System.Windows.Forms.RadioButton radioButtonOrthogonalGrids;
+ }
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationOptionForm.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationOptionForm.cs
new file mode 100644
index 00000000..a6dbd1d4
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationOptionForm.cs
@@ -0,0 +1,81 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ ///
+ /// The dialog which lets user choose the way to create grids
+ ///
+ public partial class GridCreationOptionForm : Form
+ {
+ // data class object
+ private GridCreationOptionData m_gridCreationOption;
+
+ ///
+ /// Constructor
+ ///
+ /// Data class object
+ public GridCreationOptionForm(GridCreationOptionData opt)
+ {
+ m_gridCreationOption = opt;
+
+ InitializeComponent();
+ // Set state of controls
+ InitializeControls();
+ }
+
+ ///
+ /// Set state of controls
+ ///
+ private void InitializeControls()
+ {
+ if (!m_gridCreationOption.HasSelectedLinesOrArcs)
+ {
+ radioButtonSelect.Enabled = false;
+ radioButtonOrthogonalGrids.Checked = true;
+ }
+ }
+
+ private void buttonOK_Click(object sender, EventArgs e)
+ {
+ // Transfer data back into data class
+ SetData();
+ }
+
+ ///
+ /// Transfer data back into data class
+ ///
+ private void SetData()
+ {
+ m_gridCreationOption.CreateGridsMode = radioButtonSelect.Checked ? CreateMode.Select :
+ (radioButtonOrthogonalGrids.Checked ? CreateMode.Orthogonal : CreateMode.RadialAndArc);
+ }
+ }
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationOptionForm.resx b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationOptionForm.resx
new file mode 100644
index 00000000..ff31a6db
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationOptionForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationProperties/GridCreationResources.Designer.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationProperties/GridCreationResources.Designer.cs
new file mode 100644
index 00000000..ca053c5e
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationProperties/GridCreationResources.Designer.cs
@@ -0,0 +1,567 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.832
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace MacroCSharpSamples.GridCreation.GridCreationProperties
+{
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class GridCreationResources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal GridCreationResources()
+ {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if (object.ReferenceEquals(resourceMan, null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MacroCSharpSamples.GridCreation.GridCreationProperties.GridCreationResources", typeof(GridCreationResources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Please adjust the values and try again!.
+ ///
+ internal static string AjustValues
+ {
+ get
+ {
+ return ResourceManager.GetString("AjustValues", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Coordinate can not be null!.
+ ///
+ internal static string CoordinateCannotBeNull
+ {
+ get
+ {
+ return ResourceManager.GetString("CoordinateCannotBeNull", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Coordinate is not in a correct format!.
+ ///
+ internal static string CoordinateFormatWrong
+ {
+ get
+ {
+ return ResourceManager.GetString("CoordinateFormatWrong", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Degree can not be negative!.
+ ///
+ internal static string DegreeCannotBeNegative
+ {
+ get
+ {
+ return ResourceManager.GetString("DegreeCannotBeNegative", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Degree can not be null!.
+ ///
+ internal static string DegreeCannotBeNull
+ {
+ get
+ {
+ return ResourceManager.GetString("DegreeCannotBeNull", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Degree is not in a correct format!.
+ ///
+ internal static string DegreeFormatWrong
+ {
+ get
+ {
+ return ResourceManager.GetString("DegreeFormatWrong", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Start degree and end degree can not be so close!.
+ ///
+ internal static string DegreesAreTooClose
+ {
+ get
+ {
+ return ResourceManager.GetString("DegreesAreTooClose", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Degree should be within the range of 0 - 360!.
+ ///
+ internal static string DegreeWithin0To360
+ {
+ get
+ {
+ return ResourceManager.GetString("DegreeWithin0To360", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Distance can not be negative!.
+ ///
+ internal static string DistanceCannotBeNegative
+ {
+ get
+ {
+ return ResourceManager.GetString("DistanceCannotBeNegative", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Distance can not be null!.
+ ///
+ internal static string DistanceCannotBeNull
+ {
+ get
+ {
+ return ResourceManager.GetString("DistanceCannotBeNull", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Distance is not in a correct format!.
+ ///
+ internal static string DistanceFormatWrong
+ {
+ get
+ {
+ return ResourceManager.GetString("DistanceFormatWrong", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to cm.
+ ///
+ internal static string DUT_CENTIMETERS
+ {
+ get
+ {
+ return ResourceManager.GetString("DUT_CENTIMETERS", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to '.
+ ///
+ internal static string DUT_DECIMAL_FEET
+ {
+ get
+ {
+ return ResourceManager.GetString("DUT_DECIMAL_FEET", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to ".
+ ///
+ internal static string DUT_DECIMAL_INCHES
+ {
+ get
+ {
+ return ResourceManager.GetString("DUT_DECIMAL_INCHES", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to '.
+ ///
+ internal static string DUT_FEET_FRACTIONAL_INCHES
+ {
+ get
+ {
+ return ResourceManager.GetString("DUT_FEET_FRACTIONAL_INCHES", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to ".
+ ///
+ internal static string DUT_FRACTIONAL_INCHES
+ {
+ get
+ {
+ return ResourceManager.GetString("DUT_FRACTIONAL_INCHES", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to m.
+ ///
+ internal static string DUT_METERS
+ {
+ get
+ {
+ return ResourceManager.GetString("DUT_METERS", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to m.
+ ///
+ internal static string DUT_METERS_CENTIMETERS
+ {
+ get
+ {
+ return ResourceManager.GetString("DUT_METERS_CENTIMETERS", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to mm.
+ ///
+ internal static string DUT_MILLIMETERS
+ {
+ get
+ {
+ return ResourceManager.GetString("DUT_MILLIMETERS", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to - Start point and end point of arc grids are too close.
+ ///
+ internal static string EndPointsTooClose
+ {
+ get
+ {
+ return ResourceManager.GetString("EndPointsTooClose", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to create one or more arc grids..
+ ///
+ internal static string FailedToCreateArcGrids
+ {
+ get
+ {
+ return ResourceManager.GetString("FailedToCreateArcGrids", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to create one or more grids. .
+ ///
+ internal static string FailedToCreateGrids
+ {
+ get
+ {
+ return ResourceManager.GetString("FailedToCreateGrids", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to create one or more radial grids. .
+ ///
+ internal static string FailedToCreateRadialGrids
+ {
+ get
+ {
+ return ResourceManager.GetString("FailedToCreateRadialGrids", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to delete some of the selected lines or arcs!.
+ ///
+ internal static string FailedToDeletedLinesOrArcs
+ {
+ get
+ {
+ return ResourceManager.GetString("FailedToDeletedLinesOrArcs", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to set label of grid to : .
+ ///
+ internal static string FailedToSetLabel
+ {
+ get
+ {
+ return ResourceManager.GetString("FailedToSetLabel", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to Create Grids.
+ ///
+ internal static string FailureCaptionCreateGrids
+ {
+ get
+ {
+ return ResourceManager.GetString("FailureCaptionCreateGrids", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to Delete Lines/Arcs.
+ ///
+ internal static string FailureCaptionDeletedLinesOrArcs
+ {
+ get
+ {
+ return ResourceManager.GetString("FailureCaptionDeletedLinesOrArcs", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Invalid Value.
+ ///
+ internal static string FailureCaptionInvalidValue
+ {
+ get
+ {
+ return ResourceManager.GetString("FailureCaptionInvalidValue", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to Set Label.
+ ///
+ internal static string FailureCaptionSetLabel
+ {
+ get
+ {
+ return ResourceManager.GetString("FailureCaptionSetLabel", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Label can not be null!.
+ ///
+ internal static string LabelCannotBeNull
+ {
+ get
+ {
+ return ResourceManager.GetString("LabelCannotBeNull", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to A same label has already existed!.
+ ///
+ internal static string LabelExisted
+ {
+ get
+ {
+ return ResourceManager.GetString("LabelExisted", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to The two labels can't be same!.
+ ///
+ internal static string LabelsCannotBeSame
+ {
+ get
+ {
+ return ResourceManager.GetString("LabelsCannotBeSame", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Number should be an integer between 0 and 200!.
+ ///
+ internal static string NumberBetween0And200
+ {
+ get
+ {
+ return ResourceManager.GetString("NumberBetween0And200", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Number can not be null!.
+ ///
+ internal static string NumberCannotBeNull
+ {
+ get
+ {
+ return ResourceManager.GetString("NumberCannotBeNull", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Number is not in a correct format!.
+ ///
+ internal static string NumberFormatWrong
+ {
+ get
+ {
+ return ResourceManager.GetString("NumberFormatWrong", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to The two numbers can not be both zero!.
+ ///
+ internal static string NumbersCannotBeBothZero
+ {
+ get
+ {
+ return ResourceManager.GetString("NumbersCannotBeBothZero", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Radius can not be negative or zero!.
+ ///
+ internal static string RadiusCannotBeNegativeOrZero
+ {
+ get
+ {
+ return ResourceManager.GetString("RadiusCannotBeNegativeOrZero", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Radius can not be null!.
+ ///
+ internal static string RadiusCannotBeNull
+ {
+ get
+ {
+ return ResourceManager.GetString("RadiusCannotBeNull", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Radius is not in a correct format!.
+ ///
+ internal static string RadiusFormatWrong
+ {
+ get
+ {
+ return ResourceManager.GetString("RadiusFormatWrong", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to That may be caused by one or more of following reasons:.
+ ///
+ internal static string Reasons
+ {
+ get
+ {
+ return ResourceManager.GetString("Reasons", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Spacing can not be negative or zero!.
+ ///
+ internal static string SpacingCannotBeNegativeOrZero
+ {
+ get
+ {
+ return ResourceManager.GetString("SpacingCannotBeNegativeOrZero", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Spacing can not be null!.
+ ///
+ internal static string SpacingCannotBeNull
+ {
+ get
+ {
+ return ResourceManager.GetString("SpacingCannotBeNull", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Spacing is not in a correct format!.
+ ///
+ internal static string SpacingFormatWrong
+ {
+ get
+ {
+ return ResourceManager.GetString("SpacingFormatWrong", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to - Spacings between grids are too small.
+ ///
+ internal static string SpacingsTooSmall
+ {
+ get
+ {
+ return ResourceManager.GetString("SpacingsTooSmall", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Start degree should be less than end degree!.
+ ///
+ internal static string StartDegreeShouldBeLessThanEndDegree
+ {
+ get
+ {
+ return ResourceManager.GetString("StartDegreeShouldBeLessThanEndDegree", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationProperties/GridCreationResources.resx b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationProperties/GridCreationResources.resx
new file mode 100644
index 00000000..69589ea2
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/GridCreationProperties/GridCreationResources.resx
@@ -0,0 +1,255 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Please adjust the values and try again!
+
+
+ Coordinate can not be null!
+
+
+ Coordinate is not in a correct format!
+
+
+ Degree can not be negative!
+
+
+ Degree can not be null!
+
+
+ Degree is not in a correct format!
+
+
+ Start degree and end degree can not be so close!
+
+
+ Degree should be within the range of 0 - 360!
+
+
+ Distance can not be negative!
+
+
+ Distance can not be null!
+
+
+ Distance is not in a correct format!
+
+
+ cm
+
+
+ '
+
+
+ "
+
+
+ '
+
+
+ "
+
+
+ m
+
+
+ m
+
+
+ mm
+
+
+ - Start point and end point of arc grids are too close
+
+
+ Failed to create one or more arc grids.
+
+
+ Failed to create one or more grids.
+
+
+ Failed to create one or more radial grids.
+
+
+ Failed to delete some of the selected lines or arcs!
+
+
+ Failed to set label of grid to :
+
+
+ Failed to Create Grids
+
+
+ Failed to Delete Lines/Arcs
+
+
+ Invalid Value
+
+
+ Failed to Set Label
+
+
+ Label can not be null!
+
+
+ A same label has already existed!
+
+
+ The two labels can't be same!
+
+
+ Number should be an integer between 0 and 200!
+
+
+ Number can not be null!
+
+
+ Number is not in a correct format!
+
+
+ The two numbers can not be both zero!
+
+
+ Radius can not be negative or zero!
+
+
+ Radius can not be null!
+
+
+ Radius is not in a correct format!
+
+
+ That may be caused by one or more of following reasons:
+
+
+ Spacing can not be negative or zero!
+
+
+ Spacing can not be null!
+
+
+ Spacing is not in a correct format!
+
+
+ - Spacings between grids are too small
+
+
+ Start degree should be less than end degree!
+
+
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/Properties/Resources.Designer.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/Properties/Resources.Designer.cs
new file mode 100644
index 00000000..2746d35e
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/Properties/Resources.Designer.cs
@@ -0,0 +1,469 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.832
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Revit.SDK.Samples.GridCreation.Properties
+{
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MacroCSharpSamples.Samples.GridCreation.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Please adjust the values and try again!.
+ ///
+ internal static string AjustValues {
+ get {
+ return ResourceManager.GetString("AjustValues", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Coordinate can not be null!.
+ ///
+ internal static string CoordinateCannotBeNull {
+ get {
+ return ResourceManager.GetString("CoordinateCannotBeNull", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Coordinate is not in a correct format!.
+ ///
+ internal static string CoordinateFormatWrong {
+ get {
+ return ResourceManager.GetString("CoordinateFormatWrong", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Degree can not be negative!.
+ ///
+ internal static string DegreeCannotBeNegative {
+ get {
+ return ResourceManager.GetString("DegreeCannotBeNegative", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Degree can not be null!.
+ ///
+ internal static string DegreeCannotBeNull {
+ get {
+ return ResourceManager.GetString("DegreeCannotBeNull", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Degree is not in a correct format!.
+ ///
+ internal static string DegreeFormatWrong {
+ get {
+ return ResourceManager.GetString("DegreeFormatWrong", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Start degree and end degree can not be so close!.
+ ///
+ internal static string DegreesAreTooClose {
+ get {
+ return ResourceManager.GetString("DegreesAreTooClose", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Degree should be within the range of 0 - 360!.
+ ///
+ internal static string DegreeWithin0To360 {
+ get {
+ return ResourceManager.GetString("DegreeWithin0To360", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Distance can not be negative!.
+ ///
+ internal static string DistanceCannotBeNegative {
+ get {
+ return ResourceManager.GetString("DistanceCannotBeNegative", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Distance can not be null!.
+ ///
+ internal static string DistanceCannotBeNull {
+ get {
+ return ResourceManager.GetString("DistanceCannotBeNull", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Distance is not in a correct format!.
+ ///
+ internal static string DistanceFormatWrong {
+ get {
+ return ResourceManager.GetString("DistanceFormatWrong", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to cm.
+ ///
+ internal static string DUT_CENTIMETERS {
+ get {
+ return ResourceManager.GetString("DUT_CENTIMETERS", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to '.
+ ///
+ internal static string DUT_DECIMAL_FEET {
+ get {
+ return ResourceManager.GetString("DUT_DECIMAL_FEET", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to ".
+ ///
+ internal static string DUT_DECIMAL_INCHES {
+ get {
+ return ResourceManager.GetString("DUT_DECIMAL_INCHES", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to '.
+ ///
+ internal static string DUT_FEET_FRACTIONAL_INCHES {
+ get {
+ return ResourceManager.GetString("DUT_FEET_FRACTIONAL_INCHES", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to ".
+ ///
+ internal static string DUT_FRACTIONAL_INCHES {
+ get {
+ return ResourceManager.GetString("DUT_FRACTIONAL_INCHES", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to m.
+ ///
+ internal static string DUT_METERS {
+ get {
+ return ResourceManager.GetString("DUT_METERS", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to m.
+ ///
+ internal static string DUT_METERS_CENTIMETERS {
+ get {
+ return ResourceManager.GetString("DUT_METERS_CENTIMETERS", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to mm.
+ ///
+ internal static string DUT_MILLIMETERS {
+ get {
+ return ResourceManager.GetString("DUT_MILLIMETERS", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to - Start point and end point of arc grids are too close.
+ ///
+ internal static string EndPointsTooClose {
+ get {
+ return ResourceManager.GetString("EndPointsTooClose", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to create one or more arc grids..
+ ///
+ internal static string FailedToCreateArcGrids {
+ get {
+ return ResourceManager.GetString("FailedToCreateArcGrids", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to create one or more grids. .
+ ///
+ internal static string FailedToCreateGrids {
+ get {
+ return ResourceManager.GetString("FailedToCreateGrids", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to create one or more radial grids. .
+ ///
+ internal static string FailedToCreateRadialGrids {
+ get {
+ return ResourceManager.GetString("FailedToCreateRadialGrids", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to delete some of the selected lines or arcs!.
+ ///
+ internal static string FailedToDeletedLinesOrArcs {
+ get {
+ return ResourceManager.GetString("FailedToDeletedLinesOrArcs", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to set label of grid to : .
+ ///
+ internal static string FailedToSetLabel {
+ get {
+ return ResourceManager.GetString("FailedToSetLabel", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to Create Grids.
+ ///
+ internal static string FailureCaptionCreateGrids {
+ get {
+ return ResourceManager.GetString("FailureCaptionCreateGrids", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to Delete Lines/Arcs.
+ ///
+ internal static string FailureCaptionDeletedLinesOrArcs {
+ get {
+ return ResourceManager.GetString("FailureCaptionDeletedLinesOrArcs", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Invalid Value.
+ ///
+ internal static string FailureCaptionInvalidValue {
+ get {
+ return ResourceManager.GetString("FailureCaptionInvalidValue", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to Set Label.
+ ///
+ internal static string FailureCaptionSetLabel {
+ get {
+ return ResourceManager.GetString("FailureCaptionSetLabel", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Label can not be null!.
+ ///
+ internal static string LabelCannotBeNull {
+ get {
+ return ResourceManager.GetString("LabelCannotBeNull", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to A same label has already existed!.
+ ///
+ internal static string LabelExisted {
+ get {
+ return ResourceManager.GetString("LabelExisted", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to The two labels can't be same!.
+ ///
+ internal static string LabelsCannotBeSame {
+ get {
+ return ResourceManager.GetString("LabelsCannotBeSame", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Number should be an integer between 0 and 200!.
+ ///
+ internal static string NumberBetween0And200 {
+ get {
+ return ResourceManager.GetString("NumberBetween0And200", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Number can not be null!.
+ ///
+ internal static string NumberCannotBeNull {
+ get {
+ return ResourceManager.GetString("NumberCannotBeNull", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Number is not in a correct format!.
+ ///
+ internal static string NumberFormatWrong {
+ get {
+ return ResourceManager.GetString("NumberFormatWrong", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to The two numbers can not be both zero!.
+ ///
+ internal static string NumbersCannotBeBothZero {
+ get {
+ return ResourceManager.GetString("NumbersCannotBeBothZero", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Radius can not be negative or zero!.
+ ///
+ internal static string RadiusCannotBeNegativeOrZero {
+ get {
+ return ResourceManager.GetString("RadiusCannotBeNegativeOrZero", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Radius can not be null!.
+ ///
+ internal static string RadiusCannotBeNull {
+ get {
+ return ResourceManager.GetString("RadiusCannotBeNull", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Radius is not in a correct format!.
+ ///
+ internal static string RadiusFormatWrong {
+ get {
+ return ResourceManager.GetString("RadiusFormatWrong", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to That may be caused by one or more of following reasons:.
+ ///
+ internal static string Reasons {
+ get {
+ return ResourceManager.GetString("Reasons", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Spacing can not be negative or zero!.
+ ///
+ internal static string SpacingCannotBeNegativeOrZero {
+ get {
+ return ResourceManager.GetString("SpacingCannotBeNegativeOrZero", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Spacing can not be null!.
+ ///
+ internal static string SpacingCannotBeNull {
+ get {
+ return ResourceManager.GetString("SpacingCannotBeNull", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Spacing is not in a correct format!.
+ ///
+ internal static string SpacingFormatWrong {
+ get {
+ return ResourceManager.GetString("SpacingFormatWrong", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to - Spacings between grids are too small.
+ ///
+ internal static string SpacingsTooSmall {
+ get {
+ return ResourceManager.GetString("SpacingsTooSmall", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Start degree should be less than end degree!.
+ ///
+ internal static string StartDegreeShouldBeLessThanEndDegree {
+ get {
+ return ResourceManager.GetString("StartDegreeShouldBeLessThanEndDegree", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/Properties/Resources.resx b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/Properties/Resources.resx
new file mode 100644
index 00000000..401ffa04
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/Properties/Resources.resx
@@ -0,0 +1,255 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Please adjust the values and try again!
+
+
+ Coordinate can not be null!
+
+
+ Coordinate is not in a correct format!
+
+
+ Degree can not be negative!
+
+
+ Degree can not be null!
+
+
+ Degree is not in a correct format!
+
+
+ Start degree and end degree can not be so close!
+
+
+ Degree should be within the range of 0 - 360!
+
+
+ Distance can not be negative!
+
+
+ Distance can not be null!
+
+
+ Distance is not in a correct format!
+
+
+ cm
+
+
+ '
+
+
+ "
+
+
+ '
+
+
+ "
+
+
+ m
+
+
+ m
+
+
+ mm
+
+
+ - Start point and end point of arc grids are too close
+
+
+ Failed to create one or more arc grids.
+
+
+ Failed to create one or more grids.
+
+
+ Failed to create one or more radial grids.
+
+
+ Failed to delete some of the selected lines or arcs!
+
+
+ Failed to set label of grid to :
+
+
+ Failed to Create Grids
+
+
+ Failed to Delete Lines/Arcs
+
+
+ Invalid Value
+
+
+ Failed to Set Label
+
+
+ Label can not be null!
+
+
+ A same label has already existed!
+
+
+ The two labels can't be same!
+
+
+ Number should be an integer between 0 and 200!
+
+
+ Number can not be null!
+
+
+ Number is not in a correct format!
+
+
+ The two numbers can not be both zero!
+
+
+ Radius can not be negative or zero!
+
+
+ Radius can not be null!
+
+
+ Radius is not in a correct format!
+
+
+ That may be caused by one or more of following reasons:
+
+
+ Spacing can not be negative or zero!
+
+
+ Spacing can not be null!
+
+
+ Spacing is not in a correct format!
+
+
+ - Spacings between grids are too small
+
+
+ Start degree should be less than end degree!
+
+
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/Unit.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/Unit.cs
new file mode 100644
index 00000000..805ee398
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/Unit.cs
@@ -0,0 +1,82 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Autodesk.Revit.DB;
+using Autodesk.Revit;
+
+using System.Configuration;
+using System.Reflection;
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ ///
+ /// Provides static functions to convert unit
+ ///
+ static class Unit
+ {
+ #region Methods
+ ///
+ /// Convert the value get from RevitAPI to the value indicated by DisplayUnitType
+ ///
+ /// DisplayUnitType indicates unit of target value
+ /// value get from RevitAPI
+ /// Target value
+ public static double CovertFromAPI(ForgeTypeId to, double value)
+ {
+ return value *= ImperialDutRatio(to);
+ }
+
+ ///
+ /// Convert a value indicated by DisplayUnitType to the value used by RevitAPI
+ ///
+ /// Value to be converted
+ /// DisplayUnitType indicates the unit of the value to be converted
+ /// Target value
+ public static double CovertToAPI(double value, ForgeTypeId from)
+ {
+ return value /= ImperialDutRatio(from);
+ }
+
+ ///
+ /// Get ratio between value in RevitAPI and value to display indicated by DisplayUnitType
+ ///
+ /// DisplayUnitType indicates display unit type
+ /// Ratio
+ private static double ImperialDutRatio(ForgeTypeId unit)
+ {
+ if (unit == UnitTypeId.Feet) return 1;
+ if (unit == UnitTypeId.FeetFractionalInches) return 1;
+ if (unit == UnitTypeId.Inches) return 12;
+ if (unit == UnitTypeId.FractionalInches) return 12;
+ if (unit == UnitTypeId.Meters) return 0.3048;
+ if (unit == UnitTypeId.Centimeters) return 30.48;
+ if (unit == UnitTypeId.Millimeters) return 304.8;
+ if (unit == UnitTypeId.MetersCentimeters) return 0.3048;
+ return 1;
+ }
+ #endregion
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/Validation.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/Validation.cs
new file mode 100644
index 00000000..e61ba8f1
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/GridCreation/Validation.cs
@@ -0,0 +1,339 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using System.Resources;
+using System.Collections;
+
+using SamplePropertis = MacroCSharpSamples.GridCreation.GridCreationProperties;
+
+namespace Revit.SDK.Samples.GridCreation.CS
+{
+ ///
+ /// Class to validate input data before creating grids
+ ///
+ public static class Validation
+ {
+ // Get the resource contains strings
+ static ResourceManager resManager = SamplePropertis.GridCreationResources.ResourceManager;
+
+ ///
+ /// Validate numbers in UI
+ ///
+ /// Control contains number information
+ /// Control contains another number information
+ /// Whether the numbers are validated
+ public static bool ValidateNumbers(Control number1Ctrl, Control number2Ctrl)
+ {
+ if (!ValidateNumber(number1Ctrl) || !ValidateNumber(number2Ctrl))
+ {
+ return false;
+ }
+
+ if (Convert.ToUInt32(number1Ctrl.Text) == 0 && Convert.ToUInt32(number2Ctrl.Text) == 0)
+ {
+ MessageBox.Show(resManager.GetString("NumbersCannotBeBothZero"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ number1Ctrl.Focus();
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Validate number value
+ ///
+ /// Control contains number information
+ /// Whether the number value is validated
+ public static bool ValidateNumber(Control numberCtrl)
+ {
+ if (!ValidateNotNull(numberCtrl, "Number"))
+ {
+ return false;
+ }
+
+ try
+ {
+ uint number = Convert.ToUInt32(numberCtrl.Text);
+ if (number > 200)
+ {
+ MessageBox.Show(resManager.GetString("NumberBetween0And200"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ numberCtrl.Focus();
+ return false;
+ }
+ }
+ catch (OverflowException)
+ {
+ MessageBox.Show(resManager.GetString("NumberBetween0And200"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ numberCtrl.Focus();
+ return false;
+ }
+ catch (Exception)
+ {
+ MessageBox.Show(resManager.GetString("NumberFormatWrong"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ numberCtrl.Focus();
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Validate length value
+ ///
+ /// Control contains length information
+ /// Type of length
+ /// Whether the length can be zero
+ /// Whether the length value is validated
+ public static bool ValidateLength(Control lengthCtrl, String typeName, bool canBeZero)
+ {
+ if (!ValidateNotNull(lengthCtrl, typeName))
+ {
+ return false;
+ }
+
+ try
+ {
+ double length = Convert.ToDouble(lengthCtrl.Text);
+ if (length <= 0 && !canBeZero)
+ {
+ MessageBox.Show(resManager.GetString(typeName + "CannotBeNegativeOrZero"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ lengthCtrl.Focus();
+ return false;
+ }
+ else if (length < 0 && canBeZero)
+ {
+ MessageBox.Show(resManager.GetString(typeName + "CannotBeNegative"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ lengthCtrl.Focus();
+ return false;
+ }
+ }
+ catch (Exception)
+ {
+ MessageBox.Show(resManager.GetString(typeName + "FormatWrong"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ lengthCtrl.Focus();
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Validate coordinate value
+ ///
+ /// Control contains coordinate information
+ /// Whether the coordinate value is validated
+ public static bool ValidateCoord(Control coordCtrl)
+ {
+ if (!ValidateNotNull(coordCtrl, "Coordinate"))
+ {
+ return false;
+ }
+
+ try
+ {
+ Convert.ToDouble(coordCtrl.Text);
+ }
+ catch (Exception)
+ {
+ MessageBox.Show(resManager.GetString("CoordinateFormatWrong"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ coordCtrl.Focus();
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Validate start degree and end degree
+ ///
+ /// Control contains start degree information
+ /// Control contains end degree information
+ /// Whether the degree values are validated
+ public static bool ValidateDegrees(Control startDegree, Control endDegree)
+ {
+ if (!ValidateDegree(startDegree) || !ValidateDegree(endDegree))
+ {
+ return false;
+ }
+
+ if (Math.Abs(Convert.ToDouble(startDegree.Text) - Convert.ToDouble(endDegree.Text)) <= Double.Epsilon)
+ {
+ MessageBox.Show(resManager.GetString("DegreesAreTooClose"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ startDegree.Focus();
+ return false;
+ }
+
+ if (Convert.ToDouble(startDegree.Text) >= Convert.ToDouble(endDegree.Text))
+ {
+ MessageBox.Show(resManager.GetString("StartDegreeShouldBeLessThanEndDegree"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ startDegree.Focus();
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Validate degree value
+ ///
+ /// Control contains degree information
+ /// Whether the degree value is validated
+ public static bool ValidateDegree(Control degreeCtrl)
+ {
+ if (!ValidateNotNull(degreeCtrl, "Degree"))
+ {
+ return false;
+ }
+
+ try
+ {
+ double startDegree = Convert.ToDouble(degreeCtrl.Text);
+ if (startDegree < 0 || startDegree > 360)
+ {
+ MessageBox.Show(resManager.GetString("DegreeWithin0To360"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ degreeCtrl.Focus();
+ return false;
+ }
+ }
+ catch (Exception)
+ {
+ MessageBox.Show(resManager.GetString("DegreeFormatWrong"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ degreeCtrl.Focus();
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Validate label
+ ///
+ /// Control contains label information
+ /// List contains all labels in Revit document
+ /// Whether the label value is validated
+ public static bool ValidateLabel(Control labelCtrl, ArrayList allLabels)
+ {
+ if (!ValidateNotNull(labelCtrl, "Label"))
+ {
+ return false;
+ }
+
+ String labelToBeValidated = labelCtrl.Text;
+ foreach (String label in allLabels)
+ {
+ if (label == labelToBeValidated)
+ {
+ MessageBox.Show(resManager.GetString("LabelExisted"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ labelCtrl.Focus();
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ ///
+ /// Assure value is not null
+ ///
+ /// Control contains information needs to be checked
+ /// Type of information
+ /// Whether the value is not null
+ public static bool ValidateNotNull(Control control, String typeName)
+ {
+ if (String.IsNullOrEmpty(control.Text.TrimStart(' ').TrimEnd(' ')))
+ {
+ MessageBox.Show(resManager.GetString(typeName + "CannotBeNull"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ control.Focus();
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Assure two labels are not same
+ ///
+ /// Control contains label information
+ /// Control contains label information
+ /// Whether the labels are same
+ public static bool ValidateLabels(Control label1Ctrl, Control label2Ctrl)
+ {
+ if (label1Ctrl.Text.TrimStart(' ').TrimEnd(' ') == label2Ctrl.Text.TrimStart(' ').TrimEnd(' '))
+ {
+ MessageBox.Show(resManager.GetString("LabelsCannotBeSame"),
+ SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
+ label1Ctrl.Focus();
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/MacroSamples_RVT.csproj b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/MacroSamples_RVT.csproj
new file mode 100644
index 00000000..4cbfb764
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/MacroSamples_RVT.csproj
@@ -0,0 +1,39 @@
+
+
+ net8.0-windows
+ enable
+ enable
+ true
+
+
+ x64
+ false
+ false
+ False
+ True
+ Portable
+ ..\..\Addin\
+ MacroSamples_RVT
+ obj\
+ DEBUG;TRACE
+ obj\Debug
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+
+
+
+ False
+
+
+ False
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Command.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Command.cs
new file mode 100644
index 00000000..8d47feff
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Command.cs
@@ -0,0 +1,91 @@
+//
+// (C) Copyright 2003-2007 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+
+using System;
+using System.Windows.Forms;
+
+using Autodesk.Revit;
+using Autodesk.Revit.DB;
+using MacroCSharpSamples;
+using MacroSamples_RVT;
+
+namespace Revit.SDK.Samples.ProjectInfo.CS
+{
+ ///
+ /// Get some properties of a slab , such as Level, Type name, Span direction,
+ /// Material name, Thickness, and Young Modulus for the slab's Material.
+ ///
+ public class SampleProjectInfo
+ {
+ // #region Class ctor implemetation
+ ///
+ /// Ctor without parameter is not allowed
+ ///
+ private SampleProjectInfo()
+ {
+ // no codes
+ }
+
+ ///
+ /// Default constructor of StructuralLayerFunction
+ ///
+ public SampleProjectInfo(ThisApplication App)
+ {
+ // Init for varialbes
+ // this application handler
+ m_app = App;
+ // initialize global information
+
+ RevitStartInfo.RevitApp = m_app.ActiveUIDocument.Application.Application;
+ RevitStartInfo.RevitDoc = m_app.ActiveUIDocument.Document;
+ RevitStartInfo.RevitProduct = m_app.ActiveUIDocument.Application.Application.Product;
+ }
+
+ ///
+ /// Run sample Rooms
+ ///
+ public void Run()
+ {
+ try
+ {
+ //Get ProjectInfo object from current project
+ if(m_app == null)
+ return;
+ Autodesk.Revit.DB.ProjectInfo projectInfo = m_app.ActiveUIDocument.Document.ProjectInformation;
+ if (null != projectInfo)
+ {
+ ProjectInfoForm mainForm = new ProjectInfoForm(new ProjectInfoWrapper(projectInfo));
+ mainForm.ShowDialog();
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ }
+
+ #region Class member variable
+ ThisApplication? m_app;
+ #endregion
+ }
+}
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/AngleConverter.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/AngleConverter.cs
new file mode 100644
index 00000000..b751f859
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/AngleConverter.cs
@@ -0,0 +1,100 @@
+using System;
+using System.ComponentModel;
+
+namespace Revit.SDK.Samples.ProjectInfo.CS
+{
+ ///
+ /// Converts angle with string
+ ///
+ public class AngleConverter : TypeConverter
+ {
+ #region Methods
+ ///
+ /// Converts from string.
+ ///
+ /// Converted string
+ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
+ {
+ return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
+ }
+ ///
+ /// Converts to string.
+ ///
+ /// Converted string
+ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
+ {
+ if(destinationType == null)
+ return false;
+ return destinationType.Equals(typeof(string)) || base.CanConvertTo(context, destinationType);
+ }
+
+ ///
+ /// Converts from string.
+ ///
+ /// An System.ComponentModel.ITypeDescriptorContext
+ /// that provides a format context.
+ /// An optional System.Globalization.CultureInfo.
+ /// If not supplied, the current culture is assumed.
+ /// string to be converted to an element
+ /// An element if the element exists, otherwise null
+ public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value)
+ {
+ string? text = value as string;
+ if (!string.IsNullOrEmpty(text))
+ {
+ return AngleString2Double(text);
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+ ///
+ /// Converts to string.
+ ///
+ /// An ITypeDescriptorContext that provides a format context.
+ /// A CultureInfo. If null is passed, the current culture is assumed.
+ /// The Object to convert.
+ /// The Type to convert the value parameter to.
+ /// Converted string
+ public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType)
+ {
+ if (destinationType == null)
+ {
+ throw new ArgumentNullException("destinationType");
+ }
+ if (destinationType == typeof(string))
+ {
+ if (value == null) return string.Empty;
+ double angle = (double) value;
+ return Double2AngleString(angle);
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+
+ ///
+ /// Convert angle string to double value
+ ///
+ /// Angle string
+ /// Double value
+ private static double AngleString2Double(string value)
+ {
+ int n = value.Length - 1;
+ if (!char.IsDigit(value[n]))
+ {
+ value = value.Substring(0, n);
+ }
+ return Double.Parse(value) * 0.0174532925199433;
+ }
+
+ ///
+ /// Convert double value to angle string
+ ///
+ /// Angle value
+ /// Angle string, the unit is degree.
+ private static string Double2AngleString(Double value)
+ {
+ // 0xb0 is ASCII for unit flag of "degree"
+ return ((object)Math.Round(value / 0.0174532925199433, 3)).ToString() + (char)0xb0;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/CityConverter.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/CityConverter.cs
new file mode 100644
index 00000000..7c6a8b8f
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/CityConverter.cs
@@ -0,0 +1,131 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using Autodesk.Revit.DB;
+
+namespace Revit.SDK.Samples.ProjectInfo.CS
+{
+ ///
+ /// Converts City with string
+ ///
+ public class CityConverter : TypeConverter
+ {
+
+ public static List? Cities;
+ public const string UserDefined = "User Defined";
+
+ static CityConverter()
+ {
+ if(RevitStartInfo.RevitApp == null)
+ return;
+ Cities = new List();
+ foreach (City city in RevitStartInfo.RevitApp.Cities)
+ {
+ Cities.Add(city);
+ }
+ }
+
+ #region Methods
+
+ ///
+ /// Returns whether this object supports a standard set of values that can be
+ /// picked from a list, using the specified context.
+ ///
+ /// true
+ public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
+ {
+ return true;
+ }
+
+ ///
+ /// Returns whether the collection of standard values returned from System.ComponentModel.TypeConverter.GetStandardValues()
+ /// is an exclusive list.
+ ///
+ /// true
+ public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
+ {
+ return true;
+ }
+
+ ///
+ /// Returns a collection of standard values from the default context for the
+ /// data type this type converter is designed for.
+ ///
+ /// Element collection retrieved through filtering current Revit document elements
+ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
+ {
+ return new StandardValuesCollection(Cities);
+ }
+
+ ///
+ /// Converts from string.
+ ///
+ /// Converted string
+ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
+ {
+ return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
+ }
+ ///
+ /// Converts to string.
+ ///
+ /// Converted string
+ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
+ {
+ if(destinationType == null)
+ return false;
+ return destinationType.Equals(typeof(string)) || base.CanConvertTo(context, destinationType);
+ }
+
+ ///
+ /// Returns an element from a string contains its id
+ ///
+ /// An System.ComponentModel.ITypeDescriptorContext
+ /// that provides a format context.
+ /// An optional System.Globalization.CultureInfo.
+ /// If not supplied, the current culture is assumed.
+ /// string to be converted to an element
+ /// An element if the element exists, otherwise null
+ public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value)
+ {
+ string? text = value as string;
+ if(Cities == null)
+ return null;
+ if (!string.IsNullOrEmpty(text))
+ {
+ foreach (City city in Cities)
+ {
+ if (city.Name == text)
+ return city;
+ }
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+ ///
+ /// Returns element name.
+ /// returns empty string if value is null or Element.Name throws an exception.
+ ///
+ /// An ITypeDescriptorContext that provides a format context.
+ /// A CultureInfo. If null is passed, the current culture is assumed.
+ /// The Object to convert.
+ /// The Type to convert the value parameter to.
+ /// Converted string
+ public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType)
+ {
+ if (destinationType == null)
+ {
+ throw new ArgumentNullException("destinationType");
+ }
+ if (destinationType == typeof(string))
+ {
+ if (value == null) return UserDefined;
+ City? city = value as City;
+ if (city != null)
+ return city.Name;
+ else
+ return null;
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/ConstructionWrapperConverter.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/ConstructionWrapperConverter.cs
new file mode 100644
index 00000000..9162e998
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/ConstructionWrapperConverter.cs
@@ -0,0 +1,147 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using Autodesk.Revit.DB;
+using ConstructionType = Autodesk.Revit.DB.Analysis.ConstructionType;
+
+namespace Revit.SDK.Samples.ProjectInfo.CS
+{
+ ///
+ /// Converter for ConstructionWrapper
+ ///
+ public class ConstructionWrapperConverter : TypeConverter
+ {
+ #region Methods
+ ///
+ /// Returns whether this object supports a standard set of values that can be
+ /// picked from a list, using the specified context.
+ ///
+ /// true
+ public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
+ {
+ return true;
+ }
+
+ ///
+ /// Returns whether the collection of standard values returned from System.ComponentModel.TypeConverter.GetStandardValues()
+ /// is an exclusive list.
+ ///
+ /// true
+ public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
+ {
+ return true;
+ }
+
+ ///
+ /// Returns a collection of standard values from the default context for the
+ /// data type this type converter is designed for.
+ ///
+ /// ConstructionWrapper collection depends on current context
+ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
+ {
+ List list = new List();
+ // convert property name to ConstructionType
+
+ string? tmp = context?.PropertyDescriptor.Name;
+ string tmp2 = string.Empty;
+ if(tmp != null)
+ {
+ tmp2 = tmp;
+ }
+ ConstructionType constructionType = (ConstructionType)Enum.Parse(typeof(ConstructionType),tmp2);
+ // convert instance to MEPBuildingConstructionWrapper
+ MEPBuildingConstructionWrapper? mEPBuildingConstruction = context?.Instance as MEPBuildingConstructionWrapper;
+
+ // get all Constructions from MEPBuildingConstructionWrapper and add them to a list
+ if(mEPBuildingConstruction != null)
+ {
+ foreach (Construction con in mEPBuildingConstruction.GetConstructions(constructionType))
+ {
+ list.Add(new ConstructionWrapper(con));
+ }
+
+ }
+
+
+ // sort the list
+ list.Sort();
+ return new StandardValuesCollection(list);
+ }
+
+ ///
+ /// Can convert from string
+ ///
+ /// An ITypeDescriptorContext that provides a format context.
+ /// A Type that represents the type you want to convert from.
+ /// true if sourceType is string, otherwise false
+ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
+ {
+ return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
+ }
+
+ ///
+ /// Can be converted to string
+ ///
+ /// true if destinationType is string, otherwise false
+ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
+ {
+ if(destinationType == null)
+ {
+ return false;
+ }
+ return destinationType.Equals(typeof(System.String)) || base.CanConvertTo(context, destinationType);
+ }
+
+ ///
+ /// Returns a ConstructionWrapper from a string
+ ///
+ /// An System.ComponentModel.ITypeDescriptorContext
+ /// that provides a format context.
+ /// An optional System.Globalization.CultureInfo.
+ /// If not supplied, the current culture is assumed.
+ /// string to be converted to
+ /// A ConstructionWrapper from the StandardValues
+ public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value)
+ {
+ string? text = value as string;
+ if (!string.IsNullOrEmpty(text))
+ {
+ foreach (ConstructionWrapper con in this.GetStandardValues(context))
+ {
+ if (con.Name == text)
+ {
+ return con;
+ }
+ }
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+
+ ///
+ /// Convert object to string
+ ///
+ /// An ITypeDescriptorContext that provides a format context.
+ /// A CultureInfo. If null is passed, the current culture is assumed.
+ /// The Object to convert.
+ /// The Type to convert the value parameter to.
+ /// empty string if current construction is null, otherwise construction name
+ public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType)
+ {
+ if (destinationType == null)
+ {
+ throw new ArgumentNullException("destinationType");
+ }
+ if (destinationType == typeof(string))
+ {
+ if (value == null) return string.Empty;
+ ConstructionWrapper? construction = value as ConstructionWrapper;
+ if (construction != null)
+ {
+ return construction.Name;
+ }
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ #endregion
+ };
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/Converters.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/Converters.cs
new file mode 100644
index 00000000..00d4e28e
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/Converters.cs
@@ -0,0 +1,82 @@
+//
+// (C) Copyright 2003-2009 by Autodesk, Inc.
+//
+// Permission to use, copy, modify, and distribute this software in
+// object code form for any purpose and without fee is hereby granted,
+// provided that the above copyright notice appears in all copies and
+// that both that copyright notice and the limited warranty and
+// restricted rights notice below appear in all supporting
+// documentation.
+//
+// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
+// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
+// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
+// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
+// UNINTERRUPTED OR ERROR FREE.
+//
+// Use, duplication, or disclosure by the U.S. Government is subject to
+// restrictions set forth in FAR 52.227-19 (Commercial Computer
+// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+// (Rights in Technical Data and Computer Software), as applicable.
+//
+
+using System;
+using System.ComponentModel;
+using System.Collections.Generic;
+using System.Reflection;
+using Autodesk.Revit;
+
+namespace Revit.SDK.Samples.ProjectInfo.CS
+{
+ ///
+ /// Type converter for wrapper classes
+ ///
+ public class WrapperConverter : ExpandableObjectConverter
+ {
+ #region Methods
+ ///
+ /// Can be converted to string
+ ///
+ /// true if destinationType is string, otherwise false
+ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
+ {
+ if(destinationType == null)
+ {
+ return false;
+ }
+ return destinationType.Equals(typeof(System.String)) || base.CanConvertTo(context, destinationType);
+ }
+
+ ///
+ /// Converts to string. If value is null, convert it to "(null)".
+ /// if value has a "Name" property, returns its name. otherwise, returns "(...)".
+ ///
+ /// Converted string
+ public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType)
+ {
+ if (destinationType == null)
+ {
+ throw new ArgumentNullException("destinationType");
+ }
+ if (destinationType == typeof(string))
+ {
+ if (value == null) return "(null)";
+
+ // get its name
+ Type type = value.GetType();
+ string wrapperType = type.ToString();
+ MethodInfo? mi = type.GetMethod("get_Name", new Type[0]);
+ if (mi != null)
+ {
+ return mi.Invoke(value, new object[0])?.ToString();
+ }
+
+ // if no name
+ return "(...)";
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ #endregion
+ };
+}
+
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/ElementIdConverter.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/ElementIdConverter.cs
new file mode 100644
index 00000000..c2916de3
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/ElementIdConverter.cs
@@ -0,0 +1,140 @@
+using System;
+using System.ComponentModel;
+using System.Linq;
+using Autodesk.Revit.DB;
+
+namespace Revit.SDK.Samples.ProjectInfo.CS
+{
+ ///
+ /// Convert ElementIds with string
+ ///
+ /// Element Type
+ public class ElementIdConverter : TypeConverter where T: Element
+ {
+ ///
+ /// Returns whether this object supports a standard set of values that can be
+ /// picked from a list, using the specified context.
+ ///
+ /// true
+ public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
+ {
+ return true;
+ }
+
+ ///
+ /// Returns whether the collection of standard values returned from System.ComponentModel.TypeConverter.GetStandardValues()
+ /// is an exclusive list.
+ ///
+ /// true
+ public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
+ {
+ return true;
+ }
+
+ ///
+ /// Returns a collection of standard values from the default context for the
+ /// data type this type converter is designed for.
+ ///
+ /// Element collection retrieved through filtering current Revit document elements
+ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
+ {
+ // using type filter to get the target type objects
+ //Autodesk.Revit.DB.TypeFilter typeFilter = RevitStartInfo.RevitApp.Create.Filter.NewTypeFilter(targetType, true);
+ //ElementIterator elementIterator = RevitStartInfo.RevitDoc.get_Elements(typeFilter);
+
+ //// create a list
+ //List list = new List();
+ //elementIterator.Reset();
+ //while (elementIterator.MoveNext())
+ //{
+ // list.Add(elementIterator.Current as Element);
+ //}
+ var list = new FilteredElementCollector(RevitStartInfo.RevitDoc).OfClass(typeof(T));
+
+ return new StandardValuesCollection(list.ToElementIds().ToList());
+ }
+
+ ///
+ /// Converts from string.
+ ///
+ /// Converted string
+ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
+ {
+ return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
+ }
+ ///
+ /// Converts to string.
+ ///
+ /// Converted string
+ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
+ {
+ if(destinationType == null)
+ return false;
+ return destinationType.Equals(typeof(string)) || base.CanConvertTo(context, destinationType);
+ }
+
+ ///
+ /// Returns an element from a string contains its id
+ ///
+ /// An System.ComponentModel.ITypeDescriptorContext
+ /// that provides a format context.
+ /// An optional System.Globalization.CultureInfo.
+ /// If not supplied, the current culture is assumed.
+ /// string to be converted to an element
+ /// An element if the element exists, otherwise null
+ public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value)
+ {
+ string? text = value as string;
+ if (!string.IsNullOrEmpty(text))
+ {
+ StandardValuesCollection svc = GetStandardValues(context);
+ foreach (ElementId elementId in svc)
+ {
+ Element? element = RevitStartInfo.GetElement(elementId);
+ if (element?.Name == text)
+ return element.Id;
+ }
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+ ///
+ /// Returns element name.
+ /// returns empty string if value is null or Element.Name throws an exception.
+ ///
+ /// An ITypeDescriptorContext that provides a format context.
+ /// A CultureInfo. If null is passed, the current culture is assumed.
+ /// The Object to convert.
+ /// The Type to convert the value parameter to.
+ /// Converted string
+ public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType)
+ {
+ if (destinationType == null)
+ {
+ throw new ArgumentNullException("destinationType");
+ }
+ if (destinationType == typeof(string))
+ {
+ if (value == null) return string.Empty;
+ ElementId? elementId = value as ElementId;
+ if (elementId != null)
+ {
+ Element? element = RevitStartInfo.GetElement(elementId);
+ if (element != null)
+ {
+ string elementName = string.Empty;
+ try
+ {
+ elementName = element.Name;
+ }
+ catch
+ {
+ }
+ return elementName;
+ }
+ }
+
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ };
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/ProjectLocationConverter.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/ProjectLocationConverter.cs
new file mode 100644
index 00000000..4f332dfc
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/ProjectLocationConverter.cs
@@ -0,0 +1,140 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using Autodesk.Revit.DB;
+
+namespace Revit.SDK.Samples.ProjectInfo.CS
+{
+ ///
+ /// Converts ProjectLocation with string
+ ///
+ public class ProjectLocationConverter: TypeConverter
+ {
+ ///
+ /// All project locations in current document
+ ///
+ public static List? ProjectLocations;
+ ///
+ /// User defined location
+ ///
+ public const string UserDefined = "User Defined";
+
+ ///
+ /// Initialize ProjectLocations
+ ///
+ static ProjectLocationConverter()
+ {
+ if(RevitStartInfo.RevitDoc == null)
+ return;
+ ProjectLocations = new List();
+ foreach (ProjectLocation city in RevitStartInfo.RevitDoc.ProjectLocations)
+ {
+ ProjectLocations.Add(city);
+ }
+ }
+
+ #region Methods
+
+ ///
+ /// Returns whether this object supports a standard set of values that can be
+ /// picked from a list, using the specified context.
+ ///
+ /// true
+ public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
+ {
+ return true;
+ }
+
+ ///
+ /// Returns whether the collection of standard values returned from System.ComponentModel.TypeConverter.GetStandardValues()
+ /// is an exclusive list.
+ ///
+ /// true
+ public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
+ {
+ return true;
+ }
+
+ ///
+ /// Returns a collection of standard values from the default context for the
+ /// data type this type converter is designed for.
+ ///
+ /// Element collection retrieved through filtering current Revit document elements
+ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
+ {
+ return new StandardValuesCollection(ProjectLocations);
+ }
+
+ ///
+ /// Converts from string.
+ ///
+ /// Converted string
+ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
+ {
+ return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
+ }
+ ///
+ /// Converts to string.
+ ///
+ /// Converted string
+ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
+ {
+ if(destinationType == null)
+ {
+ return false;
+ }
+ return destinationType.Equals(typeof(string)) || base.CanConvertTo(context, destinationType);
+ }
+
+ ///
+ /// Converts from string.
+ ///
+ /// An System.ComponentModel.ITypeDescriptorContext
+ /// that provides a format context.
+ /// An optional System.Globalization.CultureInfo.
+ /// If not supplied, the current culture is assumed.
+ /// string to be converted to an element
+ /// An element if the element exists, otherwise null
+ public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value)
+ {
+ string? text = value as string;
+ if(ProjectLocations == null)
+ return base.ConvertFrom(context, culture, value);
+ if (!string.IsNullOrEmpty(text))
+ {
+ foreach (ProjectLocation projectLocation in ProjectLocations)
+ {
+ if (projectLocation.Name == text)
+ return projectLocation;
+ }
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+ ///
+ /// Converts to string.
+ ///
+ /// An ITypeDescriptorContext that provides a format context.
+ /// A CultureInfo. If null is passed, the current culture is assumed.
+ /// The Object to convert.
+ /// The Type to convert the value parameter to.
+ /// Converted string
+ public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType)
+ {
+ if (destinationType == null)
+ {
+ throw new ArgumentNullException("destinationType");
+ }
+ if (destinationType == typeof(string))
+ {
+ if (value == null) return UserDefined;
+ ProjectLocation? projectLocation = value as ProjectLocation;
+ if (projectLocation != null)
+ return projectLocation.Name;
+ else
+ return null;
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/RevitEnumConverter.cs b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/RevitEnumConverter.cs
new file mode 100644
index 00000000..33836d14
--- /dev/null
+++ b/SDK/Macro Samples/MacroSamples_RVT/Source/MacroSamples_RVT/ProjectInfo/Converters/RevitEnumConverter.cs
@@ -0,0 +1,236 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+
+namespace Revit.SDK.Samples.ProjectInfo.CS
+{
+ ///
+ /// Converter for Enumeration types of RevitAPI
+ ///
+ public abstract class RevitEnumConverter : EnumConverter
+ {
+ #region Fields
+ ///
+ /// Dictionary contains enum and string map
+ ///
+ Dictionary