Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Precision of Units Conversion Node Area #12287

Merged
merged 1 commit into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Libraries/DynamoConversions/Conversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public static class Conversions
{ConversionUnit.Decimeters, .1},
{ConversionUnit.Meters, 1.0},
{ConversionUnit.SquareMeter,1},
{ConversionUnit.SquareFoot,0.093},
{ConversionUnit.SquareFoot,0.3048*0.3048},
{ConversionUnit.SquareInch,0.0006451612},
{ConversionUnit.SquareCentimeter,0.0001},
{ConversionUnit.SquareMillimeter,0.000001},
{ConversionUnit.Acres,4046.86},
{ConversionUnit.Hectares,10000},
{ConversionUnit.CubicMeters,1},
{ConversionUnit.CubicFoot,0.0283},
{ConversionUnit.CubicFoot,0.3048*0.3048*0.3048},
{ConversionUnit.CubicYards,0.765},
{ConversionUnit.CubicInches,1/61023.7},
{ConversionUnit.CubicCentimeter,0.000001},
Expand Down
14 changes: 14 additions & 0 deletions test/DynamoCoreWpfTests/DynamoConverterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,19 @@ public void ConvertBetweenHectaresToSquareMeter()
Assert.AreEqual(ConversionUnit.SquareMeter, converterNode.SelectedToConversion);
AssertPreviewValue("54435965-3778-49cd-8306-f116b3f73bde", 10000.0);
}

[Test]
public void ConvertBetweenAreaUnits()
{
var model = ViewModel.Model;
string openPath = Path.Combine(TestDirectory, @"core\units\UnitsConversionArea.dyn");
RunModel(openPath);

var converterNode =
model.CurrentWorkspace.NodeFromWorkspace("efbcafaf0e2546508f2f8eee448d46ad") as DynamoConverter;
Assert.AreEqual(ConversionUnit.SquareFoot, converterNode.SelectedFromConversion);
Assert.AreEqual(ConversionUnit.SquareMeter, converterNode.SelectedToConversion);
AssertPreviewValue("efbcafaf0e2546508f2f8eee448d46ad", 92.90304);
}
}
}
142 changes: 142 additions & 0 deletions test/core/units/UnitsConversionArea.dyn
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"Uuid": "9865fd01-78bd-4b29-9486-d992b38dc400",
"IsCustomNode": false,
"Description": "",
"Name": "UnitsConversionArea",
"ElementResolver": {
"ResolutionMap": {}
},
"Inputs": [],
"Outputs": [],
"Nodes": [
{
"ConcreteType": "CoreNodeModels.DynamoConvert, CoreNodeModels",
"NodeType": "ConvertBetweenUnitsNode",
"MeasurementType": "Area",
"FromConversion": "SquareFoot",
"ToConversion": "SquareMeter",
"Id": "efbcafaf0e2546508f2f8eee448d46ad",
"Inputs": [
{
"Id": "80679b55c6a14d1e91599232db1fc16b",
"Name": "",
"Description": "A numeric value for conversion.",
"UsingDefaultValue": true,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [
{
"Id": "f076c7f5991544e8a476b1e2144c0619",
"Name": "",
"Description": "A converted numeric value.",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Convert between units of measure."
},
{
"ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore",
"NodeType": "CodeBlockNode",
"Code": "1000;",
"Id": "3e5afd8cbf98482e962c5bb95709a839",
"Inputs": [],
"Outputs": [
{
"Id": "3e24b2951c3f443da7d2c56abe5c27ab",
"Name": "",
"Description": "Value of expression at line 1",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Allows for DesignScript code to be authored directly"
}
],
"Connectors": [
{
"Start": "3e24b2951c3f443da7d2c56abe5c27ab",
"End": "80679b55c6a14d1e91599232db1fc16b",
"Id": "616e75e911b3425ba3bafd35656ab32c",
"IsHidden": "False"
}
],
"Dependencies": [],
"NodeLibraryDependencies": [],
"Thumbnail": "",
"GraphDocumentationURL": null,
"ExtensionWorkspaceData": [
{
"ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670",
"Name": "Properties",
"Version": "2.13",
"Data": {}
}
],
"Author": "",
"Linting": {
"activeLinter": "None",
"activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a",
"warningCount": 0,
"errorCount": 0
},
"Bindings": [],
"View": {
"Dynamo": {
"ScaleFactor": 1.0,
"HasRunWithoutCrash": true,
"IsVisibleInDynamoLibrary": true,
"Version": "2.13.0.3156",
"RunType": "Automatic",
"RunPeriod": "1000"
},
"Camera": {
"Name": "Background Preview",
"EyeX": -17.0,
"EyeY": 24.0,
"EyeZ": 50.0,
"LookX": 12.0,
"LookY": -13.0,
"LookZ": -58.0,
"UpX": 0.0,
"UpY": 1.0,
"UpZ": 0.0
},
"ConnectorPins": [],
"NodeViews": [
{
"ShowGeometry": true,
"Name": "Convert Between Units",
"Id": "efbcafaf0e2546508f2f8eee448d46ad",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 315.39695515121832,
"Y": 48.290843219178925
},
{
"ShowGeometry": true,
"Name": "Code Block",
"Id": "3e5afd8cbf98482e962c5bb95709a839",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 33.0,
"Y": 59.265848777797942
}
],
"Annotations": [],
"X": 28.985692447834083,
"Y": 55.092025189076338,
"Zoom": 0.95404292488281262
}
}