diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h
index 26a06ef3e..6fe2acc09 100644
--- a/src/libs/ifc/xml/vdomdocument.h
+++ b/src/libs/ifc/xml/vdomdocument.h
@@ -102,7 +102,8 @@ public:
     void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
 
     template <typename T>
-    void SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value, const T &condition) const;
+    void SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value,
+                                bool removeCondition) const;
 
     static quint32 GetParametrUInt(const QDomElement& domElement, const QString &name, const QString &defValue);
     static bool    GetParametrBool(const QDomElement& domElement, const QString &name, const QString &defValue);
@@ -216,9 +217,9 @@ inline void VDomDocument::SetAttribute<MeasurementsType>(QDomElement &domElement
 //---------------------------------------------------------------------------------------------------------------------
 template <typename T>
 inline void VDomDocument::SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value,
-                                                 const T &condition) const
+                                                 bool removeCondition) const
 {
-    value != condition ? domElement.setAttribute(name, value) : domElement.removeAttribute(name);
+    not removeCondition ? SetAttribute(domElement, name, value) : domElement.removeAttribute(name);
 }
 
 QT_WARNING_POP
diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp
index 09bb5943e..1ea6638d7 100644
--- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp
+++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp
@@ -286,16 +286,5 @@ void VToolCubicBezier::SetSplineAttributes(QDomElement &domElement, const VCubic
     doc->SetAttribute(domElement, AttrColor,    spl.GetColor());
     doc->SetAttribute(domElement, AttrPenStyle, spl.GetPenStyle());
     doc->SetAttribute(domElement, AttrAScale,   spl.GetApproximationScale());
-
-    if (spl.GetDuplicate() > 0)
-    {
-        doc->SetAttribute(domElement, AttrDuplicate, spl.GetDuplicate());
-    }
-    else
-    {
-        if (domElement.hasAttribute(AttrDuplicate))
-        {
-            domElement.removeAttribute(AttrDuplicate);
-        }
-    }
+    doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, spl.GetDuplicate(), spl.GetDuplicate() <= 0);
 }
diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp
index 4f886e544..3b2f9eb51 100644
--- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp
+++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp
@@ -269,19 +269,7 @@ void VToolCubicBezierPath::AddPathPoint(VAbstractPattern *doc, QDomElement &domE
 void VToolCubicBezierPath::SetSplinePathAttributes(QDomElement &domElement, const VCubicBezierPath &path)
 {
     doc->SetAttribute(domElement, AttrType, ToolType);
-
-    if (path.GetDuplicate() > 0)
-    {
-        doc->SetAttribute(domElement, AttrDuplicate, path.GetDuplicate());
-    }
-    else
-    {
-        if (domElement.hasAttribute(AttrDuplicate))
-        {
-            domElement.removeAttribute(AttrDuplicate);
-        }
-    }
-
+    doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, path.GetDuplicate(), path.GetDuplicate() <= 0);
     doc->SetAttribute(domElement, AttrColor, path.GetColor());
     doc->SetAttribute(domElement, AttrPenStyle, path.GetPenStyle());
     doc->SetAttribute(domElement, AttrAScale, path.GetApproximationScale());
diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp
index 860ff27cb..704ff3d69 100644
--- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp
+++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp
@@ -645,18 +645,7 @@ void VToolSpline::SetSplineAttributes(QDomElement &domElement, const VSpline &sp
     doc->SetAttribute(domElement, AttrColor,   spl.GetColor());
     doc->SetAttribute(domElement, AttrPenStyle, spl.GetPenStyle());
     doc->SetAttribute(domElement, AttrAScale, spl.GetApproximationScale());
-
-    if (spl.GetDuplicate() > 0)
-    {
-        doc->SetAttribute(domElement, AttrDuplicate, spl.GetDuplicate());
-    }
-    else
-    {
-        if (domElement.hasAttribute(AttrDuplicate))
-        {
-            domElement.removeAttribute(AttrDuplicate);
-        }
-    }
+    doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, spl.GetDuplicate(), spl.GetDuplicate() <= 0);
 
     if (domElement.hasAttribute(AttrKCurve))
     {
diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp
index 8a3a26425..f68b756df 100644
--- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp
+++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp
@@ -339,18 +339,7 @@ void VToolSplinePath::UpdateControlPoints(const VSpline &spl, QSharedPointer<VSp
 void VToolSplinePath::SetSplinePathAttributes(QDomElement &domElement, const VSplinePath &path)
 {
     doc->SetAttribute(domElement, AttrType, ToolType);
-
-    if (path.GetDuplicate() > 0)
-    {
-        doc->SetAttribute(domElement, AttrDuplicate, path.GetDuplicate());
-    }
-    else
-    {
-        if (domElement.hasAttribute(AttrDuplicate))
-        {
-            domElement.removeAttribute(AttrDuplicate);
-        }
-    }
+    doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, path.GetDuplicate(), path.GetDuplicate() <= 0);
 
     if (domElement.hasAttribute(AttrKCurve))
     {
diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp
index 3bcdc8893..f70d14659 100644
--- a/src/libs/vtools/tools/vtoolseamallowance.cpp
+++ b/src/libs/vtools/tools/vtoolseamallowance.cpp
@@ -358,10 +358,9 @@ void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement
     doc->SetAttribute(domData, AttrHeight, data.GetLabelHeight());
     doc->SetAttribute(domData, AttrFont, data.GetFontSize());
     doc->SetAttribute(domData, VAbstractPattern::AttrRotation, data.GetRotation());
-    doc->SetAttributeOrRemoveIf<bool>(domData, AttrCenterPin, data.CenterPin(), not (data.CenterPin() > NULL_ID));
-    doc->SetAttributeOrRemoveIf<bool>(domData, AttrTopLeftPin, data.TopLeftPin(), not (data.TopLeftPin() > NULL_ID));
-    doc->SetAttributeOrRemoveIf<bool>(domData, AttrBottomRightPin, data.BottomRightPin(),
-                                      not (data.BottomRightPin() > NULL_ID));
+    doc->SetAttributeOrRemoveIf(domData, AttrCenterPin, data.CenterPin(), data.CenterPin() <= NULL_ID);
+    doc->SetAttributeOrRemoveIf(domData, AttrTopLeftPin, data.TopLeftPin(), data.TopLeftPin() <= NULL_ID);
+    doc->SetAttributeOrRemoveIf(domData, AttrBottomRightPin, data.BottomRightPin(), data.BottomRightPin() <= NULL_ID);
     doc->SetLabelTemplate(domData, data.GetLabelTemplate());
 
     domElement.appendChild(domData);
@@ -379,33 +378,9 @@ void VToolSeamAllowance::AddPatternInfo(VAbstractPattern *doc, QDomElement &domE
     doc->SetAttribute(domData, AttrHeight, geom.GetLabelHeight());
     doc->SetAttribute(domData, AttrFont, geom.GetFontSize());
     doc->SetAttribute(domData, VAbstractPattern::AttrRotation, geom.GetRotation());
-
-    if (geom.CenterPin() > NULL_ID)
-    {
-        doc->SetAttribute(domData, AttrCenterPin, geom.CenterPin());
-    }
-    else
-    {
-        domData.removeAttribute(AttrCenterPin);
-    }
-
-    if (geom.TopLeftPin() > NULL_ID)
-    {
-        doc->SetAttribute(domData, AttrTopLeftPin, geom.TopLeftPin());
-    }
-    else
-    {
-        domData.removeAttribute(AttrTopLeftPin);
-    }
-
-    if (geom.BottomRightPin() > NULL_ID)
-    {
-        doc->SetAttribute(domData, AttrBottomRightPin, geom.BottomRightPin());
-    }
-    else
-    {
-        domData.removeAttribute(AttrBottomRightPin);
-    }
+    doc->SetAttributeOrRemoveIf(domData, AttrCenterPin, geom.CenterPin(), geom.CenterPin() <= NULL_ID);
+    doc->SetAttributeOrRemoveIf(domData, AttrTopLeftPin, geom.TopLeftPin(), geom.TopLeftPin() <= NULL_ID);
+    doc->SetAttributeOrRemoveIf(domData, AttrBottomRightPin, geom.BottomRightPin(), geom.BottomRightPin() <= NULL_ID);
 
     domElement.appendChild(domData);
 }
@@ -422,9 +397,9 @@ void VToolSeamAllowance::AddGrainline(VAbstractPattern *doc, QDomElement &domEle
     doc->SetAttribute(domData, AttrLength, glGeom.GetLength());
     doc->SetAttribute(domData, VAbstractPattern::AttrRotation, glGeom.GetRotation());
     doc->SetAttribute(domData, VAbstractPattern::AttrArrows, int(glGeom.GetArrowType()));
-    doc->SetAttributeOrRemoveIf<bool>(domData, AttrCenterPin, glGeom.CenterPin(), not (glGeom.CenterPin() > NULL_ID));
-    doc->SetAttributeOrRemoveIf<bool>(domData, AttrTopPin, glGeom.TopPin(), not (glGeom.TopPin() > NULL_ID));
-    doc->SetAttributeOrRemoveIf<bool>(domData, AttrBottomPin, glGeom.BottomPin(), not (glGeom.BottomPin() > NULL_ID));
+    doc->SetAttributeOrRemoveIf(domData, AttrCenterPin, glGeom.CenterPin(), glGeom.CenterPin() <= NULL_ID);
+    doc->SetAttributeOrRemoveIf(domData, AttrTopPin, glGeom.TopPin(), glGeom.TopPin() <= NULL_ID);
+    doc->SetAttributeOrRemoveIf(domData, AttrBottomPin, glGeom.BottomPin(), glGeom.BottomPin() <= NULL_ID);
 
     domElement.appendChild(domData);
 }