replaced Revit 2020 SDK by Revit 2021 SDK

This commit is contained in:
Jeremy Tammik
2020-05-11 14:07:56 +02:00
parent 06ba6e0541
commit 64f8b0ed3e
250 changed files with 1225 additions and 1496 deletions
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CurtainWallGrid</RootNamespace>
<AssemblyName>CurtainWallGrid</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -623,11 +623,10 @@ namespace Revit.SDK.Samples.CurtainWallGrid.CS
Vector4 vec = new Vector4(xyz);
vec = m_coordinates.RestoreMatrix.Transform(vec);
offset = vec.Z - m_geometry.LineToBeMoved.FullCurve.GetEndPoint(0).Z;
offset = Unit.CovertFromAPI(m_myDocument.LengthUnitType, offset);
offset = Unit.CovertFromAPI(m_myDocument.LengthUnit, offset);
// showing the move offset
m_drawObject.Text = "Offset: " + Math.Round(offset, 1) +
Revit.SDK.Samples.CurtainWallGrid.CS.Properties.Resources.ResourceManager.GetString(m_myDocument.LengthUnitType.ToString());
m_drawObject.Text = "Offset: " + Math.Round(offset, 1) + Unit.GetUnitLabel(m_myDocument.LengthUnit);
m_drawObject.TextPosition = mousePosition;
m_drawObject.TextPen = redPen;
return;
@@ -653,11 +652,10 @@ namespace Revit.SDK.Samples.CurtainWallGrid.CS
Vector4 vec = new Vector4(xyz);
vec = m_coordinates.RestoreMatrix.Transform(vec);
offset = vec.X - m_geometry.LineToBeMoved.FullCurve.GetEndPoint(0).X;
offset = Unit.CovertFromAPI(m_myDocument.LengthUnitType, offset);
offset = Unit.CovertFromAPI(m_myDocument.LengthUnit, offset);
// showing the move offset
m_drawObject.Text = "Offset: " + Math.Round(offset, 1) +
Revit.SDK.Samples.CurtainWallGrid.CS.Properties.Resources.ResourceManager.GetString(m_myDocument.LengthUnitType.ToString());
m_drawObject.Text = "Offset: " + Math.Round(offset, 1) + Unit.GetUnitLabel(m_myDocument.LengthUnit);
m_drawObject.TextPosition = mousePosition;
m_drawObject.TextPen = redPen;
}
+7 -7
View File
@@ -102,7 +102,7 @@ namespace Revit.SDK.Samples.CurtainWallGrid.CS
LineOperation m_activeOperation;
// the length unit type for the active Revit document
DisplayUnitType m_LengthUnitType;
ForgeTypeId m_LengthUnit;
// store the message of the sample
private KeyValuePair<string/*msgText*/, bool/*is warningOrError*/> m_message;
@@ -199,11 +199,11 @@ namespace Revit.SDK.Samples.CurtainWallGrid.CS
}
}
public DisplayUnitType LengthUnitType
public ForgeTypeId LengthUnit
{
get
{
return m_LengthUnitType;
return m_LengthUnit;
}
}
@@ -271,16 +271,16 @@ namespace Revit.SDK.Samples.CurtainWallGrid.CS
/// </summary>
private void GetLengthUnitType()
{
UnitType unitType = UnitType.UT_Length;
ForgeTypeId specTypeId = SpecTypeId.Length;
Units projectUnit = m_document.GetUnits();
try
{
Autodesk.Revit.DB.FormatOptions formatOption = projectUnit.GetFormatOptions(unitType);
m_LengthUnitType = formatOption.DisplayUnits;
Autodesk.Revit.DB.FormatOptions formatOption = projectUnit.GetFormatOptions(specTypeId);
m_LengthUnit = formatOption.GetUnitTypeId();
}
catch (System.Exception /*e*/)
{
m_LengthUnitType = DisplayUnitType.DUT_DECIMAL_FEET;
m_LengthUnit = UnitTypeId.Feet;
}
}
@@ -8,8 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace Revit.SDK.Samples.CurtainWallGrid.CS.Properties
{
namespace CurtainWallGrid.Properties {
using System;
@@ -20,7 +19,7 @@ namespace Revit.SDK.Samples.CurtainWallGrid.CS.Properties
// 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", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -60,77 +59,5 @@ namespace Revit.SDK.Samples.CurtainWallGrid.CS.Properties
resourceCulture = value;
}
}
/// <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 &apos;.
/// </summary>
internal static string DUT_DECIMAL_FEET {
get {
return ResourceManager.GetString("DUT_DECIMAL_FEET", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &quot;.
/// </summary>
internal static string DUT_DECIMAL_INCHES {
get {
return ResourceManager.GetString("DUT_DECIMAL_INCHES", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &apos;.
/// </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 &quot;.
/// </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);
}
}
}
}
@@ -112,33 +112,9 @@
<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>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.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>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<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>
</root>
+35 -21
View File
@@ -38,10 +38,10 @@ namespace Revit.SDK.Samples.CurtainWallGrid.CS
{
#region Methods
/// <summary>
/// Convert the value get from RevitAPI to the value indicated by DisplayUnitType
/// Convert the value get from RevitAPI to the value indicated by ForgeTypeId
/// </summary>
/// <param name="to">
/// DisplayUnitType indicates unit of target value
/// ForgeTypeId indicates unit of target value
/// </param>
/// <param name="value">
/// value get from RevitAPI
@@ -49,51 +49,65 @@ namespace Revit.SDK.Samples.CurtainWallGrid.CS
/// <returns>
/// Target value
/// </returns>
public static double CovertFromAPI(DisplayUnitType to, double value)
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
/// Convert a value indicated by ForgeTypeId 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
/// ForgeTypeId indicates the unit of the value to be converted
/// </param>
/// <returns>
/// Target value
/// </returns>
public static double CovertToAPI(double value, DisplayUnitType from)
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
/// Get ratio between value in RevitAPI and value to display indicated by ForgeTypeId
/// </summary>
/// <param name="dut">
/// DisplayUnitType indicates display unit type
/// ForgeTypeId indicates display unit type
/// </param>
/// <returns>
/// Ratio
/// </returns>
private static double ImperialDutRatio(DisplayUnitType dut)
private static double ImperialDutRatio(ForgeTypeId unitTypeId)
{
switch (dut)
{
case DisplayUnitType.DUT_DECIMAL_FEET: return 1;
case DisplayUnitType.DUT_FEET_FRACTIONAL_INCHES: return 1;
case DisplayUnitType.DUT_DECIMAL_INCHES: return 12;
case DisplayUnitType.DUT_FRACTIONAL_INCHES: return 12;
case DisplayUnitType.DUT_METERS: return 0.3048;
case DisplayUnitType.DUT_CENTIMETERS: return 30.48;
case DisplayUnitType.DUT_MILLIMETERS: return 304.8;
case DisplayUnitType.DUT_METERS_CENTIMETERS: return 0.3048;
default: return 1;
}
if (unitTypeId == UnitTypeId.Feet) return 1;
if (unitTypeId == UnitTypeId.FeetFractionalInches) return 1;
if (unitTypeId == UnitTypeId.Inches) return 12;
if (unitTypeId == UnitTypeId.FractionalInches) return 12;
if (unitTypeId == UnitTypeId.Meters) return 0.3048;
if (unitTypeId == UnitTypeId.Centimeters) return 30.48;
if (unitTypeId == UnitTypeId.Millimeters) return 304.8;
if (unitTypeId == UnitTypeId.MetersCentimeters) return 0.3048;
return 1;
}
public static string GetUnitLabel(ForgeTypeId unitTypeId)
{
Dictionary<ForgeTypeId, string> unitLabels = new Dictionary<ForgeTypeId, string> {
{ UnitTypeId.Centimeters, "cm" },
{ UnitTypeId.Feet, "'" },
{ UnitTypeId.Inches, "\"" },
{ UnitTypeId.FeetFractionalInches, "'" },
{ UnitTypeId.FractionalInches, "\"" },
{ UnitTypeId.Meters, "m" },
{ UnitTypeId.MetersCentimeters, "m" },
{ UnitTypeId.Millimeters, "mm" }
};
if (unitLabels.ContainsKey(unitTypeId))
return unitLabels[unitTypeId];
return string.Empty;
}
#endregion
}
@@ -279,12 +279,13 @@ namespace Revit.SDK.Samples.CurtainWallGrid.CS
private void WriteCoordinate(Graphics graphics, Pen pen)
{
PointD assistPointD = ConvertToPointD(m_wallLine2D.AssistantPoint);
double x = Unit.CovertFromAPI(m_myDocument.LengthUnitType, assistPointD.X);
double y = Unit.CovertFromAPI(m_myDocument.LengthUnitType, assistPointD.Y);
double x = Unit.CovertFromAPI(m_myDocument.LengthUnit, assistPointD.X);
double y = Unit.CovertFromAPI(m_myDocument.LengthUnit, assistPointD.Y);
string xCoorString = Convert.ToString(Math.Round(x, 1));
string yCoorString = Convert.ToString(Math.Round(y, 1));
string unitType = Revit.SDK.Samples.CurtainWallGrid.CS.Properties.Resources.ResourceManager.GetString(m_myDocument.LengthUnitType.ToString());
string unitType = Unit.GetUnitLabel(m_myDocument.LengthUnit);
String coordinate = "(" + xCoorString + unitType + "," + yCoorString + unitType + ")";
graphics.DrawString(coordinate, m_coordinateFont, Brushes.Blue,
new PointF(m_wallLine2D.AssistantPoint.X + 2, m_wallLine2D.AssistantPoint.Y + 2));