diff --git a/OSCADSharp/OSCADSharp/OSCADObject.cs b/OSCADSharp/OSCADSharp/OSCADObject.cs
index 6b3584a..8f51055 100644
--- a/OSCADSharp/OSCADSharp/OSCADObject.cs
+++ b/OSCADSharp/OSCADSharp/OSCADObject.cs
@@ -767,6 +767,17 @@ namespace OSCADSharp
///
internal OSCADObject Parent { get; set; }
+ ///
+ /// If the variable is not null, binds it to the property specified
+ ///
+ ///
+ ///
+ internal void BindIfVariableNotNull(string property, Variable variable)
+ {
+ if (variable != null)
+ this.Bind(property, variable);
+ }
+
///
/// Internal collection of children for this object
///
diff --git a/OSCADSharp/OSCADSharp/Solids/Sphere.cs b/OSCADSharp/OSCADSharp/Solids/Sphere.cs
index 88d3ad9..4715b14 100644
--- a/OSCADSharp/OSCADSharp/Solids/Sphere.cs
+++ b/OSCADSharp/OSCADSharp/Solids/Sphere.cs
@@ -75,14 +75,10 @@ namespace OSCADSharp.Solids
///
public Sphere(Variable diameter = null, Variable resolution = null, Variable minimumAngle = null, Variable minimumFragmentSize = null)
{
- if (diameter != null)
- this.Bind("diameter", diameter);
- if (resolution != null)
- this.Bind("resolution", resolution);
- if (minimumAngle != null)
- this.Bind("minimumangle", minimumAngle);
- if (minimumFragmentSize != null)
- this.Bind("minimumfragmentsize", minimumFragmentSize);
+ this.BindIfVariableNotNull("diameter", diameter);
+ this.BindIfVariableNotNull("resolution", resolution);
+ this.BindIfVariableNotNull("minimumangle", minimumAngle);
+ this.BindIfVariableNotNull("minimumfragmentsize", minimumFragmentSize);
}
#endregion
diff --git a/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs b/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs
index c914b68..0ff9925 100644
--- a/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/ColoredObject.cs
@@ -39,10 +39,7 @@ namespace OSCADSharp.Transforms
internal ColoredObject(OSCADObject obj, Variable colorName, Variable opacity) : base(obj)
{
this.Bind("color", colorName);
- if(opacity != null)
- {
- this.Bind("opacity", opacity);
- }
+ this.BindIfVariableNotNull("opacity", opacity);
}
public override string ToString()
diff --git a/OSCADSharp/OSCADSharp/Transforms/MirroredObject.cs b/OSCADSharp/OSCADSharp/Transforms/MirroredObject.cs
index f8fda95..fcea8ba 100644
--- a/OSCADSharp/OSCADSharp/Transforms/MirroredObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/MirroredObject.cs
@@ -38,13 +38,9 @@ namespace OSCADSharp.Transforms
internal MirroredObject(OSCADObject obj, Vector3 normal, Variable x, Variable y, Variable z) : base(obj)
{
this.Normal = new BindableVector(normal);
-
- if (x != null)
- this.Bind("x", x);
- if (y != null)
- this.Bind("y", y);
- if (z != null)
- this.Bind("z", z);
+ this.BindIfVariableNotNull("x", x);
+ this.BindIfVariableNotNull("y", y);
+ this.BindIfVariableNotNull("z", z);
}
public override string ToString()
diff --git a/OSCADSharp/OSCADSharp/Transforms/ResizedObject.cs b/OSCADSharp/OSCADSharp/Transforms/ResizedObject.cs
index 18e24fa..a3a9c40 100644
--- a/OSCADSharp/OSCADSharp/Transforms/ResizedObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/ResizedObject.cs
@@ -38,12 +38,9 @@ namespace OSCADSharp.Transforms
{
this.Size = new BindableVector(size);
- if (x != null)
- this.Bind("x", x);
- if (y != null)
- this.Bind("y", y);
- if (z != null)
- this.Bind("z", z);
+ this.BindIfVariableNotNull("x", x);
+ this.BindIfVariableNotNull("y", y);
+ this.BindIfVariableNotNull("z", z);
}
public override string ToString()
diff --git a/OSCADSharp/OSCADSharp/Transforms/RotatedObject.cs b/OSCADSharp/OSCADSharp/Transforms/RotatedObject.cs
index af63dea..c95710a 100644
--- a/OSCADSharp/OSCADSharp/Transforms/RotatedObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/RotatedObject.cs
@@ -38,12 +38,9 @@ namespace OSCADSharp.Transforms
{
this.Angle = new BindableVector(angle);
- if (x != null)
- this.Bind("x", x);
- if (y != null)
- this.Bind("y", y);
- if (z != null)
- this.Bind("z", z);
+ this.BindIfVariableNotNull("x", x);
+ this.BindIfVariableNotNull("y", y);
+ this.BindIfVariableNotNull("z", z);
}
public override string ToString()
diff --git a/OSCADSharp/OSCADSharp/Transforms/ScaledObject.cs b/OSCADSharp/OSCADSharp/Transforms/ScaledObject.cs
index 43c0a24..9f34dd5 100644
--- a/OSCADSharp/OSCADSharp/Transforms/ScaledObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/ScaledObject.cs
@@ -38,12 +38,9 @@ namespace OSCADSharp.Transforms
{
this.ScaleFactor = new BindableVector(scale);
- if (x != null)
- this.Bind("x", x);
- if (y != null)
- this.Bind("y", y);
- if (z != null)
- this.Bind("z", z);
+ this.BindIfVariableNotNull("x", x);
+ this.BindIfVariableNotNull("y", y);
+ this.BindIfVariableNotNull("z", z);
}
public override string ToString()
diff --git a/OSCADSharp/OSCADSharp/Transforms/TranslatedObject.cs b/OSCADSharp/OSCADSharp/Transforms/TranslatedObject.cs
index 0b498e3..f9a74db 100644
--- a/OSCADSharp/OSCADSharp/Transforms/TranslatedObject.cs
+++ b/OSCADSharp/OSCADSharp/Transforms/TranslatedObject.cs
@@ -35,12 +35,9 @@ namespace OSCADSharp.Transforms
{
this.Vector = new BindableVector(vector);
- if (x != null)
- this.Bind("x", x);
- if (y != null)
- this.Bind("y", y);
- if (z != null)
- this.Bind("z", z);
+ this.BindIfVariableNotNull("x", x);
+ this.BindIfVariableNotNull("y", y);
+ this.BindIfVariableNotNull("z", z);
}
public override string ToString()