diff --git a/OSCADSharp/OSCADSharp.UnitTests/Solids/CubeTests.cs b/OSCADSharp/OSCADSharp.UnitTests/Solids/CubeTests.cs
index fb2a027..e5c3596 100644
--- a/OSCADSharp/OSCADSharp.UnitTests/Solids/CubeTests.cs
+++ b/OSCADSharp/OSCADSharp.UnitTests/Solids/CubeTests.cs
@@ -158,5 +158,21 @@ namespace OSCADSharp.UnitTests
Assert.AreEqual(centerVal.Value, obj.Center);
Assert.IsTrue(script.Contains("center = isCentered"));
}
+
+ [TestMethod]
+ public void Cube_ConstructorBindingsAppearInOutput()
+ {
+ var length = new Variable("deckBoxLength", Sizes.SixteenthInch * 32);
+ var width = new Variable("deckBoxWidth", Sizes.SixteenthInch * 32);
+ var height = new Variable("deckboxHeight", Sizes.InchesToMillimeters(2.5));
+ var centered = new Variable("isCentered", true);
+
+ var cube = new Cube(length, width, height, centered);
+
+ string script = cube.ToString();
+
+ Assert.IsTrue(script.Contains("size = [deckBoxLength, deckBoxWidth, deckboxHeight]"));
+ Assert.IsTrue(script.Contains("center = isCentered"));
+ }
}
}
diff --git a/OSCADSharp/OSCADSharp/Sizes.cs b/OSCADSharp/OSCADSharp/Sizes.cs
index b3271ea..49df804 100644
--- a/OSCADSharp/OSCADSharp/Sizes.cs
+++ b/OSCADSharp/OSCADSharp/Sizes.cs
@@ -41,9 +41,9 @@ namespace OSCADSharp
///
/// Number of inches
/// Equivalent value in milimeters
- public double InchesToMillimeters(double inches)
+ public static double InchesToMillimeters(double inches)
{
- return inches * 0.03937008;
+ return inches * OneInch;
}
}
}
diff --git a/OSCADSharp/OSCADSharp/Solids/Cube.cs b/OSCADSharp/OSCADSharp/Solids/Cube.cs
index b896c95..72f4853 100644
--- a/OSCADSharp/OSCADSharp/Solids/Cube.cs
+++ b/OSCADSharp/OSCADSharp/Solids/Cube.cs
@@ -78,6 +78,21 @@ namespace OSCADSharp.Solids
this.Center = center;
}
+
+ ///
+ /// Creates a new Cube object with variable bindings
+ ///
+ /// Size on the X axis
+ /// Size on the Y axis
+ /// Size on the Z axis
+ /// Indicates whether the cube should be centered on the origin
+ public Cube(Variable length = null, Variable width = null, Variable height = null, Variable center = null)
+ {
+ this.BindIfVariableNotNull("length", length);
+ this.BindIfVariableNotNull("width", width);
+ this.BindIfVariableNotNull("height", height);
+ this.BindIfVariableNotNull("center", center);
+ }
#endregion
#region Overrides