diff --git a/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs b/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs
index 660e587..d870519 100644
--- a/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs
+++ b/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs
@@ -14,8 +14,8 @@ namespace OSCADSharp.ConsoleTests
{
static void Main(string[] args)
{
- var diam = new Variable("mainColumn", Sizes.HalfInch);
- var height = new Variable("overallHeight", Sizes.QuarterInch);
+ var diam = new Variable("mainColumn", Inches.Half);
+ var height = new Variable("overallHeight", Inches.Quarter);
Variables.Global.Add(diam);
Variables.Global.Add(height);
diff --git a/OSCADSharp/OSCADSharp.UnitTests/Solids/CubeTests.cs b/OSCADSharp/OSCADSharp.UnitTests/Solids/CubeTests.cs
index e5c3596..2c4c43f 100644
--- a/OSCADSharp/OSCADSharp.UnitTests/Solids/CubeTests.cs
+++ b/OSCADSharp/OSCADSharp.UnitTests/Solids/CubeTests.cs
@@ -162,9 +162,9 @@ namespace OSCADSharp.UnitTests
[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 length = new Variable("deckBoxLength", Inches.Sixteenth * 32);
+ var width = new Variable("deckBoxWidth", Inches.Sixteenth * 32);
+ var height = new Variable("deckboxHeight", Inches.ToMillimeters(2.5));
var centered = new Variable("isCentered", true);
var cube = new Cube(length, width, height, centered);
@@ -174,5 +174,22 @@ namespace OSCADSharp.UnitTests
Assert.IsTrue(script.Contains("size = [deckBoxLength, deckBoxWidth, deckboxHeight]"));
Assert.IsTrue(script.Contains("center = isCentered"));
}
+
+ [TestMethod]
+ public void Cube_CloneHasSameBindings()
+ {
+ var cubeHeight = new Variable("myHeight", 35);
+ var cubeXTranslation = new Variable("xOffset", 50);
+
+ OSCADObject cube = new Cube(15, 5, 15);
+ cube.Bind("Height", cubeHeight);
+ cube = cube.Translate(cubeXTranslation, 0, 0);
+
+ var clone = cube.Clone();
+
+ string script = clone.ToString();
+
+
+ }
}
}
diff --git a/OSCADSharp/OSCADSharp.UnitTests/Solids/CylinderTests.cs b/OSCADSharp/OSCADSharp.UnitTests/Solids/CylinderTests.cs
index 7d0bd05..1ef54aa 100644
--- a/OSCADSharp/OSCADSharp.UnitTests/Solids/CylinderTests.cs
+++ b/OSCADSharp/OSCADSharp.UnitTests/Solids/CylinderTests.cs
@@ -183,8 +183,8 @@ namespace OSCADSharp.UnitTests
[TestMethod]
public void Cylinder_CanCreatePreBoundCylinderWithConstructor()
{
- var diam = new Variable("mainColumn", Sizes.HalfInch);
- var height = new Variable("overallHeight", Sizes.QuarterInch);
+ var diam = new Variable("mainColumn", Inches.Half);
+ var height = new Variable("overallHeight", Inches.Quarter);
var cyl = new Cylinder(diam, diam, height);
diff --git a/OSCADSharp/OSCADSharp.UnitTests/Solids/SphereTests.cs b/OSCADSharp/OSCADSharp.UnitTests/Solids/SphereTests.cs
index 30ebb2e..56fd53c 100644
--- a/OSCADSharp/OSCADSharp.UnitTests/Solids/SphereTests.cs
+++ b/OSCADSharp/OSCADSharp.UnitTests/Solids/SphereTests.cs
@@ -170,7 +170,7 @@ namespace OSCADSharp.UnitTests
[TestMethod]
public void Sphere_CanCreateSphereWithBindingsFromConstructor()
{
- var diam = new Variable("width", Sizes.OneInch);
+ var diam = new Variable("width", Inches.One);
var resolution = new Variable("rez", 100);
var sphere = new Sphere(diam, resolution);
diff --git a/OSCADSharp/OSCADSharp/Bindings/BindableVector.cs b/OSCADSharp/OSCADSharp/Bindings/BindableVector.cs
index 84654f7..8af9c08 100644
--- a/OSCADSharp/OSCADSharp/Bindings/BindableVector.cs
+++ b/OSCADSharp/OSCADSharp/Bindings/BindableVector.cs
@@ -53,5 +53,13 @@ namespace OSCADSharp.Bindings
return String.Format("[{0}, {1}, {2}]", x, y, z);
}
+
+ public new BindableVector Clone()
+ {
+ return new BindableVector(base.Clone())
+ {
+ bindings = this.bindings
+ };
+ }
}
}
diff --git a/OSCADSharp/OSCADSharp/Bindings/Bindings.cs b/OSCADSharp/OSCADSharp/Bindings/Bindings.cs
index 92f75a0..e726fc4 100644
--- a/OSCADSharp/OSCADSharp/Bindings/Bindings.cs
+++ b/OSCADSharp/OSCADSharp/Bindings/Bindings.cs
@@ -129,7 +129,16 @@ namespace OSCADSharp.Bindings
internal void Synonym(string propertyName, string alternateName)
{
this.synonyms[alternateName] = propertyName;
- }
+ }
+
+ internal Bindings Clone()
+ {
+ var clone = new Bindings(this.propertyNametoOpenSCADFieldMappings);
+ clone.synonyms = this.synonyms;
+ clone.bindings = this.bindings;
+
+ return clone;
+ }
#endregion
}
}
diff --git a/OSCADSharp/OSCADSharp/Scripting/Variable.cs b/OSCADSharp/OSCADSharp/Scripting/Variable.cs
index 4cb8aa0..1420b33 100644
--- a/OSCADSharp/OSCADSharp/Scripting/Variable.cs
+++ b/OSCADSharp/OSCADSharp/Scripting/Variable.cs
@@ -34,7 +34,7 @@ namespace OSCADSharp.Scripting
/// Must be compatible with the data type being assigned to.
///
public object Value { get; set; }
-
+
///
/// Gets this variable as a name = value string
///
@@ -42,6 +42,6 @@ namespace OSCADSharp.Scripting
public override string ToString()
{
return string.Format("{0} = {1}", this.Name, this.Value.ToString());
- }
+ }
}
}
diff --git a/OSCADSharp/OSCADSharp/Sizes.cs b/OSCADSharp/OSCADSharp/Sizes.cs
index 49df804..137006f 100644
--- a/OSCADSharp/OSCADSharp/Sizes.cs
+++ b/OSCADSharp/OSCADSharp/Sizes.cs
@@ -9,41 +9,41 @@ namespace OSCADSharp
///
/// Constants and conversions for units for us imperial-minded folks.
///
- public class Sizes
+ public class Inches
{
///
/// One imperial inch
///
- public const double OneInch = 25.4;
+ public const double One = 25.4;
///
/// Half of an imperial inch
///
- public const double HalfInch = OneInch / 2;
+ public const double Half = One / 2;
///
/// Quarter of an imperial inch
///
- public const double QuarterInch = HalfInch / 2;
+ public const double Quarter = Half / 2;
///
/// Eigth of an imperial inch
///
- public const double EigthInch = QuarterInch / 2;
+ public const double Eigth = Quarter / 2;
///
/// Sixteenth of an imperial inch
///
- public const double SixteenthInch = EigthInch / 2;
+ public const double Sixteenth = Eigth / 2;
///
/// Converts inches to millimeters
///
/// Number of inches
/// Equivalent value in milimeters
- public static double InchesToMillimeters(double inches)
+ public static double ToMillimeters(double inches)
{
- return inches * OneInch;
+ return inches * One;
}
}
}
diff --git a/OSCADSharp/OSCADSharp/Solids/Cube.cs b/OSCADSharp/OSCADSharp/Solids/Cube.cs
index 72f4853..f7811da 100644
--- a/OSCADSharp/OSCADSharp/Solids/Cube.cs
+++ b/OSCADSharp/OSCADSharp/Solids/Cube.cs
@@ -117,8 +117,9 @@ namespace OSCADSharp.Solids
return new Cube()
{
Name = this.Name,
- Size = this.Size,
- Center = this.Center
+ Size = ((BindableVector)this.Size).Clone(),
+ Center = this.Center,
+ bindings = this.bindings.Clone()
};
}
diff --git a/OSCADSharp/OSCADSharp/Solids/Cylinder.cs b/OSCADSharp/OSCADSharp/Solids/Cylinder.cs
index ad2391e..8e504ea 100644
--- a/OSCADSharp/OSCADSharp/Solids/Cylinder.cs
+++ b/OSCADSharp/OSCADSharp/Solids/Cylinder.cs
@@ -217,7 +217,8 @@ namespace OSCADSharp.Solids
Resolution = this.Resolution,
MinimumAngle = this.MinimumAngle,
MinimumCircumferentialLength = this.MinimumCircumferentialLength,
- Center = this.Center
+ Center = this.Center,
+ bindings = this.bindings.Clone()
};
}
diff --git a/OSCADSharp/OSCADSharp/Solids/Sphere.cs b/OSCADSharp/OSCADSharp/Solids/Sphere.cs
index 4715b14..f83b108 100644
--- a/OSCADSharp/OSCADSharp/Solids/Sphere.cs
+++ b/OSCADSharp/OSCADSharp/Solids/Sphere.cs
@@ -122,7 +122,8 @@ namespace OSCADSharp.Solids
Resolution = this.Resolution,
MinimumAngle = this.MinimumAngle,
MinimumFragmentSize = this.MinimumFragmentSize,
- Radius = this.Radius
+ Radius = this.Radius,
+ bindings = this.bindings.Clone()
};
}
diff --git a/OSCADSharp/OSCADSharp/Solids/Text3D.cs b/OSCADSharp/OSCADSharp/Solids/Text3D.cs
index 590c821..e29d368 100644
--- a/OSCADSharp/OSCADSharp/Solids/Text3D.cs
+++ b/OSCADSharp/OSCADSharp/Solids/Text3D.cs
@@ -106,7 +106,8 @@ namespace OSCADSharp.Solids
Font = this.Font,
Spacing = this.Spacing,
TextDirection = this.TextDirection,
- Language = this.Language
+ Language = this.Language,
+ bindings = this.bindings.Clone()
};
}
diff --git a/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs b/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs
index 0ff9925..8b90f47 100644
--- a/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs
@@ -58,7 +58,8 @@ namespace OSCADSharp.Transforms
{
return new ColoredObject(this.obj.Clone(), this.ColorName, this.Opacity)
{
- Name = this.Name
+ Name = this.Name,
+ bindings = this.bindings.Clone()
};
}
diff --git a/OSCADSharp/OSCADSharp/Transforms/MirroredObject.cs b/OSCADSharp/OSCADSharp/Transforms/MirroredObject.cs
index fcea8ba..2eba83a 100644
--- a/OSCADSharp/OSCADSharp/Transforms/MirroredObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/MirroredObject.cs
@@ -56,7 +56,8 @@ namespace OSCADSharp.Transforms
{
return new MirroredObject(this.obj.Clone(), this.Normal)
{
- Name = this.Name
+ Name = this.Name,
+ bindings = this.bindings.Clone()
};
}
diff --git a/OSCADSharp/OSCADSharp/Transforms/ResizedObject.cs b/OSCADSharp/OSCADSharp/Transforms/ResizedObject.cs
index a3a9c40..97b3d4b 100644
--- a/OSCADSharp/OSCADSharp/Transforms/ResizedObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/ResizedObject.cs
@@ -56,7 +56,8 @@ namespace OSCADSharp.Transforms
{
return new ResizedObject(this.obj.Clone(), this.Size)
{
- Name = this.Name
+ Name = this.Name,
+ bindings = this.bindings.Clone()
};
}
diff --git a/OSCADSharp/OSCADSharp/Transforms/RotatedObject.cs b/OSCADSharp/OSCADSharp/Transforms/RotatedObject.cs
index c95710a..0af5f60 100644
--- a/OSCADSharp/OSCADSharp/Transforms/RotatedObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/RotatedObject.cs
@@ -56,7 +56,8 @@ namespace OSCADSharp.Transforms
{
return new RotatedObject(this.obj.Clone(), this.Angle)
{
- Name = this.Name
+ Name = this.Name,
+ bindings = this.bindings.Clone()
};
}
diff --git a/OSCADSharp/OSCADSharp/Transforms/ScaledObject.cs b/OSCADSharp/OSCADSharp/Transforms/ScaledObject.cs
index 9f34dd5..18a856b 100644
--- a/OSCADSharp/OSCADSharp/Transforms/ScaledObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/ScaledObject.cs
@@ -56,7 +56,8 @@ namespace OSCADSharp.Transforms
{
return new ScaledObject(this.obj.Clone(), this.ScaleFactor)
{
- Name = this.Name
+ Name = this.Name,
+ bindings = this.bindings.Clone()
};
}
diff --git a/OSCADSharp/OSCADSharp/Transforms/TranslatedObject.cs b/OSCADSharp/OSCADSharp/Transforms/TranslatedObject.cs
index f9a74db..d6863e8 100644
--- a/OSCADSharp/OSCADSharp/Transforms/TranslatedObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/TranslatedObject.cs
@@ -53,7 +53,8 @@ namespace OSCADSharp.Transforms
{
return new TranslatedObject(this.obj.Clone(), this.Vector)
{
- Name = this.Name
+ Name = this.Name,
+ bindings = this.bindings.Clone()
};
}