mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-22 03:40:55 +00:00
integrate Revit 2025 SDK
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"ms-dotnettools.csharp",
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<Optimize>False</Optimize>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType>Portable</DebugType>
|
||||
<OutputPath>..\..\Addin\</OutputPath>
|
||||
<AssemblyName>GetTimeElapsed</AssemblyName>
|
||||
<BaseInterMediateOutputPath>obj\</BaseInterMediateOutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<InterMediateOutputPath>obj\Debug</InterMediateOutputPath>
|
||||
<Deterministic>false</Deterministic>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
|
||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
|
||||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
|
||||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="..\..\..\..\..\RevitAPI.dll">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="..\..\..\..\..\RevitAPIUI.dll">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
||||
<Exec Command="del $(OutputPath)\*.dll" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -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.*")]
|
||||
+54
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<Document, DateTime> m_dicLastSaved = new Dictionary<Document, DateTime>();
|
||||
private void Module_Startup(object? sender, EventArgs e)
|
||||
{
|
||||
InitializeDicLastSaved();
|
||||
this.Application.DocumentSaved += new EventHandler<DocumentSavedEventArgs>(ThisApplication_DocumentSaved);
|
||||
this.Application.DocumentOpened += new EventHandler<DocumentOpenedEventArgs>(ThisApplication_DocumentOpened);
|
||||
this.Application.DocumentCreated += new EventHandler<DocumentCreatedEventArgs>(ThisApplication_DocumentCreated);
|
||||
this.Application.DocumentClosing += new EventHandler<DocumentClosingEventArgs>(ThisApplication_DocumentClosing);
|
||||
}
|
||||
|
||||
private void Module_Shutdown(object? sender, EventArgs e)
|
||||
{
|
||||
this.Application.DocumentSaved -= new EventHandler<DocumentSavedEventArgs>(ThisApplication_DocumentSaved);
|
||||
this.Application.DocumentOpened -= new EventHandler<DocumentOpenedEventArgs>(ThisApplication_DocumentOpened);
|
||||
this.Application.DocumentCreated -= new EventHandler<DocumentCreatedEventArgs>(ThisApplication_DocumentCreated);
|
||||
this.Application.DocumentClosing -= new EventHandler<DocumentClosingEventArgs>(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
|
||||
|
||||
/// <summary>
|
||||
/// Initialize
|
||||
/// </summary>
|
||||
private void InitializeDicLastSaved()
|
||||
{
|
||||
foreach (Document document in this.Application.Documents)
|
||||
{
|
||||
m_dicLastSaved.Add(document, DateTime.MaxValue);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DocumentCreated event, add the created document into m_dicLastSaved
|
||||
/// </summary>
|
||||
/// <param name="sender">sender</param>
|
||||
/// <param name="args">DocumentCreatedEventArgs</param>
|
||||
public void ThisApplication_DocumentCreated(object? sender, DocumentCreatedEventArgs args)
|
||||
{
|
||||
m_dicLastSaved.Add(args.Document, DateTime.MaxValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DocumentClosing event, remove the closing document from m_dicLastSaved
|
||||
/// </summary>
|
||||
/// <param name="sender">sender</param>
|
||||
/// <param name="args">DocumentClosingEventArgs</param>
|
||||
public void ThisApplication_DocumentClosing(object? sender, DocumentClosingEventArgs args)
|
||||
{
|
||||
m_dicLastSaved.Remove(args.Document);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DocumentOpened event, add the opened document into m_dicLastSaved
|
||||
/// </summary>
|
||||
/// <param name="sender">sender</param>
|
||||
/// <param name="args">DocumentOpenedEventArgs</param>
|
||||
public void ThisApplication_DocumentOpened(object? sender, DocumentOpenedEventArgs args)
|
||||
{
|
||||
m_dicLastSaved.Add(args.Document, DateTime.MaxValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DocumentSaved event, record the current DataTime for the saved document
|
||||
/// </summary>
|
||||
/// <param name="sender">sender</param>
|
||||
/// <param name="args">DocumentSavedEventArgs</param>
|
||||
public void ThisApplication_DocumentSaved(object? sender, DocumentSavedEventArgs args)
|
||||
{
|
||||
this.m_dicLastSaved[args.Document] = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// FormatTimeSpan
|
||||
/// </summary>
|
||||
/// <param name="elapse">TimeSpan</param>
|
||||
/// <returns>the string of TimeSpan</returns>
|
||||
public String FormatTimeSpan(TimeSpan elapse)
|
||||
{
|
||||
String elapseStr = elapse.ToString();
|
||||
int lastIndexOfDot = elapseStr.LastIndexOf('.');
|
||||
return elapseStr.Substring(0, lastIndexOfDot);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetTimeElapsedSinceLastSave
|
||||
/// </summary>
|
||||
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<Document, DateTime> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"ms-dotnettools.csharp",
|
||||
]
|
||||
}
|
||||
+15
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is used to detect the obstructions of a Line or a ray.
|
||||
/// </summary>
|
||||
class Detector
|
||||
{
|
||||
/// <summary>
|
||||
/// Revit Document.
|
||||
/// </summary>
|
||||
private Document m_rvtDoc;
|
||||
|
||||
/// <summary>
|
||||
/// Revit 3D view.
|
||||
/// </summary>
|
||||
private View3D? m_view3d;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor, initialize all the fields.
|
||||
/// </summary>
|
||||
/// <param name="rvtDoc">Revit Document</param>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return all the obstructions which intersect with a ray given by an origin and a direction.
|
||||
/// </summary>
|
||||
/// <param name="origin">Ray's origin</param>
|
||||
/// <param name="dir">Ray's direction</param>
|
||||
/// <returns>Obstructions intersected with the given ray</returns>
|
||||
public List<ReferenceWithContext> Obstructions(XYZ origin, XYZ dir)
|
||||
{
|
||||
List<ReferenceWithContext> result = new List<ReferenceWithContext>();
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return all the obstructions which intersect with a bound line.
|
||||
/// </summary>
|
||||
/// <param name="boundLine">Bound line</param>
|
||||
/// <returns>Obstructions intersected with the bound line</returns>
|
||||
public List<ReferenceWithContext> Obstructions(Line boundLine)
|
||||
{
|
||||
List<ReferenceWithContext> result = new List<ReferenceWithContext>();
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="arr">ReferenceWithContext Array</param>
|
||||
/// <param name="entry">ReferenceWithContext</param>
|
||||
/// <returns>True of false</returns>
|
||||
private bool InArray(List<ReferenceWithContext> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to compare two ReferenceWithContexts, just compare their Proximitys.
|
||||
/// </summary>
|
||||
/// <param name="a">First ReferenceWithContext to compare</param>
|
||||
/// <param name="b">Second ReferenceWithContext to compare</param>
|
||||
/// <returns>-1, 0, or 1</returns>
|
||||
private int CompareReferences(ReferenceWithContext a, ReferenceWithContext b)
|
||||
{
|
||||
if (a.Proximity > b.Proximity)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (a.Proximity < b.Proximity)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<Optimize>False</Optimize>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType>Portable</DebugType>
|
||||
<OutputPath>..\..\Addin\</OutputPath>
|
||||
<AssemblyName>MacroSamples_MEP</AssemblyName>
|
||||
<BaseInterMediateOutputPath>obj\</BaseInterMediateOutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<InterMediateOutputPath>obj\Debug</InterMediateOutputPath>
|
||||
<Deterministic>false</Deterministic>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
|
||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
|
||||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
|
||||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="..\..\..\..\..\RevitAPI.dll">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="..\..\..\..\..\RevitAPIUI.dll">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
||||
<Exec Command="del $(OutputPath)\*.dll" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -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.*")]
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// This class implement the algorithm to detect the obstruction and resolve it.
|
||||
/// </summary>
|
||||
class Resolver
|
||||
{
|
||||
/// <summary>
|
||||
/// Revit Document.
|
||||
/// </summary>
|
||||
private Document? m_rvtDoc;
|
||||
|
||||
/// <summary>
|
||||
/// Detector to detect the obstructions.
|
||||
/// </summary>
|
||||
private Detector m_detector;
|
||||
|
||||
|
||||
PipingSystemType? m_pipingSystemType;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor, initialize all the fields of this class.
|
||||
/// </summary>
|
||||
/// <param name="data">Revit ExternalCommandData from external command entrance</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detect and resolve the obstructions of all Pipes.
|
||||
/// </summary>
|
||||
public void Resolve()
|
||||
{
|
||||
List<Autodesk.Revit.DB.Element> pipes = new List<Autodesk.Revit.DB.Element>();
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_rvtDoc);
|
||||
pipes.AddRange(collector.OfClass(typeof(Pipe)).ToElements());
|
||||
foreach (Element pipe in pipes)
|
||||
{
|
||||
Resolve(pipe as Pipe);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate the uniform perpendicular directions with inputting direction "dir".
|
||||
/// </summary>
|
||||
/// <param name="dir">Direction to calculate</param>
|
||||
/// <param name="count">How many perpendicular directions will be calculated</param>
|
||||
/// <returns>The calculated perpendicular directions with dir</returns>
|
||||
private List<Autodesk.Revit.DB.XYZ> PerpendicularDirs(Autodesk.Revit.DB.XYZ dir, int count)
|
||||
{
|
||||
List<Autodesk.Revit.DB.XYZ> dirs = new List<Autodesk.Revit.DB.XYZ>();
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detect the obstructions of pipe and resolve them.
|
||||
/// </summary>
|
||||
/// <param name="pipe">Pipe to resolve</param>
|
||||
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<ReferenceWithContext> 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<Section> 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Filter the inputting References, just allow Pipe, Duct and Beam References.
|
||||
/// </summary>
|
||||
/// <param name="pipe">Pipe</param>
|
||||
/// <param name="refs">References to filter</param>
|
||||
private void Filter(Pipe pipe, List<ReferenceWithContext> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method will find out a route to avoid the obstruction.
|
||||
/// </summary>
|
||||
/// <param name="pipe">Pipe to resolve</param>
|
||||
/// <param name="section">Pipe's one obstruction</param>
|
||||
/// <returns>A route which can avoid the obstruction</returns>
|
||||
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<Autodesk.Revit.DB.XYZ> dirs = new List<Autodesk.Revit.DB.XYZ>();
|
||||
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<Autodesk.Revit.DB.XYZ> 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<ReferenceWithContext> obs1 = m_detector.Obstructions(section.Start, dirs[i]);
|
||||
List<ReferenceWithContext> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find a line Parallel to pipe's centerline to avoid the obstruction.
|
||||
/// </summary>
|
||||
/// <param name="pipe">Pipe who has obstructions</param>
|
||||
/// <param name="section">Pipe's one obstruction</param>
|
||||
/// <param name="dir">Offset Direction of the parallel line</param>
|
||||
/// <param name="maxLength">Maximum offset distance</param>
|
||||
/// <returns>Parallel line which can avoid the obstruction</returns>
|
||||
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<ReferenceWithContext> refs = m_detector.Obstructions(line);
|
||||
Filter(pipe, refs);
|
||||
|
||||
if (refs.Count == 0)
|
||||
{
|
||||
return line;
|
||||
}
|
||||
hight += step;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="refs">References</param>
|
||||
/// <returns>Reference array</returns>
|
||||
private ReferenceWithContext[] GetClosestSectionsToOrigin(List<ReferenceWithContext> 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;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resolve one obstruction of Pipe.
|
||||
/// </summary>
|
||||
/// <param name="pipe">Pipe to resolve</param>
|
||||
/// <param name="section">One pipe's obstruction</param>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy parameters from source pipe to target pipe.
|
||||
/// </summary>
|
||||
/// <param name="source">Coping source</param>
|
||||
/// <param name="target">Coping target</param>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find out a connector from pipe with a specified point.
|
||||
/// </summary>
|
||||
/// <param name="pipe">Pipe to find the connector</param>
|
||||
/// <param name="conXYZ">Specified point</param>
|
||||
/// <returns>Connector whose origin is conXYZ</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find out the connector which the pipe's specified connector connected to.
|
||||
/// The pipe's specified connector is given by point conxyz.
|
||||
/// </summary>
|
||||
/// <param name="pipe">Pipe to find the connector</param>
|
||||
/// <param name="conXYZ">Specified point</param>
|
||||
/// <returns>Connector whose origin is conXYZ</returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// This class presents an obstruction of a Pipe.
|
||||
/// </summary>
|
||||
class Section
|
||||
{
|
||||
/// <summary>
|
||||
/// Pipe centerline's direction.
|
||||
/// </summary>
|
||||
private XYZ m_dir;
|
||||
|
||||
/// <summary>
|
||||
/// Extend factor in negative direction.
|
||||
/// </summary>
|
||||
private double m_startFactor;
|
||||
|
||||
/// <summary>
|
||||
/// Extend factor in positive direction.
|
||||
/// </summary>
|
||||
private double m_endFactor;
|
||||
|
||||
/// <summary>
|
||||
/// ReferenceWithContexts contained in this obstruction.
|
||||
/// </summary>
|
||||
private List<ReferenceWithContext> m_refs;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
private List<Pipe> m_pipes;
|
||||
|
||||
/// <summary>
|
||||
/// Private constructor, just be called in static factory method BuildSections.
|
||||
/// </summary>
|
||||
/// <param name="dir">Pipe's direction</param>
|
||||
private Section(XYZ dir)
|
||||
{
|
||||
m_dir = dir;
|
||||
m_startFactor = 0;
|
||||
m_endFactor = 0;
|
||||
m_refs = new List<ReferenceWithContext>();
|
||||
m_pipes = new List<Pipe>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pipe centerline's direction.
|
||||
/// </summary>
|
||||
public XYZ PipeCenterLineDirection
|
||||
{
|
||||
get { return m_dir; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public List<Pipe> Pipes
|
||||
{
|
||||
get { return m_pipes; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start point of this obstruction.
|
||||
/// </summary>
|
||||
public XYZ Start
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_refs[0].GetReference().GlobalPoint.Add(m_dir.Multiply(m_startFactor));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// End point of this obstruction.
|
||||
/// </summary>
|
||||
public XYZ End
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_refs[m_refs.Count - 1].GetReference().GlobalPoint.Add(m_dir.Multiply(m_endFactor));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ReferenceWithContexts contained in this obstruction.
|
||||
/// </summary>
|
||||
public List<ReferenceWithContext> Refs
|
||||
{
|
||||
get { return m_refs; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extend this obstruction's interval in one direction.
|
||||
/// </summary>
|
||||
/// <param name="index">index of direction, 0 => start, 1 => end</param>
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="allrefs">ReferenceWithContexts</param>
|
||||
/// <param name="dir">Pipe's direction</param>
|
||||
/// <returns>List of Section</returns>
|
||||
public static List<Section> BuildSections(List<ReferenceWithContext> allrefs, XYZ dir)
|
||||
{
|
||||
List<ReferenceWithContext> buildStack = new List<ReferenceWithContext>();
|
||||
List<Section> sections = new List<Section>();
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Judge whether a ReferenceWithContext is already in the list of ReferenceWithContext, return the founded value.
|
||||
/// </summary>
|
||||
/// <param name="arr">List of ReferenceWithContext</param>
|
||||
/// <param name="entry">Reference to test</param>
|
||||
/// <returns>One ReferenceWithContext has the same element's Id with entry</returns>
|
||||
private static ReferenceWithContext? Find(List<ReferenceWithContext> arr, ReferenceWithContext entry)
|
||||
{
|
||||
foreach (ReferenceWithContext tmp in arr)
|
||||
{
|
||||
if (tmp.GetReference().ElementId.Value == entry.GetReference().ElementId.Value)
|
||||
{
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+54
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"ms-dotnettools.csharp",
|
||||
]
|
||||
}
|
||||
+15
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
]
|
||||
}
|
||||
+494
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// add parameters(family parameters/shared parameters) to the opened family file
|
||||
/// the parameters are recorded in txt file following certain formats
|
||||
/// </summary>
|
||||
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<string /*paramName*/, FamilyParam> m_familyParams;
|
||||
private DefinitionFile? m_sharedFile;
|
||||
private string m_familyFilePath = string.Empty;
|
||||
private string m_sharedFilePath = string.Empty;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="app">
|
||||
/// the active revit application
|
||||
/// </param>
|
||||
/// <param name="doc">
|
||||
/// the family document which will have parameters added in
|
||||
/// </param>
|
||||
public FamilyParameterAssigner(ThisApplication thisApp)
|
||||
{
|
||||
m_thisapp = thisApp;
|
||||
m_app = thisApp.Application;
|
||||
m_manager = thisApp.ActiveUIDocument.Document.FamilyManager;
|
||||
m_familyParams = new Dictionary<string, FamilyParam>();
|
||||
|
||||
addInPath = thisApp.AddinFolder;
|
||||
|
||||
m_paramLoaded = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// load the family parameter file (if exists) and shared parameter file (if exists)
|
||||
/// only need to load once
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// if succeeded, return true; otherwise false
|
||||
/// </returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// load family parameters from the text file
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// return true if succeeded; otherwise false
|
||||
/// </returns>
|
||||
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<string> values = new List<string>();
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// load family parameters from the text file
|
||||
/// </summary>
|
||||
/// <param name="exist">
|
||||
/// indicate whether the shared parameter file exists
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// return true if succeeded; otherwise false
|
||||
/// </returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// add parameters to the family file
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// if succeeded, return true; otherwise false
|
||||
/// </returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// add family parameter to the family
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// if succeeded, return true; otherwise false
|
||||
/// </returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// load shared parameters from shared parameter file and add them to family
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// if succeeded, return true; otherwise false
|
||||
/// </returns>
|
||||
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"
|
||||
|
||||
/// <summary>
|
||||
/// record the data of a parameter: its name, its group, etc
|
||||
/// </summary>
|
||||
class FamilyParam
|
||||
{
|
||||
string m_name = string.Empty;
|
||||
/// <summary>
|
||||
/// the caption of the parameter
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return m_name; }
|
||||
}
|
||||
|
||||
ForgeTypeId? m_group;
|
||||
/// <summary>
|
||||
/// the group of the parameter
|
||||
/// </summary>
|
||||
public ForgeTypeId? Group
|
||||
{
|
||||
get { return m_group; }
|
||||
}
|
||||
|
||||
ForgeTypeId? m_type;
|
||||
/// <summary>
|
||||
/// the type of the parameter
|
||||
/// </summary>
|
||||
public ForgeTypeId? Type
|
||||
{
|
||||
get { return m_type; }
|
||||
}
|
||||
|
||||
bool m_isInstance;
|
||||
/// <summary>
|
||||
/// indicate whether the parameter is an instance parameter or a type parameter
|
||||
/// </summary>
|
||||
public bool IsInstance
|
||||
{
|
||||
get { return m_isInstance; }
|
||||
}
|
||||
|
||||
int m_line;
|
||||
/// <summary>
|
||||
/// record the location of this parameter in the family parameter file
|
||||
/// </summary>
|
||||
public int Line
|
||||
{
|
||||
get { return m_line; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// default constructor, hide this by making it "private"
|
||||
/// </summary>
|
||||
private FamilyParam()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor which exposes for invoking
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// parameter name
|
||||
/// </param>
|
||||
/// <param name="group">
|
||||
/// indicate which group the parameter belongs to
|
||||
/// </param>
|
||||
/// <param name="type">
|
||||
/// the type of the parameter
|
||||
/// </param>
|
||||
/// <param name="isInstance">
|
||||
/// indicate whethe the parameter is an instance parameter
|
||||
/// </param>
|
||||
/// <param name="line">
|
||||
/// record the location of this parameter in the family parameter file
|
||||
/// </param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// store the warning/error messeges when executing the sample
|
||||
/// </summary>
|
||||
static class MessageManager
|
||||
{
|
||||
static StringBuilder m_messageBuff = new StringBuilder();
|
||||
/// <summary>
|
||||
/// store the warning/error messages
|
||||
/// </summary>
|
||||
public static StringBuilder MessageBuff
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_messageBuff;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_messageBuff = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+430
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// This class show how to create Generic Model Family by Revit API.
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Implement this method as an external command for Revit.
|
||||
/// </summary>
|
||||
/// <param name="commandData">An object that is passed to the external application
|
||||
/// which contains data related to the command,
|
||||
/// such as the application object and active view.</param>
|
||||
/// <param name="message">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.</param>
|
||||
/// <param name="elements">A set of elements to which the external application
|
||||
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
|
||||
/// <returns>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.</returns>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Examples for form creation in generic model families.
|
||||
/// Create extrusion, sweep, blend, swept blend
|
||||
/// </summary>
|
||||
public void CreateGenericModel()
|
||||
{
|
||||
// use transaction if the family document is not active document
|
||||
CreateExtrusion();
|
||||
CreateBlend();
|
||||
CreateRevolution();
|
||||
CreateSweep();
|
||||
CreateSweptBlend();
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create one rectangular extrusion
|
||||
/// </summary>
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create one blend
|
||||
/// </summary>
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create one rectangular profile revolution
|
||||
/// </summary>
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create one sweep
|
||||
/// </summary>
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create one SweptBlend
|
||||
/// </summary>
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get element by its id
|
||||
/// </summary>
|
||||
private T? GetElement<T>(Int64 eid) where T : Autodesk.Revit.DB.Element
|
||||
{
|
||||
ElementId elementId = new ElementId(eid);
|
||||
return m_familyDocument?.GetElement(elementId) as T;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create sketch plane for generic model profile
|
||||
/// </summary>
|
||||
/// <param name="normal">plane normal</param>
|
||||
/// <param name="origin">origin point</param>
|
||||
/// <returns></returns>
|
||||
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
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<Optimize>False</Optimize>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType>Portable</DebugType>
|
||||
<OutputPath>..\..\Addin\</OutputPath>
|
||||
<AssemblyName>MacroSamples_RFA</AssemblyName>
|
||||
<BaseInterMediateOutputPath>obj\</BaseInterMediateOutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<InterMediateOutputPath>obj\Debug</InterMediateOutputPath>
|
||||
<Deterministic>false</Deterministic>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
|
||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
|
||||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
|
||||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="..\..\..\..\..\RevitAPI.dll">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="..\..\..\..\..\RevitAPIUI.dll">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
||||
<Exec Command="del $(OutputPath)\*.dll" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -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.*")]
|
||||
+54
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// AutoJoin
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AutoParameter
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// add parameters to the active document
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// if succeeded, return true; otherwise false
|
||||
/// </returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GenericModelCreation
|
||||
/// </summary>
|
||||
public void GenericModelCreation()
|
||||
{
|
||||
using (Transaction trans = new Transaction(this.ActiveUIDocument.Document, "GenericModelCreation"))
|
||||
{
|
||||
trans.Start();
|
||||
GenericModelCreation sample = new GenericModelCreation(this);
|
||||
sample.Run();
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TypeRegeneration
|
||||
/// </summary>
|
||||
public void TypeRegeneration()
|
||||
{
|
||||
TypeRegeneration sample = new TypeRegeneration(this);
|
||||
sample.Run();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ValidateParameters
|
||||
/// </summary>
|
||||
public void ValidateParameters()
|
||||
{
|
||||
ValidateParameters sample = new ValidateParameters(this);
|
||||
sample.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+90
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
+80
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The form is used to show the result
|
||||
/// </summary>
|
||||
public partial class MessageForm : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// new a Timer,set the interval 2 seconds;
|
||||
/// </summary>
|
||||
System.Timers.Timer timer = new System.Timers.Timer(2000);
|
||||
|
||||
/// <summary>
|
||||
/// construction of MessageForm
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// add text to the richtextbox and set time enable is true, then timer starts timing
|
||||
/// </summary>
|
||||
/// <param name="message">message from the regeneration</param>
|
||||
/// <param name="enableTimer">enable or disable the timer elapsed event</param>
|
||||
public void AddMessage(string message, bool enableTimer)
|
||||
{
|
||||
messageRichTextBox.AppendText(message);
|
||||
timer.Enabled = enableTimer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the method is executed when time is out, and set the timer enabled false,then timer stop timing
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="e">time elapsed event args</param>
|
||||
private void onTimeOut(object? source, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
timer.Enabled = false;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
+176
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// this class controls the class which subscribes handle events and the events' information UI.
|
||||
/// like a bridge between them.
|
||||
/// </summary>
|
||||
public class TypeRegeneration
|
||||
{
|
||||
#region Class Memeber Variables
|
||||
/// <summary>
|
||||
/// store family manager
|
||||
/// </summary>
|
||||
private FamilyManager? m_familyManager;
|
||||
private Autodesk.Revit.ApplicationServices.Application m_revit;
|
||||
private ThisApplication? m_thisApp;
|
||||
|
||||
/// <summary>
|
||||
/// store the log file name
|
||||
/// </summary>
|
||||
string m_logFileName = string.Empty;
|
||||
#endregion
|
||||
|
||||
public TypeRegeneration(ThisApplication thisApp)
|
||||
{
|
||||
m_thisApp = thisApp;
|
||||
m_revit = thisApp.ActiveUIDocument.Document.Application;
|
||||
}
|
||||
|
||||
#region Class Interface Implementation
|
||||
|
||||
/// <summary>
|
||||
/// Run
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// After setting CurrentType property, the CurrentType has changed to the new one,the Revit model will change along with the current type
|
||||
/// </summary>
|
||||
/// <param name="msgForm">the form is used to show the regeneration result</param>
|
||||
private void CheckTypeRegeneration(MessageForm msgForm)
|
||||
{
|
||||
//the list to record the error messages
|
||||
List<string> errorInfo = new List<string>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The method to write line to log file
|
||||
/// </summary>
|
||||
/// <param name="logStr">the log string</param>
|
||||
private void WriteLog(string logStr)
|
||||
{
|
||||
StreamWriter? writer = null;
|
||||
writer = File.AppendText(m_logFileName);
|
||||
writer.WriteLine(logStr);
|
||||
writer.Close();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+88
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
+108
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The form is used to show the result
|
||||
/// </summary>
|
||||
public partial class MessageForm : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// store the log file name
|
||||
/// </summary>
|
||||
string m_logFileName = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// construction of form
|
||||
/// </summary>
|
||||
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";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// construction method with parameter
|
||||
/// </summary>
|
||||
/// <param name="messages">messages</param>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The method is used to write line to log file
|
||||
/// </summary>
|
||||
/// <param name="logStr">the log string</param>
|
||||
private void WriteLog(string logStr)
|
||||
{
|
||||
StreamWriter? writer = null;
|
||||
writer = File.AppendText(m_logFileName);
|
||||
writer.WriteLine(logStr);
|
||||
writer.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -112,9 +112,9 @@
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
//
|
||||
// (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 Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using MacroSamples_RFA;
|
||||
|
||||
namespace Revit.SDK.Samples.ValidateParameters.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// this class controls the class which subscribes handle events and the events' information UI.
|
||||
/// like a bridge between them.
|
||||
/// </summary>
|
||||
public class ValidateParameters
|
||||
{
|
||||
#region Class Memeber Variables
|
||||
/// <summary>
|
||||
/// store the family manager
|
||||
/// </summary>
|
||||
private FamilyManager? m_familyManager;
|
||||
private Autodesk.Revit.ApplicationServices.Application? m_revit = null;
|
||||
private ThisApplication m_thisApp;
|
||||
#endregion
|
||||
|
||||
public ValidateParameters(ThisApplication thisApp)
|
||||
{
|
||||
m_thisApp = thisApp;
|
||||
m_revit = thisApp.ActiveUIDocument.Document.Application;
|
||||
}
|
||||
|
||||
#region Class Interface Implementation
|
||||
|
||||
/// <summary>
|
||||
/// Run
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
Document document = m_thisApp.ActiveUIDocument.Document;
|
||||
// only a family document can retrieve family manager
|
||||
if (document.IsFamilyDocument)
|
||||
{
|
||||
m_familyManager = document.FamilyManager;
|
||||
List<string> errorMessages = Validate(m_familyManager);
|
||||
using (MessageForm msgForm = new MessageForm(errorMessages.ToArray(), m_thisApp))
|
||||
{
|
||||
msgForm.StartPosition = FormStartPosition.CenterParent;
|
||||
msgForm.ShowDialog();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("Current document is not family document.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Class Implementation
|
||||
/// <summary>
|
||||
/// implementation of validate parameters, get all family types and parameters,
|
||||
/// use the function FamilyType.HasValue() to make sure if the parameter needs to
|
||||
/// validate. Then along to the storage type to validate the parameters.
|
||||
/// </summary>
|
||||
/// <returns>error information list</returns>
|
||||
public static List<string> Validate(FamilyManager familyManager)
|
||||
{
|
||||
List<string> errorInfo = new List<string>();
|
||||
// go though all parameters
|
||||
foreach (FamilyType type in familyManager.Types)
|
||||
{
|
||||
bool right = true;
|
||||
foreach (FamilyParameter para in familyManager.Parameters)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (type.HasValue(para))
|
||||
{
|
||||
switch (para.StorageType)
|
||||
{
|
||||
case StorageType.Double:
|
||||
if (!(type.AsDouble(para) is double))
|
||||
right = false;
|
||||
break;
|
||||
case StorageType.ElementId:
|
||||
try
|
||||
{
|
||||
ElementId elemId=type.AsElementId(para);
|
||||
}
|
||||
catch
|
||||
{
|
||||
right = false;
|
||||
}
|
||||
break;
|
||||
case StorageType.Integer:
|
||||
if (!(type.AsInteger(para) is int))
|
||||
right = false;
|
||||
break;
|
||||
case StorageType.String:
|
||||
if (!(type.AsString(para) is string))
|
||||
right = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// output the parameters which failed during validating.
|
||||
catch
|
||||
{
|
||||
errorInfo.Add("Family Type:" + type.Name + " Family Parameter:"
|
||||
+ para.Definition.Name + " validating failed!");
|
||||
}
|
||||
if (!right)
|
||||
{
|
||||
errorInfo.Add("Family Type:" + type.Name + " Family Parameter:"
|
||||
+ para.Definition.Name + " validating failed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
return errorInfo;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"ms-dotnettools.csharp",
|
||||
]
|
||||
}
|
||||
+15
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
]
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// (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 Autodesk;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.CapitalizeText.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// automatically replaces all text in text notes with capitalized text.
|
||||
/// </summary>
|
||||
public class CapitalizeText
|
||||
{
|
||||
private Document? m_doc = null;
|
||||
|
||||
/// <summary>
|
||||
/// Automatic print of all of a certain view type, to the default printer .
|
||||
/// </summary>
|
||||
private CapitalizeText()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ctor wit parameter used to call this sample.
|
||||
/// </summary>
|
||||
/// <param name="doc"></param>
|
||||
public CapitalizeText(ThisApplication hostDoc)
|
||||
{
|
||||
m_doc = hostDoc.ActiveUIDocument.Document;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// run this sample now
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
TextElement? text = null;
|
||||
|
||||
// filtrate the TextElment from the element set
|
||||
ElementClassFilter gridFilter = new ElementClassFilter(typeof(TextElement));
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_doc);
|
||||
collector.WherePasses(gridFilter);
|
||||
IList<Element> arrayText = collector.ToElements();
|
||||
|
||||
// matching and capitalizing
|
||||
int capitalizednum = 0;
|
||||
foreach (Element ee in arrayText)
|
||||
{
|
||||
text = ee as TextElement;
|
||||
if (text == null)
|
||||
continue;
|
||||
text.Text = text.Text.ToUpper();
|
||||
capitalizednum++;
|
||||
|
||||
}
|
||||
|
||||
// Show the number of notes modified.
|
||||
MessageBox.Show("Revit has completed its search and has made " + capitalizednum + " modifications.", "CapitalizeText");
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
MessageBox.Show(ee.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+523
@@ -0,0 +1,523 @@
|
||||
//
|
||||
// (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.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
using ELEMENT = Autodesk.Revit.DB.Element;
|
||||
using STRUCTURALTYPE = Autodesk.Revit.DB.Structure.StructuralType;
|
||||
using System.Diagnostics;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.CreateBeamsColumnsBraces.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Create Beams, Columns and Braces according to user's input information
|
||||
/// </summary>
|
||||
public class CreateBeamsColumnsBraces
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor without parameter is not allowed
|
||||
/// </summary>
|
||||
private CreateBeamsColumnsBraces() { }
|
||||
|
||||
/// <summary>
|
||||
/// ctor wit parameter used to call this sample
|
||||
/// </summary>
|
||||
/// <param name="hostApp"></param>
|
||||
public CreateBeamsColumnsBraces(ThisApplication? App)
|
||||
{
|
||||
m_app = App;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// run this sample now
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
//if initialize failed return Result.Failed
|
||||
bool initializeOK = Initialize();
|
||||
if (!initializeOK)
|
||||
{
|
||||
MessageBox.Show("Failed to start this sample!");
|
||||
return;
|
||||
}
|
||||
|
||||
using (CreateBeamsColumnsBracesForm displayForm = new CreateBeamsColumnsBracesForm(this))
|
||||
{
|
||||
displayForm.ShowDialog();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Class Members Variables
|
||||
ThisApplication? m_app = null;
|
||||
|
||||
ArrayList m_columnMaps = new ArrayList(); //list of columns' type
|
||||
ArrayList m_beamMaps = new ArrayList(); //list of beams' type
|
||||
ArrayList m_braceMaps = new ArrayList(); //list of braces' type
|
||||
SortedList levels = new SortedList(); //list of list sorted by their elevations
|
||||
|
||||
UV[,]? m_matrixUV; //2D coordinates of matrix
|
||||
#endregion
|
||||
|
||||
#region Class Properties and Methods
|
||||
/// <summary>
|
||||
/// list of all type of columns
|
||||
/// </summary>
|
||||
public ArrayList ColumnMaps
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_columnMaps;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// list of all type of beams
|
||||
/// </summary>
|
||||
public ArrayList BeamMaps
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_beamMaps;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// list of all type of braces
|
||||
/// </summary>
|
||||
public ArrayList BraceMaps
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_braceMaps;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// check the number of floors is less than the number of levels
|
||||
/// create beams, columns and braces according to selected types
|
||||
/// </summary>
|
||||
/// <param name="columnObject">type of column</param>
|
||||
/// <param name="beamObject">type of beam</param>
|
||||
/// <param name="braceObject">type of brace</param>
|
||||
/// <param name="floorNumber">number of floor</param>
|
||||
/// <returns>number of floors is less than the number of levels and create successfully then return true</returns>
|
||||
public bool AddInstance(object columnObject, object beamObject, object braceObject, int floorNumber)
|
||||
{
|
||||
//whether floor number less than levels number
|
||||
if (floorNumber >= levels.Count)
|
||||
{
|
||||
MessageBox.Show("The number of levels must be added.", "Revit");
|
||||
return false;
|
||||
}
|
||||
|
||||
FamilySymbol? columnSymbol = columnObject as FamilySymbol;
|
||||
FamilySymbol? beamSymbol = beamObject as FamilySymbol;
|
||||
FamilySymbol? braceSymbol = braceObject as FamilySymbol;
|
||||
|
||||
//any symbol is null then the command failed
|
||||
if (null == columnSymbol || null == beamSymbol || null == braceSymbol)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (m_matrixUV == null)
|
||||
return false;
|
||||
for (int k = 0; k < floorNumber; k++) //iterate levels from lower one to higher
|
||||
{
|
||||
Level? baseLevel = levels.GetByIndex(k) as Level;
|
||||
Level? topLevel = levels.GetByIndex(k + 1) as Level;
|
||||
|
||||
int matrixXSize = m_matrixUV.GetLength(0); //length of matrix's x range
|
||||
int matrixYSize = m_matrixUV.GetLength(1); //length of matrix's y range
|
||||
|
||||
//iterate coordinate both in x direction and y direction and create beams and braces
|
||||
for (int j = 0; j < matrixYSize; j++)
|
||||
{
|
||||
for (int i = 0; i < matrixXSize; i++)
|
||||
{
|
||||
//create beams and braces in x direction
|
||||
if (i != (matrixXSize - 1) && baseLevel != null && topLevel != null)
|
||||
{
|
||||
PlaceBrace(m_matrixUV[i, j], m_matrixUV[i + 1, j], baseLevel, topLevel, braceSymbol, true);
|
||||
}
|
||||
//create beams and braces in y direction
|
||||
if (j != (matrixYSize - 1) && baseLevel != null && topLevel != null)
|
||||
{
|
||||
PlaceBrace(m_matrixUV[i, j], m_matrixUV[i, j + 1], baseLevel, topLevel, braceSymbol, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < matrixYSize; j++)
|
||||
{
|
||||
for (int i = 0; i < matrixXSize; i++)
|
||||
{
|
||||
//create beams and braces in x direction
|
||||
if (i != (matrixXSize - 1) && baseLevel != null && topLevel != null)
|
||||
{
|
||||
PlaceBeam(m_matrixUV[i, j], m_matrixUV[i + 1, j], baseLevel, topLevel, beamSymbol);
|
||||
}
|
||||
//create beams and braces in y direction
|
||||
if (j != (matrixYSize - 1) && baseLevel != null && topLevel != null)
|
||||
{
|
||||
PlaceBeam(m_matrixUV[i, j], m_matrixUV[i, j + 1], baseLevel, topLevel, beamSymbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
//place column of this level
|
||||
foreach (UV point2D in m_matrixUV)
|
||||
{
|
||||
if (baseLevel != null && topLevel != null)
|
||||
PlaceColumn(point2D, columnSymbol, baseLevel, topLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// generate 2D coordinates of matrix according to parameters
|
||||
/// </summary>
|
||||
/// <param name="xNumber">Number of Columns in the X direction</param>
|
||||
/// <param name="yNumber">Number of Columns in the Y direction</param>
|
||||
/// <param name="distance">Distance between columns</param>
|
||||
public void CreateMatrix(int xNumber, int yNumber, double distance)
|
||||
{
|
||||
m_matrixUV = new UV[xNumber, yNumber];
|
||||
if (m_app != null)
|
||||
{
|
||||
for (int i = 0; i < xNumber; i++)
|
||||
{
|
||||
for (int j = 0; j < yNumber; j++)
|
||||
{
|
||||
object[] param = { i * distance, j * distance };
|
||||
m_matrixUV[i, j] = m_app.ActiveUIDocument.Document.Application.Create.NewUV(i * distance, j * distance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// iterate all the symbols of levels, columns, beams and braces
|
||||
/// </summary>
|
||||
/// <returns>A value that signifies if the initialization was successful for true or failed for false</returns>
|
||||
private bool Initialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_app == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ElementClassFilter levelFilter = new ElementClassFilter(typeof(Level));
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_app.ActiveUIDocument.Document);
|
||||
collector.WherePasses(levelFilter);
|
||||
IList<Element> arrayLevel = collector.ToElements();
|
||||
|
||||
foreach (Autodesk.Revit.DB.Element ee in arrayLevel)
|
||||
{
|
||||
Level? level = ee as Level;
|
||||
if (null != level)
|
||||
{
|
||||
levels.Add(level.Elevation, level);
|
||||
}
|
||||
}
|
||||
|
||||
ElementClassFilter filterFamily = new ElementClassFilter(typeof(Family));
|
||||
collector = new FilteredElementCollector(m_app.ActiveUIDocument.Document);
|
||||
collector.WherePasses(filterFamily);
|
||||
IList<Element> arrayFamily = collector.ToElements();
|
||||
|
||||
foreach (Autodesk.Revit.DB.Element ee in arrayFamily)
|
||||
{
|
||||
Family? f = ee as Family;
|
||||
if (null != f)
|
||||
{
|
||||
foreach (ElementId symbolId in f.GetFamilySymbolIds())
|
||||
{
|
||||
FamilySymbol? familyType = m_app.ActiveUIDocument.Document.GetElement(symbolId) as FamilySymbol;
|
||||
if (null == familyType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (null == familyType.Category)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//add symbols of beams and braces to lists
|
||||
string categoryName = familyType.Category.Name;
|
||||
if ("Structural Framing" == categoryName)
|
||||
{
|
||||
m_beamMaps.Add(new SymbolMap(familyType));
|
||||
m_braceMaps.Add(new SymbolMap(familyType));
|
||||
}
|
||||
else if ("Structural Columns" == categoryName)
|
||||
{
|
||||
m_columnMaps.Add(new SymbolMap(familyType));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// create column of certain type in certain position
|
||||
/// </summary>
|
||||
/// <param name="point2D">2D coordinate of the column</param>
|
||||
/// <param name="columnType">type of column</param>
|
||||
/// <param name="baseLevel">the base level of the column</param>
|
||||
/// <param name="topLevel">the top level of the colunm</param>
|
||||
private void PlaceColumn(UV point2D, FamilySymbol columnType, Level baseLevel, Level topLevel)
|
||||
{
|
||||
//create column of certain type in certain level and start point
|
||||
object[] xyzParam = { point2D.U, point2D.V, 0 };
|
||||
if (m_app == null)
|
||||
return;
|
||||
XYZ point = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ(point2D.U, point2D.V, 0);
|
||||
|
||||
//
|
||||
// create family instance now
|
||||
STRUCTURALTYPE structuralType;
|
||||
structuralType = Autodesk.Revit.DB.Structure.StructuralType.Column;
|
||||
FamilyInstance column = m_app.ActiveUIDocument.Document.Create.NewFamilyInstance(point, columnType, topLevel, structuralType);
|
||||
|
||||
//set baselevel & toplevel of the column
|
||||
if (null != column)
|
||||
{
|
||||
Parameter baseLevelParameter = column.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.FAMILY_BASE_LEVEL_PARAM);
|
||||
Parameter topLevelParameter = column.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.FAMILY_TOP_LEVEL_PARAM);
|
||||
Parameter topOffsetParameter = column.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM);
|
||||
Parameter baseOffsetParameter = column.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM);
|
||||
|
||||
if (null != baseLevelParameter)
|
||||
{
|
||||
Autodesk.Revit.DB.ElementId baseLevelId;
|
||||
baseLevelId = baseLevel.Id;
|
||||
baseLevelParameter.Set(baseLevelId);
|
||||
}
|
||||
|
||||
if (null != topLevelParameter)
|
||||
{
|
||||
Autodesk.Revit.DB.ElementId topLevelId;
|
||||
topLevelId = topLevel.Id;
|
||||
topLevelParameter.Set(topLevelId);
|
||||
}
|
||||
|
||||
if (null != topOffsetParameter)
|
||||
{
|
||||
topOffsetParameter.Set(0.0);
|
||||
}
|
||||
|
||||
if (null != baseOffsetParameter)
|
||||
{
|
||||
baseOffsetParameter.Set(0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// create beam of certain type in certain position
|
||||
/// </summary>
|
||||
/// <param name="point2D1">one point of the location line in 2D</param>
|
||||
/// <param name="point2D2">another point of the location line in 2D</param>
|
||||
/// <param name="baseLevel">the base level of the beam</param>
|
||||
/// <param name="topLevel">the top level of the beam</param>
|
||||
/// <param name="beamType">type of beam</param>
|
||||
/// <returns>nothing</returns>
|
||||
private void PlaceBeam(UV point2D1, UV point2D2, Level baseLevel, Level topLevel, FamilySymbol beamType)
|
||||
{
|
||||
// create start and end points for beam
|
||||
if (m_app == null)
|
||||
return;
|
||||
double height = topLevel.Elevation;
|
||||
XYZ startPoint = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ(point2D1.U, point2D1.V, height);
|
||||
XYZ endPoint = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ(point2D2.U, point2D2.V, height);
|
||||
ElementId topLevelId = topLevel.Id;
|
||||
|
||||
STRUCTURALTYPE structuralType = Autodesk.Revit.DB.Structure.StructuralType.Beam;
|
||||
FamilyInstance beam = m_app.ActiveUIDocument.Document.Create.NewFamilyInstance(startPoint, beamType, topLevel, structuralType);
|
||||
|
||||
LocationCurve? beamCurve = beam.Location as LocationCurve;
|
||||
if (null != beamCurve)
|
||||
{
|
||||
Line line = Line.CreateBound(startPoint, endPoint);
|
||||
beamCurve.Curve = line;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// create brace of certain type in certain position between two adjacent columns
|
||||
/// </summary>
|
||||
/// <param name="point2D1">one point of the location line in 2D</param>
|
||||
/// <param name="point2D2">another point of the location line in 2D</param>
|
||||
/// <param name="baseLevel">the base level of the brace</param>
|
||||
/// <param name="topLevel">the top level of the brace</param>
|
||||
/// <param name="braceType">type of beam</param>
|
||||
/// <param name="isXDirection">whether the location line is in x direction</param>
|
||||
private void PlaceBrace(UV point2D1, UV point2D2, Level baseLevel, Level topLevel, FamilySymbol braceType, bool isXDirection)
|
||||
{
|
||||
//get the start points and end points of location lines of two braces
|
||||
if (m_app == null)
|
||||
return;
|
||||
double topHeight = topLevel.Elevation;
|
||||
double baseHeight = baseLevel.Elevation;
|
||||
double middleElevation = (topHeight + baseHeight) / 2;
|
||||
double middleHeight = (topHeight - baseHeight) / 2;
|
||||
|
||||
XYZ startPoint = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ(point2D1.U, point2D1.V, middleElevation);
|
||||
XYZ endPoint = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ(point2D2.U, point2D2.V, middleElevation);
|
||||
XYZ middlePoint;
|
||||
|
||||
if (isXDirection)
|
||||
{
|
||||
middlePoint = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ((point2D1.U + point2D2.U) / 2, point2D2.V, topHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
middlePoint = middlePoint = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ(point2D2.U, (point2D1.V + point2D2.V) / 2, topHeight);
|
||||
}
|
||||
|
||||
//create two brace and set their location line
|
||||
STRUCTURALTYPE structuralType = Autodesk.Revit.DB.Structure.StructuralType.Brace;
|
||||
ElementId levelId = topLevel.Id;
|
||||
ElementId startLevelId = baseLevel.Id;
|
||||
ElementId endLevelId = topLevel.Id;
|
||||
|
||||
FamilyInstance firstBrace = m_app.ActiveUIDocument.Document.Create.NewFamilyInstance(startPoint, braceType, structuralType);
|
||||
LocationCurve? braceCurve1 = firstBrace.Location as LocationCurve;
|
||||
if (null != braceCurve1)
|
||||
{
|
||||
Line line = Line.CreateBound(startPoint, middlePoint);
|
||||
braceCurve1.Curve = line;
|
||||
}
|
||||
|
||||
Parameter referenceLevel1 = firstBrace.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM);
|
||||
if (null != referenceLevel1)
|
||||
{
|
||||
referenceLevel1.Set(levelId);
|
||||
}
|
||||
|
||||
FamilyInstance secondBrace = m_app.ActiveUIDocument.Document.Create.NewFamilyInstance(endPoint, braceType, baseLevel, structuralType);
|
||||
LocationCurve? braceCurve2 = secondBrace.Location as LocationCurve;
|
||||
if (null != braceCurve2)
|
||||
{
|
||||
Line line = Line.CreateBound(endPoint, middlePoint);
|
||||
braceCurve2.Curve = line;
|
||||
}
|
||||
|
||||
Parameter referenceLevel2 = secondBrace.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM);
|
||||
if (null != referenceLevel2)
|
||||
{
|
||||
referenceLevel2.Set(levelId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// assistant class contains symbol and it's name
|
||||
/// </summary>
|
||||
public class SymbolMap
|
||||
{
|
||||
string m_symbolName = "";
|
||||
FamilySymbol? m_symbol = null;
|
||||
|
||||
/// <summary>
|
||||
/// constructor without parameter is forbidden
|
||||
/// </summary>
|
||||
private SymbolMap()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="symbol">family symbol</param>
|
||||
public SymbolMap(FamilySymbol symbol)
|
||||
{
|
||||
m_symbol = symbol;
|
||||
string familyName = "";
|
||||
if (null != symbol.Family)
|
||||
{
|
||||
familyName = symbol.Family.Name;
|
||||
}
|
||||
m_symbolName = familyName + " : " + symbol.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SymbolName property
|
||||
/// </summary>
|
||||
public string SymbolName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_symbolName;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// ElementType property
|
||||
/// </summary>
|
||||
public FamilySymbol? ElementType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_symbol;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+506
@@ -0,0 +1,506 @@
|
||||
//
|
||||
// (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.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Revit.SDK.Samples.CreateBeamsColumnsBraces.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// UI
|
||||
/// </summary>
|
||||
public class CreateBeamsColumnsBracesForm : System.Windows.Forms.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container? components = null;
|
||||
private System.Windows.Forms.Button? OKButton;
|
||||
private System.Windows.Forms.TextBox? XTextBox;
|
||||
private System.Windows.Forms.TextBox? DistanceTextBox;
|
||||
private System.Windows.Forms.TextBox? YTextBox;
|
||||
private System.Windows.Forms.ComboBox? columnComboBox;
|
||||
private System.Windows.Forms.ComboBox? beamComboBox;
|
||||
private System.Windows.Forms.ComboBox? braceComboBox;
|
||||
private System.Windows.Forms.Button? cancelButton;
|
||||
private System.Windows.Forms.TextBox? floornumberTextBox;
|
||||
private System.Windows.Forms.Label? columnLabel;
|
||||
private System.Windows.Forms.Label? beamLabel;
|
||||
private System.Windows.Forms.Label? braceLabel;
|
||||
private System.Windows.Forms.Label? DistanceLabel;
|
||||
private System.Windows.Forms.Label? YLabel;
|
||||
private System.Windows.Forms.Label? XLabel;
|
||||
private System.Windows.Forms.Label? floornumberLabel;
|
||||
private System.Windows.Forms.Label? unitLabel;
|
||||
|
||||
// To store the datas
|
||||
CreateBeamsColumnsBraces? m_dataBuffer = null;
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="dataBuffer">the revit datas</param>
|
||||
public CreateBeamsColumnsBracesForm(CreateBeamsColumnsBraces? dataBuffer)
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
m_dataBuffer = dataBuffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
OKButton = new System.Windows.Forms.Button();
|
||||
XTextBox = new System.Windows.Forms.TextBox();
|
||||
YTextBox = new System.Windows.Forms.TextBox();
|
||||
DistanceTextBox = new System.Windows.Forms.TextBox();
|
||||
columnComboBox = new System.Windows.Forms.ComboBox();
|
||||
beamComboBox = new System.Windows.Forms.ComboBox();
|
||||
braceComboBox = new System.Windows.Forms.ComboBox();
|
||||
columnLabel = new System.Windows.Forms.Label();
|
||||
beamLabel = new System.Windows.Forms.Label();
|
||||
braceLabel = new System.Windows.Forms.Label();
|
||||
floornumberTextBox = new System.Windows.Forms.TextBox();
|
||||
DistanceLabel = new System.Windows.Forms.Label();
|
||||
YLabel = new System.Windows.Forms.Label();
|
||||
XLabel = new System.Windows.Forms.Label();
|
||||
floornumberLabel = new System.Windows.Forms.Label();
|
||||
cancelButton = new System.Windows.Forms.Button();
|
||||
unitLabel = new System.Windows.Forms.Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// OKButton
|
||||
//
|
||||
OKButton.Location = new System.Drawing.Point(296, 208);
|
||||
OKButton.Name = "OKButton";
|
||||
OKButton.Size = new System.Drawing.Size(75, 23);
|
||||
OKButton.TabIndex = 8;
|
||||
OKButton.Text = "&OK";
|
||||
OKButton.Click += new System.EventHandler(OKButton_Click);
|
||||
//
|
||||
// XTextBox
|
||||
//
|
||||
XTextBox.Location = new System.Drawing.Point(16, 96);
|
||||
XTextBox.Name = "XTextBox";
|
||||
XTextBox.Size = new System.Drawing.Size(136, 20);
|
||||
XTextBox.TabIndex = 2;
|
||||
XTextBox.Validating += new System.ComponentModel.CancelEventHandler(XTextBox_Validating);
|
||||
//
|
||||
// YTextBox
|
||||
//
|
||||
YTextBox.Location = new System.Drawing.Point(16, 152);
|
||||
YTextBox.Name = "YTextBox";
|
||||
YTextBox.Size = new System.Drawing.Size(136, 20);
|
||||
YTextBox.TabIndex = 3;
|
||||
YTextBox.Validating += new System.ComponentModel.CancelEventHandler(YTextBox_Validating);
|
||||
//
|
||||
// DistanceTextBox
|
||||
//
|
||||
DistanceTextBox.Location = new System.Drawing.Point(16, 40);
|
||||
DistanceTextBox.Name = "DistanceTextBox";
|
||||
DistanceTextBox.Size = new System.Drawing.Size(112, 20);
|
||||
DistanceTextBox.TabIndex = 1;
|
||||
DistanceTextBox.Validating += new System.ComponentModel.CancelEventHandler(DistanceTextBox_Validating);
|
||||
//
|
||||
// columnComboBox
|
||||
//
|
||||
columnComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
columnComboBox.Location = new System.Drawing.Point(240, 40);
|
||||
columnComboBox.Name = "columnComboBox";
|
||||
columnComboBox.Size = new System.Drawing.Size(288, 21);
|
||||
columnComboBox.TabIndex = 5;
|
||||
//
|
||||
// beamComboBox
|
||||
//
|
||||
beamComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
beamComboBox.Location = new System.Drawing.Point(240, 96);
|
||||
beamComboBox.Name = "beamComboBox";
|
||||
beamComboBox.Size = new System.Drawing.Size(288, 21);
|
||||
beamComboBox.TabIndex = 6;
|
||||
//
|
||||
// braceComboBox
|
||||
//
|
||||
braceComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
braceComboBox.Location = new System.Drawing.Point(240, 152);
|
||||
braceComboBox.Name = "braceComboBox";
|
||||
braceComboBox.Size = new System.Drawing.Size(288, 21);
|
||||
braceComboBox.TabIndex = 7;
|
||||
//
|
||||
// columnLabel
|
||||
//
|
||||
columnLabel.Location = new System.Drawing.Point(240, 16);
|
||||
columnLabel.Name = "columnLabel";
|
||||
columnLabel.Size = new System.Drawing.Size(120, 23);
|
||||
columnLabel.TabIndex = 10;
|
||||
columnLabel.Text = "Type of Columns:";
|
||||
//
|
||||
// beamLabel
|
||||
//
|
||||
beamLabel.Location = new System.Drawing.Point(240, 72);
|
||||
beamLabel.Name = "beamLabel";
|
||||
beamLabel.Size = new System.Drawing.Size(120, 23);
|
||||
beamLabel.TabIndex = 11;
|
||||
beamLabel.Text = "Type of Beams:";
|
||||
//
|
||||
// braceLabel
|
||||
//
|
||||
braceLabel.Location = new System.Drawing.Point(240, 128);
|
||||
braceLabel.Name = "braceLabel";
|
||||
braceLabel.Size = new System.Drawing.Size(120, 23);
|
||||
braceLabel.TabIndex = 12;
|
||||
braceLabel.Text = "Type of Braces:";
|
||||
//
|
||||
// floornumberTextBox
|
||||
//
|
||||
floornumberTextBox.Location = new System.Drawing.Point(16, 208);
|
||||
floornumberTextBox.Name = "floornumberTextBox";
|
||||
floornumberTextBox.Size = new System.Drawing.Size(112, 20);
|
||||
floornumberTextBox.TabIndex = 4;
|
||||
floornumberTextBox.Validating += new System.ComponentModel.CancelEventHandler(floornumberTextBox_Validating);
|
||||
//
|
||||
// DistanceLabel
|
||||
//
|
||||
DistanceLabel.Location = new System.Drawing.Point(16, 16);
|
||||
DistanceLabel.Name = "DistanceLabel";
|
||||
DistanceLabel.Size = new System.Drawing.Size(152, 23);
|
||||
DistanceLabel.TabIndex = 14;
|
||||
DistanceLabel.Text = "Distance between Columns:";
|
||||
//
|
||||
// YLabel
|
||||
//
|
||||
YLabel.Location = new System.Drawing.Point(16, 128);
|
||||
YLabel.Name = "YLabel";
|
||||
YLabel.Size = new System.Drawing.Size(200, 23);
|
||||
YLabel.TabIndex = 15;
|
||||
YLabel.Text = "Number of Columns in the Y Direction:";
|
||||
//
|
||||
// XLabel
|
||||
//
|
||||
XLabel.Location = new System.Drawing.Point(16, 72);
|
||||
XLabel.Name = "XLabel";
|
||||
XLabel.Size = new System.Drawing.Size(200, 23);
|
||||
XLabel.TabIndex = 16;
|
||||
XLabel.Text = "Number of Columns in the X Direction:";
|
||||
//
|
||||
// floornumberLabel
|
||||
//
|
||||
floornumberLabel.Location = new System.Drawing.Point(16, 184);
|
||||
floornumberLabel.Name = "floornumberLabel";
|
||||
floornumberLabel.Size = new System.Drawing.Size(144, 23);
|
||||
floornumberLabel.TabIndex = 17;
|
||||
floornumberLabel.Text = "Number of Floors:";
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
cancelButton.Location = new System.Drawing.Point(392, 208);
|
||||
cancelButton.Name = "cancelButton";
|
||||
cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
cancelButton.TabIndex = 9;
|
||||
cancelButton.Text = "&Cancel";
|
||||
cancelButton.Click += new System.EventHandler(cancelButton_Click);
|
||||
//
|
||||
// unitLabel
|
||||
//
|
||||
unitLabel.Location = new System.Drawing.Point(136, 42);
|
||||
unitLabel.Name = "unitLabel";
|
||||
unitLabel.Size = new System.Drawing.Size(32, 23);
|
||||
unitLabel.TabIndex = 18;
|
||||
unitLabel.Text = "feet";
|
||||
//
|
||||
// CreateBeamsColumnsBracesForm
|
||||
//
|
||||
AcceptButton = OKButton;
|
||||
AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
||||
CancelButton = cancelButton;
|
||||
ClientSize = new System.Drawing.Size(546, 246);
|
||||
Controls.Add(unitLabel);
|
||||
Controls.Add(cancelButton);
|
||||
Controls.Add(floornumberLabel);
|
||||
Controls.Add(XLabel);
|
||||
Controls.Add(YLabel);
|
||||
Controls.Add(DistanceLabel);
|
||||
Controls.Add(floornumberTextBox);
|
||||
Controls.Add(DistanceTextBox);
|
||||
Controls.Add(YTextBox);
|
||||
Controls.Add(XTextBox);
|
||||
Controls.Add(braceLabel);
|
||||
Controls.Add(beamLabel);
|
||||
Controls.Add(columnLabel);
|
||||
Controls.Add(braceComboBox);
|
||||
Controls.Add(beamComboBox);
|
||||
Controls.Add(columnComboBox);
|
||||
Controls.Add(OKButton);
|
||||
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
Name = "CreateBeamsColumnsBracesForm";
|
||||
ShowInTaskbar = false;
|
||||
StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
Text = "Create Beams Columns and Braces";
|
||||
Load += new System.EventHandler(CreateBeamsColumnsBracesForm_Load);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Refresh the text box for the default datas
|
||||
/// </summary>
|
||||
private void TextBoxRefresh()
|
||||
{
|
||||
if (XTextBox != null && YTextBox != null && DistanceTextBox != null && floornumberTextBox != null)
|
||||
{
|
||||
XTextBox.Text = "2";
|
||||
YTextBox.Text = "2";
|
||||
DistanceTextBox.Text = "20.0";
|
||||
floornumberTextBox.Text = "1";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void CreateBeamsColumnsBracesForm_Load(object? sender, System.EventArgs e)
|
||||
{
|
||||
TextBoxRefresh();
|
||||
if (columnComboBox == null || beamComboBox == null || braceComboBox == null)
|
||||
return;
|
||||
bool notLoadSymbol = false;
|
||||
if (0 == m_dataBuffer?.ColumnMaps.Count)
|
||||
{
|
||||
MessageBox.Show("No Structural Columns family is loaded in the project, please load one firstly.", "Revit");
|
||||
notLoadSymbol = true;
|
||||
}
|
||||
if (0 == m_dataBuffer?.BeamMaps.Count)
|
||||
{
|
||||
MessageBox.Show("No Structural Framing family is loaded in the project, please load one firstly.", "Revit");
|
||||
notLoadSymbol = true;
|
||||
}
|
||||
|
||||
if (notLoadSymbol)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
columnComboBox.DataSource = m_dataBuffer?.ColumnMaps;
|
||||
columnComboBox.DisplayMember = "SymbolName";
|
||||
columnComboBox.ValueMember = "ElementType";
|
||||
|
||||
beamComboBox.DataSource = m_dataBuffer?.BeamMaps;
|
||||
beamComboBox.DisplayMember = "SymbolName";
|
||||
beamComboBox.ValueMember = "ElementType";
|
||||
|
||||
braceComboBox.DataSource = m_dataBuffer?.BraceMaps;
|
||||
braceComboBox.DisplayMember = "SymbolName";
|
||||
braceComboBox.ValueMember = "ElementType";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// accept use's inpurt and create columns, beams and braces
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OKButton_Click(object? sender, System.EventArgs e)
|
||||
{
|
||||
//check whether the input is correct and create elements
|
||||
try
|
||||
{
|
||||
if (XTextBox == null || YTextBox == null || DistanceTextBox == null || columnComboBox == null || beamComboBox == null || braceComboBox == null || floornumberTextBox == null)
|
||||
return;
|
||||
int xNumber = int.Parse(XTextBox.Text);
|
||||
int yNumber = int.Parse(YTextBox.Text);
|
||||
double distance = double.Parse(DistanceTextBox.Text);
|
||||
object? columnType = columnComboBox.SelectedValue;
|
||||
object? beamType = beamComboBox.SelectedValue;
|
||||
object? braceType = braceComboBox.SelectedValue;
|
||||
int floorNumber = int.Parse(floornumberTextBox.Text);
|
||||
if (columnType != null && beamType != null && braceType != null)
|
||||
{
|
||||
m_dataBuffer?.CreateMatrix(xNumber, yNumber, distance);
|
||||
m_dataBuffer?.AddInstance(columnType, beamType, braceType, floorNumber);
|
||||
}
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Please input datas correctly.", "Revit");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// cancel the command
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void cancelButton_Click(object? sender, System.EventArgs? e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify the distance
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DistanceTextBox_Validating(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (DistanceTextBox == null)
|
||||
return;
|
||||
double distance = 0.1;
|
||||
try
|
||||
{
|
||||
distance = double.Parse(DistanceTextBox.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Please enter a value larger than 5 and less than 30000.", "Revit");
|
||||
DistanceTextBox.Text = "";
|
||||
DistanceTextBox.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (distance <= 5)
|
||||
{
|
||||
MessageBox.Show("Please enter a value larger than 5.", "Revit");
|
||||
DistanceTextBox.Text = "";
|
||||
DistanceTextBox.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (distance > 30000)
|
||||
{
|
||||
MessageBox.Show("Please enter a value less than 30000.", "Revit");
|
||||
DistanceTextBox.Text = "";
|
||||
DistanceTextBox.Focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify the number of X direction
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void XTextBox_Validating(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (XTextBox == null)
|
||||
return;
|
||||
int xNumber = 1;
|
||||
try
|
||||
{
|
||||
xNumber = int.Parse(XTextBox.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Please input an integer for X direction between 1 to 20.", "Revit");
|
||||
XTextBox.Text = "";
|
||||
}
|
||||
if (xNumber < 1 || xNumber > 20)
|
||||
{
|
||||
MessageBox.Show("Please input an integer for X direction between 1 to 20.", "Revit");
|
||||
XTextBox.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify the number of Y direction
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void YTextBox_Validating(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (YTextBox == null)
|
||||
return;
|
||||
int yNumber = 1;
|
||||
try
|
||||
{
|
||||
yNumber = int.Parse(YTextBox.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Please input an integer for Y direction between 1 to 20.", "Revit");
|
||||
YTextBox.Text = "";
|
||||
}
|
||||
if (yNumber < 1 || yNumber > 20)
|
||||
{
|
||||
MessageBox.Show("Please input an integer for Y direction between 1 to 20.", "Revit");
|
||||
YTextBox.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify the number of floors
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void floornumberTextBox_Validating(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (floornumberTextBox == null)
|
||||
return;
|
||||
int floorNumber = 1;
|
||||
try
|
||||
{
|
||||
floorNumber = int.Parse(floornumberTextBox.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Please input an integer for the number of floors between 1 to 10.", "Revit");
|
||||
floornumberTextBox.Text = "";
|
||||
}
|
||||
if (floorNumber < 1 || floorNumber > 10)
|
||||
{
|
||||
MessageBox.Show("Please input an integer for the number of floors between 1 to 10.", "Revit");
|
||||
floornumberTextBox.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
+111
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Delete the elements that were selected
|
||||
/// </summary>
|
||||
public class DeleteObject
|
||||
{
|
||||
ThisApplication? m_app; //ThisDocument data for Macro
|
||||
|
||||
/// <summary>
|
||||
/// Ctro without parameter is not allowed
|
||||
/// </summary>
|
||||
private DeleteObject()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ctor with ThisDocument as
|
||||
/// </summary>
|
||||
/// <param name="hostApp">ThisDocument handler</param>
|
||||
public DeleteObject(ThisApplication App)
|
||||
{
|
||||
m_app = App;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run this sample
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
if (m_app == null)
|
||||
return;
|
||||
ICollection<ElementId> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+455
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Data class which stores information for creating orthogonal grids
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// X coordinate of origin
|
||||
/// </summary>
|
||||
public double XOrigin
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_xOrigin;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_xOrigin = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Y coordinate of origin
|
||||
/// </summary>
|
||||
public double YOrigin
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_yOrigin;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_yOrigin = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spacing between horizontal grids
|
||||
/// </summary>
|
||||
public double XSpacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_xSpacing;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_xSpacing = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spacing between vertical grids
|
||||
/// </summary>
|
||||
public double YSpacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ySpacing;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_ySpacing = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of horizontal grids
|
||||
/// </summary>
|
||||
public uint XNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_xNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_xNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of vertical grids
|
||||
/// </summary>
|
||||
public uint YNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_yNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_yNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bubble location of horizontal grids
|
||||
/// </summary>
|
||||
public BubbleLocation XBubbleLoc
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_xBubbleLoc;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_xBubbleLoc = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bubble location of vertical grids
|
||||
/// </summary>
|
||||
public BubbleLocation YBubbleLoc
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_yBubbleLoc;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_yBubbleLoc = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Label of first horizontal grid
|
||||
/// </summary>
|
||||
public String XFirstLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_xFirstLabel == null ? string.Empty : m_xFirstLabel;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_xFirstLabel = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Label of first vertical grid
|
||||
/// </summary>
|
||||
public String YFirstLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_yFirstLabel == null ? string.Empty : m_yFirstLabel;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_yFirstLabel = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get array list contains all grid labels in current document
|
||||
/// </summary>
|
||||
public ArrayList LabelsList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_labelsList;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current display unit type
|
||||
/// </summary>
|
||||
public ForgeTypeId? Unit
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_unit;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="application">Application object</param>
|
||||
/// <param name="unit">Current length display unit type</param>
|
||||
/// <param name="labels">All existing labels in Revit's document</param>
|
||||
public CreateOrthogonalGridsData(ThisApplication? thisApp, ForgeTypeId? unit, ArrayList labels)
|
||||
{
|
||||
m_thisApp = thisApp;
|
||||
m_labelsList = labels;
|
||||
m_unit = unit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create grids
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create horizontal grids
|
||||
/// </summary>
|
||||
/// <param name="failureReasons">ArrayList contains failure reasons</param>
|
||||
/// <returns>Number of grids failed to create</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create vertical grids
|
||||
/// </summary>
|
||||
/// <param name="failureReasons">ArrayList contains failure reasons</param>
|
||||
/// <returns>Number of grids failed to create</returns>
|
||||
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
|
||||
}
|
||||
}
|
||||
+425
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
+173
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The dialog which provides the options of creating orthogonal grids
|
||||
/// </summary>
|
||||
public partial class CreateOrthogonalGridsForm : Form
|
||||
{
|
||||
// data class object
|
||||
private CreateOrthogonalGridsData m_data;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="data">Data class object</param>
|
||||
public CreateOrthogonalGridsForm(CreateOrthogonalGridsData data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
InitializeComponent();
|
||||
// Set state of controls
|
||||
InitializeControls();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set state of controls
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transfer data back into data class
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if input are validated
|
||||
/// </summary>
|
||||
/// <returns>Whether input is validated</returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
+598
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The dialog which provides the options of creating radial and arc grids
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// X coordinate of origin
|
||||
/// </summary>
|
||||
public double XOrigin
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_xOrigin;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_xOrigin = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Y coordinate of origin
|
||||
/// </summary>
|
||||
public double YOrigin
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_yOrigin;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_yOrigin = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start degree of arc grids and radial grids
|
||||
/// </summary>
|
||||
public double StartDegree
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_startDegree;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_startDegree = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// End degree of arc grids and radial grids
|
||||
/// </summary>
|
||||
public double EndDegree
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_endDegree;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_endDegree = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spacing between arc grids
|
||||
/// </summary>
|
||||
public double ArcSpacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_arcSpacing;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_arcSpacing = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of arc grids
|
||||
/// </summary>
|
||||
public uint ArcNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_arcNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_arcNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of radial grids
|
||||
/// </summary>
|
||||
public uint LineNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_lineNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_lineNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Radius of first arc grid
|
||||
/// </summary>
|
||||
public double ArcFirstRadius
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_arcFirstRadius;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_arcFirstRadius = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Distance from origin to start point
|
||||
/// </summary>
|
||||
public double LineFirstDistance
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LineFirstDistance;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_LineFirstDistance = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bubble location of arc grids
|
||||
/// </summary>
|
||||
public BubbleLocation ArcFirstBubbleLoc
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_arcFirstBubbleLoc;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_arcFirstBubbleLoc = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bubble location of radial grids
|
||||
/// </summary>
|
||||
public BubbleLocation LineFirstBubbleLoc
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_lineFirstBubbleLoc;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_lineFirstBubbleLoc = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Label of first arc grid
|
||||
/// </summary>
|
||||
public String ArcFirstLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_arcFirstLabel;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_arcFirstLabel = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Label of first radial grid
|
||||
/// </summary>
|
||||
public String LineFirstLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_lineFirstLabel;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_lineFirstLabel = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get array list contains all grid labels in current document
|
||||
/// </summary>
|
||||
public ArrayList LabelsList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_labelsList;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current display unit type
|
||||
/// </summary>
|
||||
public ForgeTypeId? Unit
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_unit;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="application">Application object</param>
|
||||
/// <param name="unit">Current length display unit type</param>
|
||||
/// <param name="labels">All existing labels in Revit's document</param>
|
||||
public CreateRadialAndArcGridsData(ThisApplication? app, ForgeTypeId? unit, ArrayList labels)
|
||||
{
|
||||
m_app = app;
|
||||
m_labelsList = labels;
|
||||
m_unit = unit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create grids
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create radial grids
|
||||
/// </summary>
|
||||
/// <returns>Number of grids failed to create</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create Arc Grids
|
||||
/// </summary>
|
||||
/// <param name="failureReasons">ArrayList contains failure reasons</param>
|
||||
/// <returns>Number of grids failed to create</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an arc grid with its origin, radius, start degree, end degree and bubble location
|
||||
/// </summary>
|
||||
/// <param name="origin">Arc grid's origin</param>
|
||||
/// <param name="radius">Arc grid's radius</param>
|
||||
/// <param name="startDegree">Arc grid's start degree</param>
|
||||
/// <param name="endDegree">Arc grid's end degree</param>
|
||||
/// <param name="bubLoc">Arc grid's Bubble location</param>
|
||||
/// <returns>The newly created grid</returns>
|
||||
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
|
||||
}
|
||||
}
|
||||
+546
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The dialog which provides the options of creating radial and arc grids
|
||||
/// </summary>
|
||||
partial class CreateRadialAndArcGridsForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+213
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="data">Data class object</param>
|
||||
public CreateRadialAndArcGridsForm(CreateRadialAndArcGridsData data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
InitializeComponent();
|
||||
// Set state of controls
|
||||
InitializeControls();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set state of controls
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transfer data back into data class
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if input are validated
|
||||
/// </summary>
|
||||
/// <returns>Whether input is validated</returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
+183
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
+95
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The dialog which provides the options of creating grids with selected lines/arcs
|
||||
/// </summary>
|
||||
public partial class CreateWithSelectedCurvesForm : Form
|
||||
{
|
||||
// data class object
|
||||
private CreateWithSelectedCurvesData m_data;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="data">Data class object</param>
|
||||
public CreateWithSelectedCurvesForm(CreateWithSelectedCurvesData data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
InitializeComponent();
|
||||
// Set state of controls
|
||||
InitializeControls();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set state of controls
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if input are validated
|
||||
/// </summary>
|
||||
/// <returns>Whether input is validated</returns>
|
||||
private bool ValidateValues()
|
||||
{
|
||||
return Validation.ValidateLabel(textBoxFirstLabel, m_data.LabelsList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transfer data back into data class
|
||||
/// </summary>
|
||||
private void SetData()
|
||||
{
|
||||
m_data.BubbleLocation = (BubbleLocation)comboBoxBubbleLocation.SelectedIndex;
|
||||
m_data.FirstLabel = textBoxFirstLabel.Text;
|
||||
m_data.DeleteSelectedElements = checkBoxDeleteElements.Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
+386
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The dialog which provides the options of creating grids with selected lines/arcs
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Whether to delete selected lines/arc after creation
|
||||
/// </summary>
|
||||
public bool DeleteSelectedElements
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_deleteSelectedElements;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_deleteSelectedElements = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bubble location of grids
|
||||
/// </summary>
|
||||
public BubbleLocation BubbleLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bubbleLocation;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_bubbleLocation = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Label of first grid
|
||||
/// </summary>
|
||||
public String FirstLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_firstLabel;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_firstLabel = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get array list contains all grid labels in current document
|
||||
/// </summary>
|
||||
public ArrayList LabelsList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_labelsList;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="application">Revit application</param>
|
||||
/// <param name="selectedCurves">Array contains geometry curves of selected lines or arcs </param>
|
||||
/// <param name="labels">List contains all existing labels in Revit document</param>
|
||||
public CreateWithSelectedCurvesData(ThisApplication? thisApp, CurveArray? selectedCurves, ArrayList labels)
|
||||
{
|
||||
m_thisApp = thisApp;
|
||||
m_revit = thisApp?.ActiveUIDocument.Document.Application;
|
||||
|
||||
m_selectedCurves = selectedCurves;
|
||||
m_labelsList = labels;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create grids
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create two grids if the selected curve is a circle
|
||||
/// </summary>
|
||||
/// <param name="arc">The circular curve to be transferred to grid</param>
|
||||
/// <param name="gridUpper">The grid to be created base on the upper part of the circular curve</param>
|
||||
/// <param name="gridLower">The grid to be created base on the lower part of the circular curve</param>
|
||||
/// <param name="isFirst">Whether the circular curve is the first curve to be transferred</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create arc grid
|
||||
/// </summary>
|
||||
/// <param name="arc">The arc curve to be transferred to grid</param>
|
||||
/// <returns>The newly created grid</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create linear grid
|
||||
/// </summary>
|
||||
/// <param name="line">The linear curve to be transferred to grid</param>
|
||||
/// <returns>The newly created grid</returns>
|
||||
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
|
||||
}
|
||||
}
|
||||
+72
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// An enumerate type listing the ways to create grids.
|
||||
/// </summary>
|
||||
public enum CreateMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Create grids with selected lines/arcs
|
||||
/// </summary>
|
||||
Select,
|
||||
/// <summary>
|
||||
/// Create orthogonal grids
|
||||
/// </summary>
|
||||
Orthogonal,
|
||||
/// <summary>
|
||||
/// Create radial and arc grids
|
||||
/// </summary>
|
||||
RadialAndArc
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An enumerate type listing bubble locations of grids.
|
||||
/// </summary>
|
||||
public enum BubbleLocation
|
||||
{
|
||||
/// <summary>
|
||||
/// Place bubble at the start point
|
||||
/// </summary>
|
||||
StartPoint,
|
||||
/// <summary>
|
||||
/// Place bubble at the end point
|
||||
/// </summary>
|
||||
EndPoint
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class contains common const values
|
||||
/// </summary>
|
||||
static class Values
|
||||
{
|
||||
public const double PI = 3.1415926535897900;
|
||||
// ratio from degree to radian
|
||||
public const double DEGTORAD = PI / 180;
|
||||
}
|
||||
}
|
||||
+247
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements the Revit add-in interface IExternalCommand
|
||||
/// </summary>
|
||||
public class GridCreation
|
||||
{
|
||||
#region
|
||||
ThisApplication? m_app;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor without parameter is not allowed
|
||||
/// </summary>
|
||||
private GridCreation()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GridCreation init
|
||||
/// </summary>
|
||||
/// <param name="hostApp"></param>
|
||||
public GridCreation(ThisApplication App)
|
||||
{
|
||||
m_app = App;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run this sample now
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all selected lines and arcs
|
||||
/// </summary>
|
||||
/// <param name="document">Revit's document</param>
|
||||
/// <returns>CurveArray contains all selected lines and arcs</returns>
|
||||
private CurveArray? GetSelectedCurves(ThisApplication? document)
|
||||
{
|
||||
CurveArray? selectedCurves = m_app?.ActiveUIDocument.Document.Application.Create.NewCurveArray();
|
||||
ICollection<ElementId>? 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all model and detail lines/arcs within selected elements
|
||||
/// </summary>
|
||||
/// <param name="document">Revit's document</param>
|
||||
/// <returns>ElementSet contains all model and detail lines/arcs within selected elements </returns>
|
||||
public static ICollection<ElementId> GetSelectedModelLinesAndArcs(ThisApplication thisDocument)
|
||||
{
|
||||
var tmpIds = new List<ElementId>();
|
||||
ICollection<ElementId> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get current length display unit type
|
||||
/// </summary>
|
||||
/// <param name="document">Revit's document</param>
|
||||
/// <returns>Current length display unit type</returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all grid labels in current document
|
||||
/// </summary>
|
||||
/// <param name="document">Revit's document</param>
|
||||
/// <returns>ArrayList contains all grid labels in current document</returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+83
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Data class which stores the information of the way to create grids
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Creating mode
|
||||
/// </summary>
|
||||
public CreateMode CreateGridsMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_createGridsMode;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_createGridsMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// State whether lines/arcs have been selected
|
||||
/// </summary>
|
||||
public bool HasSelectedLinesOrArcs
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_hasSelectedLinesOrArcs;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="hasSelectedLinesOrArcs">Whether lines or arcs have been selected</param>
|
||||
public GridCreationOptionData(bool hasSelectedLinesOrArcs)
|
||||
{
|
||||
m_hasSelectedLinesOrArcs = hasSelectedLinesOrArcs;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+160
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
+81
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The dialog which lets user choose the way to create grids
|
||||
/// </summary>
|
||||
public partial class GridCreationOptionForm : Form
|
||||
{
|
||||
// data class object
|
||||
private GridCreationOptionData m_gridCreationOption;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="opt">Data class object</param>
|
||||
public GridCreationOptionForm(GridCreationOptionData opt)
|
||||
{
|
||||
m_gridCreationOption = opt;
|
||||
|
||||
InitializeComponent();
|
||||
// Set state of controls
|
||||
InitializeControls();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set state of controls
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transfer data back into data class
|
||||
/// </summary>
|
||||
private void SetData()
|
||||
{
|
||||
m_gridCreationOption.CreateGridsMode = radioButtonSelect.Checked ? CreateMode.Select :
|
||||
(radioButtonOrthogonalGrids.Checked ? CreateMode.Orthogonal : CreateMode.RadialAndArc);
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
+567
@@ -0,0 +1,567 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace MacroCSharpSamples.GridCreation.GridCreationProperties
|
||||
{
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// 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()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Please adjust the values and try again!.
|
||||
/// </summary>
|
||||
internal static string AjustValues
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("AjustValues", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Coordinate can not be null!.
|
||||
/// </summary>
|
||||
internal static string CoordinateCannotBeNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("CoordinateCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Coordinate is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string CoordinateFormatWrong
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("CoordinateFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree can not be negative!.
|
||||
/// </summary>
|
||||
internal static string DegreeCannotBeNegative
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DegreeCannotBeNegative", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree can not be null!.
|
||||
/// </summary>
|
||||
internal static string DegreeCannotBeNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DegreeCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string DegreeFormatWrong
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DegreeFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Start degree and end degree can not be so close!.
|
||||
/// </summary>
|
||||
internal static string DegreesAreTooClose
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DegreesAreTooClose", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree should be within the range of 0 - 360!.
|
||||
/// </summary>
|
||||
internal static string DegreeWithin0To360
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DegreeWithin0To360", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Distance can not be negative!.
|
||||
/// </summary>
|
||||
internal static string DistanceCannotBeNegative
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DistanceCannotBeNegative", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Distance can not be null!.
|
||||
/// </summary>
|
||||
internal static string DistanceCannotBeNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DistanceCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Distance is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string DistanceFormatWrong
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DistanceFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to cm.
|
||||
/// </summary>
|
||||
internal static string DUT_CENTIMETERS
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_CENTIMETERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to '.
|
||||
/// </summary>
|
||||
internal static string DUT_DECIMAL_FEET
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_DECIMAL_FEET", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ".
|
||||
/// </summary>
|
||||
internal static string DUT_DECIMAL_INCHES
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_DECIMAL_INCHES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to '.
|
||||
/// </summary>
|
||||
internal static string DUT_FEET_FRACTIONAL_INCHES
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_FEET_FRACTIONAL_INCHES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ".
|
||||
/// </summary>
|
||||
internal static string DUT_FRACTIONAL_INCHES
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_FRACTIONAL_INCHES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to m.
|
||||
/// </summary>
|
||||
internal static string DUT_METERS
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_METERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to m.
|
||||
/// </summary>
|
||||
internal static string DUT_METERS_CENTIMETERS
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_METERS_CENTIMETERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to mm.
|
||||
/// </summary>
|
||||
internal static string DUT_MILLIMETERS
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_MILLIMETERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to - Start point and end point of arc grids are too close.
|
||||
/// </summary>
|
||||
internal static string EndPointsTooClose
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("EndPointsTooClose", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to create one or more arc grids..
|
||||
/// </summary>
|
||||
internal static string FailedToCreateArcGrids
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailedToCreateArcGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to create one or more grids. .
|
||||
/// </summary>
|
||||
internal static string FailedToCreateGrids
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailedToCreateGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to create one or more radial grids. .
|
||||
/// </summary>
|
||||
internal static string FailedToCreateRadialGrids
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailedToCreateRadialGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to delete some of the selected lines or arcs!.
|
||||
/// </summary>
|
||||
internal static string FailedToDeletedLinesOrArcs
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailedToDeletedLinesOrArcs", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to set label of grid to : .
|
||||
/// </summary>
|
||||
internal static string FailedToSetLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailedToSetLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to Create Grids.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionCreateGrids
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailureCaptionCreateGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to Delete Lines/Arcs.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionDeletedLinesOrArcs
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailureCaptionDeletedLinesOrArcs", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Invalid Value.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionInvalidValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailureCaptionInvalidValue", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to Set Label.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionSetLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailureCaptionSetLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Label can not be null!.
|
||||
/// </summary>
|
||||
internal static string LabelCannotBeNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("LabelCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to A same label has already existed!.
|
||||
/// </summary>
|
||||
internal static string LabelExisted
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("LabelExisted", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The two labels can't be same!.
|
||||
/// </summary>
|
||||
internal static string LabelsCannotBeSame
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("LabelsCannotBeSame", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Number should be an integer between 0 and 200!.
|
||||
/// </summary>
|
||||
internal static string NumberBetween0And200
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("NumberBetween0And200", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Number can not be null!.
|
||||
/// </summary>
|
||||
internal static string NumberCannotBeNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("NumberCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Number is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string NumberFormatWrong
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("NumberFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The two numbers can not be both zero!.
|
||||
/// </summary>
|
||||
internal static string NumbersCannotBeBothZero
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("NumbersCannotBeBothZero", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Radius can not be negative or zero!.
|
||||
/// </summary>
|
||||
internal static string RadiusCannotBeNegativeOrZero
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("RadiusCannotBeNegativeOrZero", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Radius can not be null!.
|
||||
/// </summary>
|
||||
internal static string RadiusCannotBeNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("RadiusCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Radius is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string RadiusFormatWrong
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("RadiusFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to That may be caused by one or more of following reasons:.
|
||||
/// </summary>
|
||||
internal static string Reasons
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("Reasons", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Spacing can not be negative or zero!.
|
||||
/// </summary>
|
||||
internal static string SpacingCannotBeNegativeOrZero
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("SpacingCannotBeNegativeOrZero", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Spacing can not be null!.
|
||||
/// </summary>
|
||||
internal static string SpacingCannotBeNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("SpacingCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Spacing is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string SpacingFormatWrong
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("SpacingFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to - Spacings between grids are too small.
|
||||
/// </summary>
|
||||
internal static string SpacingsTooSmall
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("SpacingsTooSmall", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Start degree should be less than end degree!.
|
||||
/// </summary>
|
||||
internal static string StartDegreeShouldBeLessThanEndDegree
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("StartDegreeShouldBeLessThanEndDegree", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+255
File diff suppressed because one or more lines are too long
+469
@@ -0,0 +1,469 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Revit.SDK.Samples.GridCreation.Properties
|
||||
{
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// 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() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Please adjust the values and try again!.
|
||||
/// </summary>
|
||||
internal static string AjustValues {
|
||||
get {
|
||||
return ResourceManager.GetString("AjustValues", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Coordinate can not be null!.
|
||||
/// </summary>
|
||||
internal static string CoordinateCannotBeNull {
|
||||
get {
|
||||
return ResourceManager.GetString("CoordinateCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Coordinate is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string CoordinateFormatWrong {
|
||||
get {
|
||||
return ResourceManager.GetString("CoordinateFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree can not be negative!.
|
||||
/// </summary>
|
||||
internal static string DegreeCannotBeNegative {
|
||||
get {
|
||||
return ResourceManager.GetString("DegreeCannotBeNegative", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree can not be null!.
|
||||
/// </summary>
|
||||
internal static string DegreeCannotBeNull {
|
||||
get {
|
||||
return ResourceManager.GetString("DegreeCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string DegreeFormatWrong {
|
||||
get {
|
||||
return ResourceManager.GetString("DegreeFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Start degree and end degree can not be so close!.
|
||||
/// </summary>
|
||||
internal static string DegreesAreTooClose {
|
||||
get {
|
||||
return ResourceManager.GetString("DegreesAreTooClose", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree should be within the range of 0 - 360!.
|
||||
/// </summary>
|
||||
internal static string DegreeWithin0To360 {
|
||||
get {
|
||||
return ResourceManager.GetString("DegreeWithin0To360", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Distance can not be negative!.
|
||||
/// </summary>
|
||||
internal static string DistanceCannotBeNegative {
|
||||
get {
|
||||
return ResourceManager.GetString("DistanceCannotBeNegative", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Distance can not be null!.
|
||||
/// </summary>
|
||||
internal static string DistanceCannotBeNull {
|
||||
get {
|
||||
return ResourceManager.GetString("DistanceCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Distance is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string DistanceFormatWrong {
|
||||
get {
|
||||
return ResourceManager.GetString("DistanceFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to cm.
|
||||
/// </summary>
|
||||
internal static string DUT_CENTIMETERS {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_CENTIMETERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to '.
|
||||
/// </summary>
|
||||
internal static string DUT_DECIMAL_FEET {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_DECIMAL_FEET", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ".
|
||||
/// </summary>
|
||||
internal static string DUT_DECIMAL_INCHES {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_DECIMAL_INCHES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to '.
|
||||
/// </summary>
|
||||
internal static string DUT_FEET_FRACTIONAL_INCHES {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_FEET_FRACTIONAL_INCHES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ".
|
||||
/// </summary>
|
||||
internal static string DUT_FRACTIONAL_INCHES {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_FRACTIONAL_INCHES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to m.
|
||||
/// </summary>
|
||||
internal static string DUT_METERS {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_METERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to m.
|
||||
/// </summary>
|
||||
internal static string DUT_METERS_CENTIMETERS {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_METERS_CENTIMETERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to mm.
|
||||
/// </summary>
|
||||
internal static string DUT_MILLIMETERS {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_MILLIMETERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to - Start point and end point of arc grids are too close.
|
||||
/// </summary>
|
||||
internal static string EndPointsTooClose {
|
||||
get {
|
||||
return ResourceManager.GetString("EndPointsTooClose", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to create one or more arc grids..
|
||||
/// </summary>
|
||||
internal static string FailedToCreateArcGrids {
|
||||
get {
|
||||
return ResourceManager.GetString("FailedToCreateArcGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to create one or more grids. .
|
||||
/// </summary>
|
||||
internal static string FailedToCreateGrids {
|
||||
get {
|
||||
return ResourceManager.GetString("FailedToCreateGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to create one or more radial grids. .
|
||||
/// </summary>
|
||||
internal static string FailedToCreateRadialGrids {
|
||||
get {
|
||||
return ResourceManager.GetString("FailedToCreateRadialGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to delete some of the selected lines or arcs!.
|
||||
/// </summary>
|
||||
internal static string FailedToDeletedLinesOrArcs {
|
||||
get {
|
||||
return ResourceManager.GetString("FailedToDeletedLinesOrArcs", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to set label of grid to : .
|
||||
/// </summary>
|
||||
internal static string FailedToSetLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("FailedToSetLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to Create Grids.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionCreateGrids {
|
||||
get {
|
||||
return ResourceManager.GetString("FailureCaptionCreateGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to Delete Lines/Arcs.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionDeletedLinesOrArcs {
|
||||
get {
|
||||
return ResourceManager.GetString("FailureCaptionDeletedLinesOrArcs", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Invalid Value.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionInvalidValue {
|
||||
get {
|
||||
return ResourceManager.GetString("FailureCaptionInvalidValue", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to Set Label.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionSetLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("FailureCaptionSetLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Label can not be null!.
|
||||
/// </summary>
|
||||
internal static string LabelCannotBeNull {
|
||||
get {
|
||||
return ResourceManager.GetString("LabelCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to A same label has already existed!.
|
||||
/// </summary>
|
||||
internal static string LabelExisted {
|
||||
get {
|
||||
return ResourceManager.GetString("LabelExisted", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The two labels can't be same!.
|
||||
/// </summary>
|
||||
internal static string LabelsCannotBeSame {
|
||||
get {
|
||||
return ResourceManager.GetString("LabelsCannotBeSame", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Number should be an integer between 0 and 200!.
|
||||
/// </summary>
|
||||
internal static string NumberBetween0And200 {
|
||||
get {
|
||||
return ResourceManager.GetString("NumberBetween0And200", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Number can not be null!.
|
||||
/// </summary>
|
||||
internal static string NumberCannotBeNull {
|
||||
get {
|
||||
return ResourceManager.GetString("NumberCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Number is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string NumberFormatWrong {
|
||||
get {
|
||||
return ResourceManager.GetString("NumberFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The two numbers can not be both zero!.
|
||||
/// </summary>
|
||||
internal static string NumbersCannotBeBothZero {
|
||||
get {
|
||||
return ResourceManager.GetString("NumbersCannotBeBothZero", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Radius can not be negative or zero!.
|
||||
/// </summary>
|
||||
internal static string RadiusCannotBeNegativeOrZero {
|
||||
get {
|
||||
return ResourceManager.GetString("RadiusCannotBeNegativeOrZero", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Radius can not be null!.
|
||||
/// </summary>
|
||||
internal static string RadiusCannotBeNull {
|
||||
get {
|
||||
return ResourceManager.GetString("RadiusCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Radius is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string RadiusFormatWrong {
|
||||
get {
|
||||
return ResourceManager.GetString("RadiusFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to That may be caused by one or more of following reasons:.
|
||||
/// </summary>
|
||||
internal static string Reasons {
|
||||
get {
|
||||
return ResourceManager.GetString("Reasons", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Spacing can not be negative or zero!.
|
||||
/// </summary>
|
||||
internal static string SpacingCannotBeNegativeOrZero {
|
||||
get {
|
||||
return ResourceManager.GetString("SpacingCannotBeNegativeOrZero", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Spacing can not be null!.
|
||||
/// </summary>
|
||||
internal static string SpacingCannotBeNull {
|
||||
get {
|
||||
return ResourceManager.GetString("SpacingCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Spacing is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string SpacingFormatWrong {
|
||||
get {
|
||||
return ResourceManager.GetString("SpacingFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to - Spacings between grids are too small.
|
||||
/// </summary>
|
||||
internal static string SpacingsTooSmall {
|
||||
get {
|
||||
return ResourceManager.GetString("SpacingsTooSmall", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Start degree should be less than end degree!.
|
||||
/// </summary>
|
||||
internal static string StartDegreeShouldBeLessThanEndDegree {
|
||||
get {
|
||||
return ResourceManager.GetString("StartDegreeShouldBeLessThanEndDegree", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AjustValues" xml:space="preserve">
|
||||
<value>Please adjust the values and try again!</value>
|
||||
</data>
|
||||
<data name="CoordinateCannotBeNull" xml:space="preserve">
|
||||
<value>Coordinate can not be null!</value>
|
||||
</data>
|
||||
<data name="CoordinateFormatWrong" xml:space="preserve">
|
||||
<value>Coordinate is not in a correct format!</value>
|
||||
</data>
|
||||
<data name="DegreeCannotBeNegative" xml:space="preserve">
|
||||
<value>Degree can not be negative!</value>
|
||||
</data>
|
||||
<data name="DegreeCannotBeNull" xml:space="preserve">
|
||||
<value>Degree can not be null!</value>
|
||||
</data>
|
||||
<data name="DegreeFormatWrong" xml:space="preserve">
|
||||
<value>Degree is not in a correct format!</value>
|
||||
</data>
|
||||
<data name="DegreesAreTooClose" xml:space="preserve">
|
||||
<value>Start degree and end degree can not be so close!</value>
|
||||
</data>
|
||||
<data name="DegreeWithin0To360" xml:space="preserve">
|
||||
<value>Degree should be within the range of 0 - 360!</value>
|
||||
</data>
|
||||
<data name="DistanceCannotBeNegative" xml:space="preserve">
|
||||
<value>Distance can not be negative!</value>
|
||||
</data>
|
||||
<data name="DistanceCannotBeNull" xml:space="preserve">
|
||||
<value>Distance can not be null!</value>
|
||||
</data>
|
||||
<data name="DistanceFormatWrong" xml:space="preserve">
|
||||
<value>Distance is not in a correct format!</value>
|
||||
</data>
|
||||
<data name="DUT_CENTIMETERS" xml:space="preserve">
|
||||
<value>cm</value>
|
||||
</data>
|
||||
<data name="DUT_DECIMAL_FEET" xml:space="preserve">
|
||||
<value>'</value>
|
||||
</data>
|
||||
<data name="DUT_DECIMAL_INCHES" xml:space="preserve">
|
||||
<value>"</value>
|
||||
</data>
|
||||
<data name="DUT_FEET_FRACTIONAL_INCHES" xml:space="preserve">
|
||||
<value>'</value>
|
||||
</data>
|
||||
<data name="DUT_FRACTIONAL_INCHES" xml:space="preserve">
|
||||
<value>"</value>
|
||||
</data>
|
||||
<data name="DUT_METERS" xml:space="preserve">
|
||||
<value>m</value>
|
||||
</data>
|
||||
<data name="DUT_METERS_CENTIMETERS" xml:space="preserve">
|
||||
<value>m</value>
|
||||
</data>
|
||||
<data name="DUT_MILLIMETERS" xml:space="preserve">
|
||||
<value>mm</value>
|
||||
</data>
|
||||
<data name="EndPointsTooClose" xml:space="preserve">
|
||||
<value>- Start point and end point of arc grids are too close</value>
|
||||
</data>
|
||||
<data name="FailedToCreateArcGrids" xml:space="preserve">
|
||||
<value>Failed to create one or more arc grids.</value>
|
||||
</data>
|
||||
<data name="FailedToCreateGrids" xml:space="preserve">
|
||||
<value>Failed to create one or more grids. </value>
|
||||
</data>
|
||||
<data name="FailedToCreateRadialGrids" xml:space="preserve">
|
||||
<value>Failed to create one or more radial grids. </value>
|
||||
</data>
|
||||
<data name="FailedToDeletedLinesOrArcs" xml:space="preserve">
|
||||
<value>Failed to delete some of the selected lines or arcs!</value>
|
||||
</data>
|
||||
<data name="FailedToSetLabel" xml:space="preserve">
|
||||
<value>Failed to set label of grid to : </value>
|
||||
</data>
|
||||
<data name="FailureCaptionCreateGrids" xml:space="preserve">
|
||||
<value>Failed to Create Grids</value>
|
||||
</data>
|
||||
<data name="FailureCaptionDeletedLinesOrArcs" xml:space="preserve">
|
||||
<value>Failed to Delete Lines/Arcs</value>
|
||||
</data>
|
||||
<data name="FailureCaptionInvalidValue" xml:space="preserve">
|
||||
<value>Invalid Value</value>
|
||||
</data>
|
||||
<data name="FailureCaptionSetLabel" xml:space="preserve">
|
||||
<value>Failed to Set Label</value>
|
||||
</data>
|
||||
<data name="LabelCannotBeNull" xml:space="preserve">
|
||||
<value>Label can not be null!</value>
|
||||
</data>
|
||||
<data name="LabelExisted" xml:space="preserve">
|
||||
<value>A same label has already existed!</value>
|
||||
</data>
|
||||
<data name="LabelsCannotBeSame" xml:space="preserve">
|
||||
<value>The two labels can't be same!</value>
|
||||
</data>
|
||||
<data name="NumberBetween0And200" xml:space="preserve">
|
||||
<value>Number should be an integer between 0 and 200!</value>
|
||||
</data>
|
||||
<data name="NumberCannotBeNull" xml:space="preserve">
|
||||
<value>Number can not be null!</value>
|
||||
</data>
|
||||
<data name="NumberFormatWrong" xml:space="preserve">
|
||||
<value>Number is not in a correct format!</value>
|
||||
</data>
|
||||
<data name="NumbersCannotBeBothZero" xml:space="preserve">
|
||||
<value>The two numbers can not be both zero!</value>
|
||||
</data>
|
||||
<data name="RadiusCannotBeNegativeOrZero" xml:space="preserve">
|
||||
<value>Radius can not be negative or zero!</value>
|
||||
</data>
|
||||
<data name="RadiusCannotBeNull" xml:space="preserve">
|
||||
<value>Radius can not be null!</value>
|
||||
</data>
|
||||
<data name="RadiusFormatWrong" xml:space="preserve">
|
||||
<value>Radius is not in a correct format!</value>
|
||||
</data>
|
||||
<data name="Reasons" xml:space="preserve">
|
||||
<value> That may be caused by one or more of following reasons:</value>
|
||||
</data>
|
||||
<data name="SpacingCannotBeNegativeOrZero" xml:space="preserve">
|
||||
<value>Spacing can not be negative or zero!</value>
|
||||
</data>
|
||||
<data name="SpacingCannotBeNull" xml:space="preserve">
|
||||
<value>Spacing can not be null!</value>
|
||||
</data>
|
||||
<data name="SpacingFormatWrong" xml:space="preserve">
|
||||
<value>Spacing is not in a correct format!</value>
|
||||
</data>
|
||||
<data name="SpacingsTooSmall" xml:space="preserve">
|
||||
<value>- Spacings between grids are too small</value>
|
||||
</data>
|
||||
<data name="StartDegreeShouldBeLessThanEndDegree" xml:space="preserve">
|
||||
<value>Start degree should be less than end degree!</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides static functions to convert unit
|
||||
/// </summary>
|
||||
static class Unit
|
||||
{
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Convert the value get from RevitAPI to the value indicated by DisplayUnitType
|
||||
/// </summary>
|
||||
/// <param name="to">DisplayUnitType indicates unit of target value</param>
|
||||
/// <param name="value">value get from RevitAPI</param>
|
||||
/// <returns>Target value</returns>
|
||||
public static double CovertFromAPI(ForgeTypeId to, double value)
|
||||
{
|
||||
return value *= ImperialDutRatio(to);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a value indicated by DisplayUnitType to the value used by RevitAPI
|
||||
/// </summary>
|
||||
/// <param name="value">Value to be converted</param>
|
||||
/// <param name="from">DisplayUnitType indicates the unit of the value to be converted</param>
|
||||
/// <returns>Target value</returns>
|
||||
public static double CovertToAPI(double value, ForgeTypeId from)
|
||||
{
|
||||
return value /= ImperialDutRatio(from);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get ratio between value in RevitAPI and value to display indicated by DisplayUnitType
|
||||
/// </summary>
|
||||
/// <param name="dut">DisplayUnitType indicates display unit type</param>
|
||||
/// <returns>Ratio </returns>
|
||||
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
|
||||
}
|
||||
}
|
||||
+339
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to validate input data before creating grids
|
||||
/// </summary>
|
||||
public static class Validation
|
||||
{
|
||||
// Get the resource contains strings
|
||||
static ResourceManager resManager = SamplePropertis.GridCreationResources.ResourceManager;
|
||||
|
||||
/// <summary>
|
||||
/// Validate numbers in UI
|
||||
/// </summary>
|
||||
/// <param name="number1Ctrl">Control contains number information</param>
|
||||
/// <param name="number2Ctrl">Control contains another number information</param>
|
||||
/// <returns>Whether the numbers are validated</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate number value
|
||||
/// </summary>
|
||||
/// <param name="numberCtrl">Control contains number information</param>
|
||||
/// <returns>Whether the number value is validated</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate length value
|
||||
/// </summary>
|
||||
/// <param name="lengthCtrl">Control contains length information</param>
|
||||
/// <param name="typeName">Type of length</param>
|
||||
/// <param name="canBeZero">Whether the length can be zero</param>
|
||||
/// <returns>Whether the length value is validated</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate coordinate value
|
||||
/// </summary>
|
||||
/// <param name="coordCtrl">Control contains coordinate information</param>
|
||||
/// <returns>Whether the coordinate value is validated</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate start degree and end degree
|
||||
/// </summary>
|
||||
/// <param name="startDegree">Control contains start degree information</param>
|
||||
/// <param name="endDegree">Control contains end degree information</param>
|
||||
/// <returns>Whether the degree values are validated</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate degree value
|
||||
/// </summary>
|
||||
/// <param name="degreeCtrl">Control contains degree information</param>
|
||||
/// <returns>Whether the degree value is validated</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate label
|
||||
/// </summary>
|
||||
/// <param name="labelCtrl">Control contains label information</param>
|
||||
/// <param name="allLabels">List contains all labels in Revit document</param>
|
||||
/// <returns>Whether the label value is validated</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assure value is not null
|
||||
/// </summary>
|
||||
/// <param name="control">Control contains information needs to be checked</param>
|
||||
/// <param name="typeName">Type of information</param>
|
||||
/// <returns>Whether the value is not null</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assure two labels are not same
|
||||
/// </summary>
|
||||
/// <param name="label1Ctrl">Control contains label information</param>
|
||||
/// <param name="label2Ctrl">Control contains label information</param>
|
||||
/// <returns>Whether the labels are same</returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<Optimize>False</Optimize>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType>Portable</DebugType>
|
||||
<OutputPath>..\..\Addin\</OutputPath>
|
||||
<AssemblyName>MacroSamples_RVT</AssemblyName>
|
||||
<BaseInterMediateOutputPath>obj\</BaseInterMediateOutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<InterMediateOutputPath>obj\Debug</InterMediateOutputPath>
|
||||
<Deterministic>false</Deterministic>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
|
||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
|
||||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
|
||||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="..\..\..\..\..\RevitAPI.dll">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="..\..\..\..\..\RevitAPIUI.dll">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
||||
<Exec Command="del $(OutputPath)\*.dll" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Get some properties of a slab , such as Level, Type name, Span direction,
|
||||
/// Material name, Thickness, and Young Modulus for the slab's Material.
|
||||
/// </summary>
|
||||
public class SampleProjectInfo
|
||||
{
|
||||
// #region Class ctor implemetation
|
||||
/// <summary>
|
||||
/// Ctor without parameter is not allowed
|
||||
/// </summary>
|
||||
private SampleProjectInfo()
|
||||
{
|
||||
// no codes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor of StructuralLayerFunction
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run sample Rooms
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts angle with string
|
||||
/// </summary>
|
||||
public class AngleConverter : TypeConverter
|
||||
{
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Converts from string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts to string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
|
||||
{
|
||||
if(destinationType == null)
|
||||
return false;
|
||||
return destinationType.Equals(typeof(string)) || base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts from string.
|
||||
/// </summary>
|
||||
/// <param name="context">An System.ComponentModel.ITypeDescriptorContext
|
||||
/// that provides a format context.</param>
|
||||
/// <param name="culture">An optional System.Globalization.CultureInfo.
|
||||
/// If not supplied, the current culture is assumed.</param>
|
||||
/// <param name="value">string to be converted to an element</param>
|
||||
/// <returns>An element if the element exists, otherwise null</returns>
|
||||
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);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts to string.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="culture">A CultureInfo. If null is passed, the current culture is assumed. </param>
|
||||
/// <param name="value">The Object to convert. </param>
|
||||
/// <param name="destinationType">The Type to convert the value parameter to. </param>
|
||||
/// <returns>Converted string</returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert angle string to double value
|
||||
/// </summary>
|
||||
/// <param name="value">Angle string</param>
|
||||
/// <returns>Double value</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert double value to angle string
|
||||
/// </summary>
|
||||
/// <param name="value">Angle value</param>
|
||||
/// <returns>Angle string, the unit is degree.</returns>
|
||||
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
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts City with string
|
||||
/// </summary>
|
||||
public class CityConverter : TypeConverter
|
||||
{
|
||||
|
||||
public static List<City>? Cities;
|
||||
public const string UserDefined = "User Defined";
|
||||
|
||||
static CityConverter()
|
||||
{
|
||||
if(RevitStartInfo.RevitApp == null)
|
||||
return;
|
||||
Cities = new List<City>();
|
||||
foreach (City city in RevitStartInfo.RevitApp.Cities)
|
||||
{
|
||||
Cities.Add(city);
|
||||
}
|
||||
}
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether this object supports a standard set of values that can be
|
||||
/// picked from a list, using the specified context.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the collection of standard values returned from System.ComponentModel.TypeConverter.GetStandardValues()
|
||||
/// is an exclusive list.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of standard values from the default context for the
|
||||
/// data type this type converter is designed for.
|
||||
/// </summary>
|
||||
/// <returns>Element collection retrieved through filtering current Revit document elements</returns>
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
|
||||
{
|
||||
return new StandardValuesCollection(Cities);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts from string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts to string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
|
||||
{
|
||||
if(destinationType == null)
|
||||
return false;
|
||||
return destinationType.Equals(typeof(string)) || base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an element from a string contains its id
|
||||
/// </summary>
|
||||
/// <param name="context">An System.ComponentModel.ITypeDescriptorContext
|
||||
/// that provides a format context.</param>
|
||||
/// <param name="culture">An optional System.Globalization.CultureInfo.
|
||||
/// If not supplied, the current culture is assumed.</param>
|
||||
/// <param name="value">string to be converted to an element</param>
|
||||
/// <returns>An element if the element exists, otherwise null</returns>
|
||||
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);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns element name.
|
||||
/// returns empty string if value is null or Element.Name throws an exception.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="culture">A CultureInfo. If null is passed, the current culture is assumed. </param>
|
||||
/// <param name="value">The Object to convert. </param>
|
||||
/// <param name="destinationType">The Type to convert the value parameter to. </param>
|
||||
/// <returns>Converted string</returns>
|
||||
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
|
||||
}
|
||||
}
|
||||
+147
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Converter for ConstructionWrapper
|
||||
/// </summary>
|
||||
public class ConstructionWrapperConverter : TypeConverter
|
||||
{
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Returns whether this object supports a standard set of values that can be
|
||||
/// picked from a list, using the specified context.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the collection of standard values returned from System.ComponentModel.TypeConverter.GetStandardValues()
|
||||
/// is an exclusive list.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of standard values from the default context for the
|
||||
/// data type this type converter is designed for.
|
||||
/// </summary>
|
||||
/// <returns>ConstructionWrapper collection depends on current context</returns>
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
|
||||
{
|
||||
List<ConstructionWrapper> list = new List<ConstructionWrapper>();
|
||||
// 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Can convert from string
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="sourceType">A Type that represents the type you want to convert from. </param>
|
||||
/// <returns>true if sourceType is string, otherwise false</returns>
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Can be converted to string
|
||||
/// </summary>
|
||||
/// <returns>true if destinationType is string, otherwise false</returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
|
||||
{
|
||||
if(destinationType == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return destinationType.Equals(typeof(System.String)) || base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a ConstructionWrapper from a string
|
||||
/// </summary>
|
||||
/// <param name="context">An System.ComponentModel.ITypeDescriptorContext
|
||||
/// that provides a format context.</param>
|
||||
/// <param name="culture">An optional System.Globalization.CultureInfo.
|
||||
/// If not supplied, the current culture is assumed.</param>
|
||||
/// <param name="value">string to be converted to</param>
|
||||
/// <returns>A ConstructionWrapper from the StandardValues</returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert object to string
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="culture">A CultureInfo. If null is passed, the current culture is assumed. </param>
|
||||
/// <param name="value">The Object to convert. </param>
|
||||
/// <param name="destinationType">The Type to convert the value parameter to. </param>
|
||||
/// <returns>empty string if current construction is null, otherwise construction name</returns>
|
||||
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
|
||||
};
|
||||
}
|
||||
+82
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Type converter for wrapper classes
|
||||
/// </summary>
|
||||
public class WrapperConverter : ExpandableObjectConverter
|
||||
{
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Can be converted to string
|
||||
/// </summary>
|
||||
/// <returns>true if destinationType is string, otherwise false</returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
|
||||
{
|
||||
if(destinationType == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return destinationType.Equals(typeof(System.String)) || base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts to string. If value is null, convert it to "(null)".
|
||||
/// if value has a "Name" property, returns its name. otherwise, returns "(...)".
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert ElementIds with string
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Element Type</typeparam>
|
||||
public class ElementIdConverter<T> : TypeConverter where T: Element
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns whether this object supports a standard set of values that can be
|
||||
/// picked from a list, using the specified context.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the collection of standard values returned from System.ComponentModel.TypeConverter.GetStandardValues()
|
||||
/// is an exclusive list.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of standard values from the default context for the
|
||||
/// data type this type converter is designed for.
|
||||
/// </summary>
|
||||
/// <returns>Element collection retrieved through filtering current Revit document elements</returns>
|
||||
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<Element> list = new List<Element>();
|
||||
//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());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts from string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts to string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
|
||||
{
|
||||
if(destinationType == null)
|
||||
return false;
|
||||
return destinationType.Equals(typeof(string)) || base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an element from a string contains its id
|
||||
/// </summary>
|
||||
/// <param name="context">An System.ComponentModel.ITypeDescriptorContext
|
||||
/// that provides a format context.</param>
|
||||
/// <param name="culture">An optional System.Globalization.CultureInfo.
|
||||
/// If not supplied, the current culture is assumed.</param>
|
||||
/// <param name="value">string to be converted to an element</param>
|
||||
/// <returns>An element if the element exists, otherwise null</returns>
|
||||
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);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns element name.
|
||||
/// returns empty string if value is null or Element.Name throws an exception.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="culture">A CultureInfo. If null is passed, the current culture is assumed. </param>
|
||||
/// <param name="value">The Object to convert. </param>
|
||||
/// <param name="destinationType">The Type to convert the value parameter to. </param>
|
||||
/// <returns>Converted string</returns>
|
||||
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);
|
||||
}
|
||||
};
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts ProjectLocation with string
|
||||
/// </summary>
|
||||
public class ProjectLocationConverter: TypeConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// All project locations in current document
|
||||
/// </summary>
|
||||
public static List<ProjectLocation>? ProjectLocations;
|
||||
/// <summary>
|
||||
/// User defined location
|
||||
/// </summary>
|
||||
public const string UserDefined = "User Defined";
|
||||
|
||||
/// <summary>
|
||||
/// Initialize ProjectLocations
|
||||
/// </summary>
|
||||
static ProjectLocationConverter()
|
||||
{
|
||||
if(RevitStartInfo.RevitDoc == null)
|
||||
return;
|
||||
ProjectLocations = new List<ProjectLocation>();
|
||||
foreach (ProjectLocation city in RevitStartInfo.RevitDoc.ProjectLocations)
|
||||
{
|
||||
ProjectLocations.Add(city);
|
||||
}
|
||||
}
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether this object supports a standard set of values that can be
|
||||
/// picked from a list, using the specified context.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the collection of standard values returned from System.ComponentModel.TypeConverter.GetStandardValues()
|
||||
/// is an exclusive list.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of standard values from the default context for the
|
||||
/// data type this type converter is designed for.
|
||||
/// </summary>
|
||||
/// <returns>Element collection retrieved through filtering current Revit document elements</returns>
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
|
||||
{
|
||||
return new StandardValuesCollection(ProjectLocations);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts from string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts to string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
|
||||
{
|
||||
if(destinationType == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return destinationType.Equals(typeof(string)) || base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts from string.
|
||||
/// </summary>
|
||||
/// <param name="context">An System.ComponentModel.ITypeDescriptorContext
|
||||
/// that provides a format context.</param>
|
||||
/// <param name="culture">An optional System.Globalization.CultureInfo.
|
||||
/// If not supplied, the current culture is assumed.</param>
|
||||
/// <param name="value">string to be converted to an element</param>
|
||||
/// <returns>An element if the element exists, otherwise null</returns>
|
||||
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);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts to string.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="culture">A CultureInfo. If null is passed, the current culture is assumed. </param>
|
||||
/// <param name="value">The Object to convert. </param>
|
||||
/// <param name="destinationType">The Type to convert the value parameter to. </param>
|
||||
/// <returns>Converted string</returns>
|
||||
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
|
||||
}
|
||||
}
|
||||
+236
@@ -0,0 +1,236 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Converter for Enumeration types of RevitAPI
|
||||
/// </summary>
|
||||
public abstract class RevitEnumConverter : EnumConverter
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Dictionary contains enum and string map
|
||||
/// </summary>
|
||||
Dictionary<object, string>? m_map = null;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the enum-string map
|
||||
/// </summary>
|
||||
protected abstract Dictionary<object, string> EnumMap
|
||||
{
|
||||
get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initialize private variables
|
||||
/// </summary>
|
||||
/// <param name="type">Enumeration type</param>
|
||||
public RevitEnumConverter(Type type)
|
||||
: base(type)
|
||||
{
|
||||
m_map = EnumMap;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Returns a collection of standard values from the default context for the
|
||||
/// data type this type converter is designed for.
|
||||
/// </summary>
|
||||
/// <returns>All enum items</returns>
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
|
||||
{
|
||||
return new StandardValuesCollection(m_map?.Keys);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enum item from a string
|
||||
/// </summary>
|
||||
/// <param name="context">An System.ComponentModel.ITypeDescriptorContext
|
||||
/// that provides a format context.</param>
|
||||
/// <param name="culture">An optional System.Globalization.CultureInfo.
|
||||
/// If not supplied, the current culture is assumed.</param>
|
||||
/// <param name="value">string to be converted to</param>
|
||||
/// <returns>An enum item</returns>
|
||||
public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value)
|
||||
{
|
||||
object enumValue = value;
|
||||
string? valueText = value.ToString();
|
||||
if(m_map == null)
|
||||
return base.ConvertFrom(context, culture, enumValue);
|
||||
foreach (KeyValuePair<object, string> pair in m_map)
|
||||
{
|
||||
if (pair.Value == valueText)
|
||||
{
|
||||
string? tmp = pair.Key.ToString();
|
||||
if(tmp != null)
|
||||
enumValue = tmp;
|
||||
}
|
||||
}
|
||||
return base.ConvertFrom(context, culture, enumValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert enum item to string
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="culture">A CultureInfo. If null is passed, the current culture is assumed. </param>
|
||||
/// <param name="value">The Object to convert. </param>
|
||||
/// <param name="destinationType">The Type to convert the value parameter to. </param>
|
||||
/// <returns>Corresponding string related with the enum item</returns>
|
||||
public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType)
|
||||
{
|
||||
object? enumValue = base.ConvertTo(context, culture, value, destinationType);
|
||||
string? tmp = enumValue?.ToString();
|
||||
if(tmp == null || m_map == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
object enumObject = Enum.Parse(this.EnumType, tmp);
|
||||
return m_map[enumObject];
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Converter for BuildingType
|
||||
/// </summary>
|
||||
public class BuildingTypeConverter : RevitEnumConverter
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="type">enumeration type</param>
|
||||
public BuildingTypeConverter(Type type) : base(type) { }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the enum-string map
|
||||
/// </summary>
|
||||
protected override Dictionary<object, string> EnumMap
|
||||
{
|
||||
get
|
||||
{
|
||||
return RevitStartInfo.BuildingTypeMap;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Converter for ExportComplexityConverter
|
||||
/// </summary>
|
||||
public class ExportComplexityConverter : RevitEnumConverter
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="type">enumeration type</param>
|
||||
public ExportComplexityConverter(Type type) : base(type) { }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the enum-string map
|
||||
/// </summary>
|
||||
protected override Dictionary<object, string> EnumMap
|
||||
{
|
||||
get
|
||||
{
|
||||
return RevitStartInfo.ExportComplexityMap;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Converter for ServiceType
|
||||
/// </summary>
|
||||
public class ServiceTypeConverter : RevitEnumConverter
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="type">enumeration type</param>
|
||||
public ServiceTypeConverter(Type type) : base(type) { }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the enum-string map
|
||||
/// </summary>
|
||||
protected override Dictionary<object, string> EnumMap
|
||||
{
|
||||
get
|
||||
{
|
||||
return RevitStartInfo.ServiceTypeMap;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Converter for HVACLoadLoadsReportType
|
||||
/// </summary>
|
||||
public class HVACLoadLoadsReportTypeConverter : RevitEnumConverter
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="type">enumeration type</param>
|
||||
public HVACLoadLoadsReportTypeConverter(Type type) : base(type) { }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the enum-string map
|
||||
/// </summary>
|
||||
protected override Dictionary<object, string> EnumMap
|
||||
{
|
||||
get
|
||||
{
|
||||
return RevitStartInfo.HVACLoadLoadsReportTypeMap;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Converter for HVACLoadConstructionClass
|
||||
/// </summary>
|
||||
public class HVACLoadConstructionClassConverter : RevitEnumConverter
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="type">enumeration type</param>
|
||||
public HVACLoadConstructionClassConverter(Type type) : base(type) { }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the enum-string map
|
||||
/// </summary>
|
||||
protected override Dictionary<object, string> EnumMap
|
||||
{
|
||||
get
|
||||
{
|
||||
return RevitStartInfo.HVACLoadConstructionClassMap;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Converter used to convert TimeZone
|
||||
/// </summary>
|
||||
public class TimeZoneConverter : TypeConverter
|
||||
{
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Returns whether this object supports a standard set of values that can be
|
||||
/// picked from a list, using the specified context.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the collection of standard values returned from System.ComponentModel.TypeConverter.GetStandardValues()
|
||||
/// is an exclusive list.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of standard values from the default context for the
|
||||
/// data type this type converter is designed for.
|
||||
/// </summary>
|
||||
/// <returns>Element collection retrieved through filtering current Revit document elements</returns>
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
|
||||
{
|
||||
return new StandardValuesCollection(RevitStartInfo.TimeZones);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
}
|
||||
Generated
+118
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// (C) Copyright 2003-2010 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.ProjectInfo.CS
|
||||
{
|
||||
partial class ProjectInfoForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.okButton.Location = new System.Drawing.Point(265, 384);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.okButton.TabIndex = 0;
|
||||
this.okButton.Text = "&OK";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(346, 384);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.cancelButton.TabIndex = 1;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// propertyGrid1
|
||||
//
|
||||
this.propertyGrid1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.propertyGrid1.HelpVisible = false;
|
||||
this.propertyGrid1.Location = new System.Drawing.Point(12, 12);
|
||||
this.propertyGrid1.Name = "propertyGrid1";
|
||||
this.propertyGrid1.Size = new System.Drawing.Size(409, 366);
|
||||
this.propertyGrid1.TabIndex = 2;
|
||||
//
|
||||
// ProjectInfoForm
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.ClientSize = new System.Drawing.Size(433, 419);
|
||||
this.Controls.Add(this.propertyGrid1);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ProjectInfoForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Project Information";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.PropertyGrid propertyGrid1;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// (C) Copyright 2003-2010 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.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Form used to display project information
|
||||
/// </summary>
|
||||
public partial class ProjectInfoForm : System.Windows.Forms.Form
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Wrapper for ProjectInfo
|
||||
/// </summary>
|
||||
ProjectInfoWrapper? m_projectInfoWrapper = null;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initialize component
|
||||
/// </summary>
|
||||
public ProjectInfoForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize PropertyGrid
|
||||
/// </summary>
|
||||
/// <param name="projectInfoWrapper">ProjectInfo wrapper</param>
|
||||
public ProjectInfoForm(ProjectInfoWrapper projectInfoWrapper)
|
||||
:this()
|
||||
{
|
||||
m_projectInfoWrapper = projectInfoWrapper;
|
||||
|
||||
// Initialize propertyGrid with CustomDescriptor
|
||||
propertyGrid1.SelectedObject = new WrapperCustomDescriptor(m_projectInfoWrapper);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
+262
@@ -0,0 +1,262 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.ApplicationServices;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.Analysis;
|
||||
|
||||
/// <summary>
|
||||
/// Preserves global information
|
||||
/// </summary>
|
||||
public static class RevitStartInfo
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Current Revit application
|
||||
/// </summary>
|
||||
public static Autodesk.Revit.ApplicationServices.Application? RevitApp;
|
||||
|
||||
/// <summary>
|
||||
/// Active Revit document
|
||||
/// </summary>
|
||||
public static Document? RevitDoc;
|
||||
|
||||
/// <summary>
|
||||
/// Current Revit Product
|
||||
/// </summary>
|
||||
public static ProductType RevitProduct;
|
||||
|
||||
/// <summary>
|
||||
/// Time Zone Array
|
||||
/// </summary>
|
||||
public static string[] TimeZones;
|
||||
|
||||
/// <summary>
|
||||
/// BuildingType and its display string map.
|
||||
/// </summary>
|
||||
public static Dictionary<object, string> BuildingTypeMap;
|
||||
|
||||
/// <summary>
|
||||
/// ServiceType and its display string map.
|
||||
/// </summary>
|
||||
public static Dictionary<object, string> ServiceTypeMap;
|
||||
|
||||
/// <summary>
|
||||
/// ExportComplexity and its display string map.
|
||||
/// </summary>
|
||||
public static Dictionary<object, string> ExportComplexityMap;
|
||||
|
||||
/// <summary>
|
||||
/// HVACLoadLoadsReportType and its display string map.
|
||||
/// </summary>
|
||||
public static Dictionary<object, string> HVACLoadLoadsReportTypeMap;
|
||||
|
||||
/// <summary>
|
||||
/// HVACLoadConstructionClass and its display string map.
|
||||
/// </summary>
|
||||
public static Dictionary<object, string> HVACLoadConstructionClassMap;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize some static members
|
||||
/// </summary>
|
||||
static RevitStartInfo()
|
||||
{
|
||||
#region TimeZones
|
||||
TimeZones = new string[]{
|
||||
"(GMT-12:00) International Date Line West",
|
||||
"(GMT-11:00) Midway Island, Samoa",
|
||||
"(GMT-10:00) Hawaii",
|
||||
"(GMT-09:00) Alaska",
|
||||
"(GMT-08:00) Pacific Time (US/Canada)",
|
||||
"(GMT-08:00) Tijuana, Baja California",
|
||||
"(GMT-07:00) Arizona",
|
||||
"(GMT-07:00) Chihuahua, La Paz, Mazatlan - New",
|
||||
"(GMT-07:00) Chihuahua, La Paz, Mazatlan - Old",
|
||||
"(GMT-07:00) Mountain Time (US/Canada)",
|
||||
"(GMT-06:00) Central America",
|
||||
"(GMT-06:00) Central Time (US/Canada)",
|
||||
"(GMT-06:00) Guadalajara, Mexico City, Monterrey - New",
|
||||
"(GMT-06:00) Guadalajara, Mexico City, Monterrey - Old",
|
||||
"(GMT-06:00) Saskatchewan",
|
||||
"(GMT-05:00) Bogota, Lima, Quito, Rio Branco",
|
||||
"(GMT-05:00) Eastern Time (US/Canada)",
|
||||
"(GMT-05:00) Indiana (East)",
|
||||
"(GMT-04:00) Atlantic Time (Canada)",
|
||||
"(GMT-04:00) Caracas, La Paz",
|
||||
"(GMT-04:00) Santiago",
|
||||
"(GMT-03:30) Newfoundland",
|
||||
"(GMT-03:00) Brazilia",
|
||||
"(GMT-03:00) Buanos Aires, Georgetown",
|
||||
"(GMT-03:00) Greenland",
|
||||
"(GMT-03:00) Montevideo",
|
||||
"(GMT-02:00) Mid-Atlantic",
|
||||
"(GMT-01:00) Azores",
|
||||
"(GMT-01:00) Cape Verde Is.",
|
||||
"(GMT) Casablanca, Monrovia,Reykjavik",
|
||||
"(GMT) Greenwich Time: Dublin, Edinburgh, Lisbon, London",
|
||||
"(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna",
|
||||
"(GMT+01:00) Belgrade, Brastislava, Budapest, Ljubljana, Prague",
|
||||
"(GMT+01:00) Brussels, Copenhagen, Madrid, Paris",
|
||||
"(GMT+01:00) Sarajevo, Skopje, Sofija, Vilnus, Warsaw, Zagreb",
|
||||
"(GMT+01:00) West Central Africa",
|
||||
"(GMT+02:00) Amman",
|
||||
"(GMT+02:00) Athens, Bucharest, Istanbul",
|
||||
"(GMT+02:00) Beirut",
|
||||
"(GMT+02:00) Cairo",
|
||||
"(GMT+02:00) Harare, Pretoria",
|
||||
"(GMT+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius",
|
||||
"(GMT+02:00) Jerusalem",
|
||||
"(GMT+02:00) Minsk",
|
||||
"(GMT+02:00) Windhoek",
|
||||
"(GMT+03:00) Baghdad",
|
||||
"(GMT+03:00) Kuwait, Riyadh",
|
||||
"(GMT+03:00) Moscow, St. Petersburg, Volgograd",
|
||||
"(GMT+03:00) Nairobi",
|
||||
"(GMT+03:00) Tbilisi",
|
||||
"(GMT+03:00) Tehran",
|
||||
"(GMT+04:00) Abu Dhabi, Muscat",
|
||||
"(GMT+04:00) Baku",
|
||||
"(GMT+04:00) Yerevan",
|
||||
"(GMT+04:30) Kabul",
|
||||
"(GMT+05:00) Ekaterinburg",
|
||||
"(GMT+05:00) Islamabad, Karachi, Tashkent",
|
||||
"(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi",
|
||||
"(GMT+05:30) Sri Jayawardenepura",
|
||||
"(GMT+05:45) Kathmandu ",
|
||||
"(GMT+06:00) Almaty, Novosibirsk",
|
||||
"(GMT+06:00) Astana, Dhaka",
|
||||
"(GMT+06:30) Yangon (Rangoon)",
|
||||
"(GMT+07:00) Bangkok, Hanoi, Jakarta ",
|
||||
"(GMT+07:00) Krasnoyarsk ",
|
||||
"(GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi ",
|
||||
"(GMT+08:00) Irkutsk, Ulaan Bataar ",
|
||||
"(GMT+08:00) Kuala Lumpur, Singapore ",
|
||||
"(GMT+08:00) Perth",
|
||||
"(GMT+08:00) Taipei",
|
||||
"(GMT+09:00) Osaka, Sapporo, Tokyo",
|
||||
"(GMT+09:00) Seoul",
|
||||
"(GMT+09:00) Yakutsk",
|
||||
"(GMT+09:30) Adelaide",
|
||||
"(GMT+09:30) Darwin",
|
||||
"(GMT+10:00) Brisbane",
|
||||
"(GMT+10:00) Canberra, Melbourne, Sydney",
|
||||
"(GMT+10:00) Guam, Port Moresby",
|
||||
"(GMT+10:00) Hobart",
|
||||
"(GMT+10:00) Vladivostok",
|
||||
"(GMT+11:00) Magadan, Solomon Is., New Caledonia ",
|
||||
"(GMT+12:00) Aukland, Wellington ",
|
||||
"(GMT+12:00) Fiji, Kamchatka, Marshall Is.",
|
||||
"(GMT+13:00) Nubu'alofa" };
|
||||
#endregion
|
||||
|
||||
#region BuildingTypeMap
|
||||
BuildingTypeMap = new Dictionary<object, string>();
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.AutomotiveFacility, "Automotive Facility");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.ConventionCenter, "Convention Center");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Courthouse, "Courthouse");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.DiningBarLoungeOrLeisure, "Dining Bar Lounge or Leisure");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.DiningCafeteriaFastFood, "Dining Cafeteria Fast Food");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.DiningFamily, "Dining Family");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Dormitory, "Dormitory");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.ExerciseCenter, "Exercise Center");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.FireStation, "Fire Station");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Gymnasium, "Gymnasium");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.HospitalOrHealthcare, "Hospital or Healthcare");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Hotel, "Hotel");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Library, "Library");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Manufacturing, "Manufacturing");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Motel, "Motel");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.MotionPictureTheatre, "Motion Picture Theatre");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.MultiFamily, "Multi Family");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Museum, "Museum");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.NoOfBuildingTypes, "None");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Office, "Office");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.ParkingGarage, "Parking Garage");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Penitentiary, "Penitentiary");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.PerformingArtsTheater, "Performing Arts Theater");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.PoliceStation, "Police Station");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.PostOffice, "Post Office");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.ReligiousBuilding, "Religious Building");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Retail, "Retail");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.SchoolOrUniversity, "School or University");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.SingleFamily, "Single Family");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.SportsArena, "Sports Arena");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.TownHall, "Town Hall");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Transportation, "Transportation");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Warehouse, "Warehouse");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Workshop, "Workshop");
|
||||
#endregion
|
||||
|
||||
#region ServiceTypeMap
|
||||
ServiceTypeMap = new Dictionary<object, string>();
|
||||
ServiceTypeMap.Add(gbXMLServiceType.ActiveChilledBeams, "Active Chilled Beams");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.CentralHeatingConvectors, "Central Heating: Convectors");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.CentralHeatingHotAir, "Central Heating: Hot Air");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.CentralHeatingRadiantFloor, "Central Heating: Radiant Floor");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.CentralHeatingRadiators, "Central Heating: Radiators");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.ConstantVolumeDualDuct, "Constant Volume - Dual Duct");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.ConstantVolumeFixedOA, "Constant Volume - Fixed OA");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.ConstantVolumeTerminalReheat, "Constant Volume - Terminal Reheat");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.ConstantVolumeVariableOA, "Constant Volume - Variable OA");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.FanCoilSystem, "Fan Coil System");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.ForcedConvectionHeaterFlue, "Forced Convection Heater - Flue");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.ForcedConvectionHeaterNoFlue, "Forced Convection Heater - No Flue");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.InductionSystem, "Induction System");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.MultizoneHotDeckColdDeck, "Multi-zone - Hot Deck / Cold Deck");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.NoServiceType, "None");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.OtherRoomHeater, "Other Room Heater");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.RadiantCooledCeilings, "Radiant Cooled Ceilings");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.RadiantHeaterFlue, "Radiant Heater - Flue");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.RadiantHeaterMultiburner, "Radiant Heater - Multi-burner");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.RadiantHeaterNoFlue, "Radiant Heater - No Flue");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.SplitSystemsWithMechanicalVentilation, "Split System(s) with Mechanical Ventilation");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.SplitSystemsWithMechanicalVentilationWithCooling, "Split System(s) with Mechanical Ventilation with Cooling");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.SplitSystemsWithNaturalVentilation, "Split System(s) with Natural Ventilation");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.VariableRefrigerantFlow, "Variable Refrigerant Flow");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.VAVDualDuct, "VAV - Dual Duct");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.VAVIndoorPackagedCabinet, "VAV - Indoor Packaged Cabinet");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.VAVSingleDuct, "VAV - Single Duct");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.VAVTerminalReheat, "VAV - Terminal Reheat");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.WaterLoopHeatPump, "Water Loop Heat Pump");
|
||||
#endregion
|
||||
|
||||
#region ExportComplexityMap
|
||||
ExportComplexityMap = new Dictionary<object, string>();
|
||||
ExportComplexityMap.Add(gbXMLExportComplexity.Complex, "Complex");
|
||||
ExportComplexityMap.Add(gbXMLExportComplexity.ComplexWithMullionsAndShadingSurfaces, "Complex With Mullions And Shading Surfaces");
|
||||
ExportComplexityMap.Add(gbXMLExportComplexity.ComplexWithShadingSurfaces, "Complex With Shading Surfaces");
|
||||
ExportComplexityMap.Add(gbXMLExportComplexity.Simple, "Simple");
|
||||
ExportComplexityMap.Add(gbXMLExportComplexity.SimpleWithShadingSurfaces, "Simple With Shading Surfaces");
|
||||
#endregion
|
||||
|
||||
#region HVACLoadLoadsReportTypeMap
|
||||
HVACLoadLoadsReportTypeMap = new Dictionary<object, string>();
|
||||
HVACLoadLoadsReportTypeMap.Add(HVACLoadLoadsReportType.DetailedReport, "Detailed");
|
||||
HVACLoadLoadsReportTypeMap.Add(HVACLoadLoadsReportType.NoReport, "No");
|
||||
HVACLoadLoadsReportTypeMap.Add(HVACLoadLoadsReportType.SimpleReport, "Simple");
|
||||
HVACLoadLoadsReportTypeMap.Add(HVACLoadLoadsReportType.StandardReport, "Standard");
|
||||
#endregion
|
||||
|
||||
#region HVACLoadConstructionClassMap
|
||||
HVACLoadConstructionClassMap = new Dictionary<object, string>();
|
||||
HVACLoadConstructionClassMap.Add(HVACLoadConstructionClass.LooseConstruction, "Loose");
|
||||
HVACLoadConstructionClassMap.Add(HVACLoadConstructionClass.NoneConstruction, "None");
|
||||
HVACLoadConstructionClassMap.Add(HVACLoadConstructionClass.MediumConstruction, "Medium");
|
||||
HVACLoadConstructionClassMap.Add(HVACLoadConstructionClass.TightConstruction, "Tight");
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public static Element? GetElement(ElementId elementId)
|
||||
{
|
||||
return RevitDoc?.GetElement(elementId);
|
||||
}
|
||||
public static Element? GetElement(Int64 elementId)
|
||||
{
|
||||
return GetElement(new ElementId(elementId));
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// (C) Copyright 2003-2010 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.ObjectModel;
|
||||
using Autodesk.Revit.ApplicationServices;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute which designates Revit version names
|
||||
/// </summary>
|
||||
public sealed class RevitVersionAttribute : Attribute
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Revit version name array
|
||||
/// </summary>
|
||||
List<ProductType> m_products = new List<ProductType>();
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets Revit version names
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<ProductType> Names
|
||||
{
|
||||
get { return m_products.AsReadOnly(); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes Revit version name array
|
||||
/// </summary>
|
||||
/// <param name="names"></param>
|
||||
public RevitVersionAttribute(params ProductType[] names)
|
||||
{
|
||||
m_products.AddRange(names);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper class for Construction
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(ConstructionWrapperConverter))]
|
||||
public class ConstructionWrapper : IComparable, IWrapper
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Construction
|
||||
/// </summary>
|
||||
private Construction m_construction;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes private variables.
|
||||
/// </summary>
|
||||
/// <param name="construction">Construction</param>
|
||||
public ConstructionWrapper(Construction construction)
|
||||
{
|
||||
m_construction = construction;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
#region IComparable Members
|
||||
|
||||
/// <summary>
|
||||
/// Compares the names of Constructions.
|
||||
/// </summary>
|
||||
/// <param name="obj">ConstructionWrapper used to compare</param>
|
||||
/// <returns>A 32-bit signed integer that indicates the relative order of the objects
|
||||
/// being compared. The return value has these meanings:
|
||||
/// Value Condition Less than zero This instance is less than value.
|
||||
/// Zero This instance is equal to value. Greater than zero This instance is
|
||||
/// greater than value.-or- value is null.</returns>
|
||||
public int CompareTo(object? obj)
|
||||
{
|
||||
ConstructionWrapper? wrapper = obj as ConstructionWrapper;
|
||||
if (wrapper != null)
|
||||
{
|
||||
return this.Name.CompareTo(wrapper.Name);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IWrapper Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle object.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public object Handle
|
||||
{
|
||||
get { return m_construction; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the handle.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public String Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_construction.Name;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+271
@@ -0,0 +1,271 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.ApplicationServices;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Analysis;
|
||||
using Autodesk.Revit.DB.Mechanical;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper class for gbXMLParamElem
|
||||
/// </summary>
|
||||
public class EnergyDataSettingsWrapper : IWrapper
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// gbXMLParamElem
|
||||
/// </summary>
|
||||
private EnergyDataSettings m_energyDataSettings;
|
||||
/// <summary>
|
||||
/// Revit Document
|
||||
/// </summary>
|
||||
private Document m_document;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes private variables.
|
||||
/// </summary>
|
||||
/// <param name="gbXMLParamElem">gbXMLParamElem</param>
|
||||
public EnergyDataSettingsWrapper(Document document)
|
||||
{
|
||||
m_document = document;
|
||||
m_energyDataSettings = EnergyDataSettings.GetFromDocument(document);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Building Type
|
||||
/// </summary>
|
||||
[Category("Common"), DisplayName("Building Type")]
|
||||
[TypeConverter(typeof(BuildingTypeConverter))]
|
||||
public gbXMLBuildingType BuildingType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.BuildingType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.BuildingType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Ground Plane
|
||||
/// </summary>
|
||||
[Category("Common"), DisplayName("Ground Plane")]
|
||||
[TypeConverter(typeof(ElementIdConverter<Level>))]
|
||||
public ElementId GroundPlane
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.GroundPlane;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.GroundPlane = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Building Service
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Building Service")]
|
||||
[TypeConverter(typeof(ServiceTypeConverter))]
|
||||
[RevitVersion(ProductType.MEP)]
|
||||
public gbXMLServiceType BuildingService
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.ServiceType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.ServiceType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets Building Construction
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Building Construction"), TypeConverter(typeof(WrapperConverter)), RevitVersion(ProductType.MEP)]
|
||||
public MEPBuildingConstructionWrapper? BuildingConstruction
|
||||
{
|
||||
get
|
||||
{
|
||||
ElementId eid = EnergyDataSettings.GetBuildingConstructionSetElementId(m_document);
|
||||
MEPBuildingConstruction? mEPBuildingConstruction = RevitStartInfo.GetElement(eid) as MEPBuildingConstruction;
|
||||
//MEPBuildingConstruction mEPBuildingConstruction = RevitStartInfo.GetElement(m_energyDataSettings.ConstructionSetElementId) as MEPBuildingConstruction;
|
||||
if(mEPBuildingConstruction != null)
|
||||
return new MEPBuildingConstructionWrapper(mEPBuildingConstruction);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and Sets BuildingConstructionClass
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Building Infiltration Class")]
|
||||
[TypeConverter(typeof(HVACLoadConstructionClassConverter))]
|
||||
[RevitVersion(ProductType.MEP)]
|
||||
public HVACLoadConstructionClass BuildingConstructionClass
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.BuildingConstructionClass;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.BuildingConstructionClass = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Project Phase
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Project Phase")]
|
||||
[TypeConverter(typeof(ElementIdConverter<Phase>))]
|
||||
public ElementId ProjectPhase
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.ProjectPhase;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.ProjectPhase = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Sliver Space Tolerance
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Sliver Space Tolerance")]
|
||||
public Double SliverSpaceTolerance
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.SliverSpaceTolerance;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.SliverSpaceTolerance = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Export Complexity
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Export Complexity")]
|
||||
[TypeConverter(typeof(ExportComplexityConverter))]
|
||||
public gbXMLExportComplexity ExportComplexity
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.ExportComplexity;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.ExportComplexity = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Export Default Values
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Export Default Values")]
|
||||
[RevitVersion(ProductType.MEP)]
|
||||
public bool ExportDefaultValues
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.ExportDefaults;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.ExportDefaults = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and Sets ProjectReportType
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Report Type")]
|
||||
[TypeConverter(typeof(HVACLoadLoadsReportTypeConverter))]
|
||||
[RevitVersion(ProductType.MEP)]
|
||||
public HVACLoadLoadsReportType ProjectReportType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.ProjectReportType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.ProjectReportType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets Project Location
|
||||
/// </summary>
|
||||
[DisplayName("Project Location"), TypeConverter(typeof(ProjectLocationConverter)), RevitVersion(ProductType.MEP, ProductType.Architecture)]
|
||||
public ProjectLocation ProjectLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_document.ActiveProjectLocation;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_document.ActiveProjectLocation = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets Site Location
|
||||
/// </summary>
|
||||
[DisplayName("Site Location"), TypeConverter(typeof(WrapperConverter)), RevitVersion(ProductType.MEP, ProductType.Architecture)]
|
||||
public SiteLocationWrapper SiteLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SiteLocationWrapper(m_document.SiteLocation);
|
||||
}
|
||||
}
|
||||
|
||||
#region IWrapper Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle object.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public object Handle
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the handle.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "";
|
||||
}
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+237
@@ -0,0 +1,237 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Mechanical;
|
||||
using ConstructionType = Autodesk.Revit.DB.Analysis.ConstructionType;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper class for MEPBuildingConstruction
|
||||
/// </summary>
|
||||
public class MEPBuildingConstructionWrapper : IWrapper
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// MEPBuildingConstruction
|
||||
/// </summary>
|
||||
private MEPBuildingConstruction m_mEPBuildingConstruction;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes private variables.
|
||||
/// </summary>
|
||||
/// <param name="mEPBuildingConstruction">MEPBuildingConstruction</param>
|
||||
public MEPBuildingConstructionWrapper(MEPBuildingConstruction mEPBuildingConstruction)
|
||||
{
|
||||
m_mEPBuildingConstruction = mEPBuildingConstruction;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets or sets Roofs
|
||||
/// </summary>
|
||||
[DisplayName("Roofs")]
|
||||
public ConstructionWrapper Roof
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.Roof));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.Roof, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Exterior Walls
|
||||
/// </summary>
|
||||
[DisplayName("Exterior Walls")]
|
||||
public ConstructionWrapper ExteriorWall
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.ExteriorWall));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.ExteriorWall, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Interior Walls
|
||||
/// </summary>
|
||||
[DisplayName("Interior Walls")]
|
||||
public ConstructionWrapper InteriorWall
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.InteriorWall));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.InteriorWall, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Ceilings
|
||||
/// </summary>
|
||||
[DisplayName("Ceilings")]
|
||||
public ConstructionWrapper Ceiling
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.Ceiling));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.Ceiling, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Doors
|
||||
/// </summary>
|
||||
[DisplayName("Doors")]
|
||||
public ConstructionWrapper Door
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.Door));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.Door, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Slabs
|
||||
/// </summary>
|
||||
[DisplayName("Slabs")]
|
||||
public ConstructionWrapper Slab
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.Slab));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.Slab, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Floors
|
||||
/// </summary>
|
||||
[DisplayName("Floors")]
|
||||
public ConstructionWrapper Floor
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.Floor));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.Floor, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Exterior Windows
|
||||
/// </summary>
|
||||
[DisplayName("Exterior Windows")]
|
||||
public ConstructionWrapper ExteriorWindow
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.ExteriorWindow));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.ExteriorWindow, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Interior Windows
|
||||
/// </summary>
|
||||
[DisplayName("Interior Windows")]
|
||||
public ConstructionWrapper InteriorWindow
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.ExteriorWindow));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.ExteriorWindow, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Skylights
|
||||
/// </summary>
|
||||
[DisplayName("Skylights")]
|
||||
public ConstructionWrapper Skylight
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.Skylight));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.Skylight, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
#region IWrapper Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle object.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public object Handle
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_mEPBuildingConstruction;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the handle.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_mEPBuildingConstruction.Name;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.Name = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Get constructions
|
||||
/// </summary>
|
||||
/// <param name="constructionType">ConstructionType</param>
|
||||
/// <returns>Related Constructions specified by constructionTypes</returns>
|
||||
public ICollection<Construction> GetConstructions(ConstructionType constructionType)
|
||||
{
|
||||
return m_mEPBuildingConstruction.GetConstructions(constructionType);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.ApplicationServices;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper class for ProjectInfo
|
||||
/// </summary>
|
||||
public class ProjectInfoWrapper : IWrapper
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// ProjectInfo
|
||||
/// </summary>
|
||||
private Autodesk.Revit.DB.ProjectInfo m_projectInfo;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes private variables.
|
||||
/// </summary>
|
||||
/// <param name="projectInfo">ProjectInfo</param>
|
||||
public ProjectInfoWrapper(Autodesk.Revit.DB.ProjectInfo projectInfo)
|
||||
{
|
||||
m_projectInfo = projectInfo;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets gbXMLSettings
|
||||
/// </summary>
|
||||
[Category("Energy Analysis"), DisplayName("Energy Settings")]
|
||||
[TypeConverter(typeof(WrapperConverter))]
|
||||
[RevitVersion(ProductType.MEP, ProductType.Architecture)]
|
||||
public ICustomTypeDescriptor EnergyDataSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
return new WrapperCustomDescriptor(new EnergyDataSettingsWrapper(m_projectInfo.Document));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Project Issue Data
|
||||
/// </summary>
|
||||
[Category("Other"), DisplayName("Project Issue Data")]
|
||||
public String IssueDate
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_projectInfo.IssueDate;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_projectInfo.IssueDate = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Project Status
|
||||
/// </summary>
|
||||
[Category("Other"), DisplayName("Project Status")]
|
||||
public String Status
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_projectInfo.Status;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_projectInfo.Status = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Client Name
|
||||
/// </summary>
|
||||
[Category("Other"), DisplayName("Client Name")]
|
||||
public String ClientName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_projectInfo.ClientName;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_projectInfo.ClientName = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Project Address
|
||||
/// </summary>
|
||||
[Category("Other"), DisplayName("Project Address")]
|
||||
public String Address
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_projectInfo.Address;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_projectInfo.Address = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Project Number
|
||||
/// </summary>
|
||||
[Category("Other"), DisplayName("Project Number")]
|
||||
public String Number
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_projectInfo.Number;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_projectInfo.Number = value;
|
||||
}
|
||||
}
|
||||
|
||||
#region IWrapper Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle object.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public object Handle
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_projectInfo;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the handle.
|
||||
/// </summary>
|
||||
[Category("Other"), DisplayName("Project Name")]
|
||||
public String Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_projectInfo.Name;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_projectInfo.Name = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper class for SiteLocation
|
||||
/// </summary>
|
||||
public class SiteLocationWrapper : IWrapper
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// SiteLocation
|
||||
/// </summary>
|
||||
private SiteLocation m_siteLocation;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes private variables.
|
||||
/// </summary>
|
||||
/// <param name="siteLocation"></param>
|
||||
public SiteLocationWrapper(SiteLocation siteLocation)
|
||||
{
|
||||
m_siteLocation = siteLocation;
|
||||
//m_citys = RevitStartInfo.RevitApp.Cities;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets or sets TimeZone
|
||||
/// </summary>
|
||||
[DisplayName("Time Zone"), TypeConverter(typeof(TimeZoneConverter))]
|
||||
public String? TimeZone
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetTimeZoneFromDouble(m_siteLocation.TimeZone);
|
||||
}
|
||||
//set
|
||||
//{
|
||||
// m_siteLocation.TimeZone = GetTimeZoneFromString(value);
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Longitude
|
||||
/// </summary>
|
||||
[DisplayName("Longitude"), TypeConverter(typeof(AngleConverter))]
|
||||
public double Longitude
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_siteLocation.Longitude;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_siteLocation.Longitude = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Latitude
|
||||
/// </summary>
|
||||
[DisplayName("Latitude"), TypeConverter(typeof(AngleConverter))]
|
||||
public double Latitude
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_siteLocation.Latitude;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_siteLocation.Latitude = value;
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("City"), TypeConverter(typeof(CityConverter))]
|
||||
public City? City
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetCityFromPosition(Latitude, Longitude);
|
||||
}
|
||||
set
|
||||
{
|
||||
if(value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_siteLocation.Latitude = value.Latitude;
|
||||
m_siteLocation.Longitude = value.Longitude;
|
||||
m_siteLocation.TimeZone = value.TimeZone;
|
||||
}
|
||||
}
|
||||
|
||||
private City? GetCityFromPosition(double latitude, double longitude)
|
||||
{
|
||||
if(RevitStartInfo.RevitApp == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (City city in RevitStartInfo.RevitApp.Cities)
|
||||
{
|
||||
if (DoubleEquals(city.Latitude, latitude) && DoubleEquals(city.Longitude, longitude))
|
||||
return city;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool DoubleEquals(double x, double y)
|
||||
{
|
||||
return Math.Abs(x - y) < 1E-9;
|
||||
}
|
||||
|
||||
#region IWrapper Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle object.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public object Handle
|
||||
{
|
||||
get { return m_siteLocation; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the handle.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public String Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_siteLocation.Name;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_siteLocation.Name = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Get time zone double value from time zone string
|
||||
/// </summary>
|
||||
/// <param name="value">time zone string</param>
|
||||
/// <returns>the value of time zone</returns>
|
||||
private double GetTimeZoneFromString(string value)
|
||||
{
|
||||
//i.e. convert "(GMT-12:00) International Date Line West" to 12.0
|
||||
//i.e. convert "(GMT-03:30) Newfoundland" to 3.30
|
||||
string timeZoneDouble = value.Substring(4, value.IndexOf(')') - 4).Replace(':', '.').Trim();
|
||||
if (string.IsNullOrEmpty(timeZoneDouble))
|
||||
return 0d;
|
||||
else
|
||||
return Double.Parse(timeZoneDouble);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get time zone display string from time zone value
|
||||
/// </summary>
|
||||
/// <param name="timeZone">zone value</param>
|
||||
/// <returns>display string</returns>
|
||||
private string? GetTimeZoneFromDouble(double timeZone)
|
||||
{
|
||||
// e.g. get "(GMT-04:00) Santiago" from double number 4.0
|
||||
// should find the last one who matches the time zone
|
||||
string? lastTimeZone = null;
|
||||
foreach (string tmpTimeZone in RevitStartInfo.TimeZones)
|
||||
{
|
||||
object tmpZone = this.GetTimeZoneFromString(tmpTimeZone);
|
||||
if ((double)tmpZone == timeZone)
|
||||
lastTimeZone = tmpTimeZone;
|
||||
}
|
||||
return lastTimeZone;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+253
@@ -0,0 +1,253 @@
|
||||
//
|
||||
// (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.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class WrapperCustomDescriptor : ICustomTypeDescriptor, IWrapper
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Handle object
|
||||
/// </summary>
|
||||
object m_handle = new object() ;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes handle object
|
||||
/// </summary>
|
||||
/// <param name="handle">Handle object</param>
|
||||
public WrapperCustomDescriptor(object handle)
|
||||
{
|
||||
m_handle = handle;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets handle object
|
||||
/// </summary>
|
||||
public object Handle
|
||||
{
|
||||
get { return m_handle; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the handle object if it has the Name property,
|
||||
/// otherwise returns Handle.ToString().
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
MethodInfo? mi = this.Handle.GetType().GetMethod("get_Name", new Type[0]);
|
||||
if (mi != null)
|
||||
{
|
||||
object? name = mi.Invoke(this.Handle, new object[0]);
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
string? tmp = name.ToString();
|
||||
if(tmp != null)
|
||||
return tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
string? tmp2 =Handle.ToString();
|
||||
if(tmp2 != null)
|
||||
return tmp2;
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
#region ICustomTypeDescriptor Members
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of custom attributes for this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>Handle's attributes</returns>
|
||||
public AttributeCollection GetAttributes()
|
||||
{
|
||||
return TypeDescriptor.GetAttributes(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the class name of this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>Handle's class name</returns>
|
||||
public string? GetClassName()
|
||||
{
|
||||
return TypeDescriptor.GetClassName(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>The name of handle object</returns>
|
||||
public string? GetComponentName()
|
||||
{
|
||||
return TypeDescriptor.GetComponentName(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a type converter for this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>The converter of the handle</returns>
|
||||
public TypeConverter GetConverter()
|
||||
{
|
||||
return TypeDescriptor.GetConverter(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the default event for this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>An EventDescriptor that represents the default event for this object,
|
||||
/// or null if this object does not have events.</returns>
|
||||
public EventDescriptor? GetDefaultEvent()
|
||||
{
|
||||
return TypeDescriptor.GetDefaultEvent(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the default property for this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>A PropertyDescriptor that represents the default property for this object,
|
||||
/// or null if this object does not have properties.</returns>
|
||||
public PropertyDescriptor? GetDefaultProperty()
|
||||
{
|
||||
return TypeDescriptor.GetDefaultProperty(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an editor of the specified type for this instance of a component.
|
||||
/// </summary>
|
||||
/// <param name="editorBaseType">A Type that represents the editor for this object. </param>
|
||||
/// <returns>An Object of the specified type that is the editor for this object,
|
||||
/// or null if the editor cannot be found.</returns>
|
||||
public object? GetEditor(Type editorBaseType)
|
||||
{
|
||||
return TypeDescriptor.GetEditor(m_handle, editorBaseType, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the events for this instance of a component using the specified attribute array as a filter.
|
||||
/// </summary>
|
||||
/// <param name="attributes">An array of type Attribute that is used as a filter. </param>
|
||||
/// <returns>An EventDescriptorCollection that represents the filtered events for this component instance.</returns>
|
||||
public EventDescriptorCollection GetEvents(Attribute[]? attributes)
|
||||
{
|
||||
return TypeDescriptor.GetEvents(m_handle, attributes, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the events for this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>An EventDescriptorCollection that represents the events for this component instance.</returns>
|
||||
public EventDescriptorCollection GetEvents()
|
||||
{
|
||||
return TypeDescriptor.GetEvents(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the properties for this instance of a component using the attribute array as a filter.
|
||||
/// </summary>
|
||||
/// <param name="attributes">An array of type Attribute that is used as a filter.</param>
|
||||
/// <returns>A PropertyDescriptorCollection that
|
||||
/// represents the filtered properties for this component instance.</returns>
|
||||
public PropertyDescriptorCollection GetProperties(Attribute[]? attributes)
|
||||
{
|
||||
// get handle's properties
|
||||
PropertyDescriptorCollection collection = TypeDescriptor.GetProperties(m_handle, attributes, false);
|
||||
// create empty collection
|
||||
PropertyDescriptorCollection collection2 = new PropertyDescriptorCollection(new PropertyDescriptor[0]);
|
||||
|
||||
// filter properties by RevitVersionAttribute.
|
||||
// if there is RevitVersionAttribute specified and the designated names does not
|
||||
// contain current Revit version, the property will not be exposed.
|
||||
foreach (PropertyDescriptor pd in collection)
|
||||
{
|
||||
bool matchRevitVersion = true;
|
||||
foreach (Attribute att in pd.Attributes)
|
||||
{
|
||||
RevitVersionAttribute? pfa = att as RevitVersionAttribute;
|
||||
if (pfa != null)
|
||||
{
|
||||
if (!pfa.Names.Contains(RevitStartInfo.RevitProduct))
|
||||
matchRevitVersion = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (matchRevitVersion)
|
||||
collection2.Add(pd);
|
||||
}
|
||||
return collection2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the properties for this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>A PropertyDescriptorCollection that represents the properties
|
||||
/// for this component instance.</returns>
|
||||
public PropertyDescriptorCollection GetProperties()
|
||||
{
|
||||
return TypeDescriptor.GetProperties(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an object that contains the property described by the specified property descriptor.
|
||||
/// </summary>
|
||||
/// <param name="pd">A PropertyDescriptor that represents the property whose owner is to be found. </param>
|
||||
/// <returns>Handle object</returns>
|
||||
public object GetPropertyOwner(PropertyDescriptor? pd)
|
||||
{
|
||||
return m_handle;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// overrides ToString method
|
||||
/// </summary>
|
||||
/// <returns>The name of the handle object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Name;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// (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.Text;
|
||||
|
||||
using Autodesk.Revit;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// wrapper interface
|
||||
/// </summary>
|
||||
public interface IWrapper
|
||||
{
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the handle object.
|
||||
/// </summary>
|
||||
object Handle
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the handle.
|
||||
/// </summary>
|
||||
string Name
|
||||
{
|
||||
get;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user