# Repeat the process until user click cancel button

**URL:** <https://forum.dynamobim.com/t/repeat-the-process-until-user-click-cancel-button/75065>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [April 1, 2022, 9:42am UTC](https://forum.dynamobim.com/t/repeat-the-process-until-user-click-cancel-button/75065 "2022-04-01T09:42:30Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [April 9, 2022, 6:06pm UTC](https://forum.dynamobim.com/t/repeat-the-process-until-user-click-cancel-button/75065/13 "2022-04-09T18:06:28Z")

</div>

Your request is really very specific, the least you could have done was to explore a solution that I mentioned earlier (wpf or Winform).

Here is a example with Winform (I hope this example will be useful for several users).

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/c/cce09487f251ad5f181d4fbc71824a383aa22870.png)

```auto
import sys
import clr
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitAPI')
import Autodesk
import Autodesk.Revit.DB as DB

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI.Selection import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')
import System.Drawing
import System.Windows.Forms
from System.Drawing import *
from System.Windows.Forms import *

class MyForm(Form):
	def __init__ (self):
		self.InitializeComponent()
	
	def InitializeComponent(self):
		self._buttonCancel = System.Windows.Forms.Button()
		self._buttonOk = System.Windows.Forms.Button()
		self._label1 = System.Windows.Forms.Label()
		self._label2 = System.Windows.Forms.Label()
		self._label3 = System.Windows.Forms.Label()
		self.numericaNgle = System.Windows.Forms.NumericUpDown()
		self.numericx = System.Windows.Forms.NumericUpDown()
		self.numericy = System.Windows.Forms.NumericUpDown()
		self.numericaNgle.BeginInit()
		self.numericx.BeginInit()
		self.numericy.BeginInit()
		self.SuspendLayout()
		# 
		# buttonCancel
		self._buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
		self._buttonCancel.Location = System.Drawing.Point(12, 201)
		self._buttonCancel.Name = "buttonCancel"
		self._buttonCancel.Size = System.Drawing.Size(110, 40)
		self._buttonCancel.TabIndex = 2
		self._buttonCancel.Text = "Quit"
		self._buttonCancel.UseVisualStyleBackColor = True
		# 
		# buttonOk
		self._buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK
		self._buttonOk.Location = System.Drawing.Point(163, 201)
		self._buttonOk.Name = "buttonOk"
		self._buttonOk.Size = System.Drawing.Size(110, 40)
		self._buttonOk.TabIndex = 2
		self._buttonOk.Text = "Select Column to Apply"
		self._buttonOk.UseVisualStyleBackColor = True
		# 
		# label1
		self._label1.Location = System.Drawing.Point(156, 31)
		self._label1.Name = "label1"
		self._label1.Size = System.Drawing.Size(119, 23)
		self._label1.TabIndex = 3
		self._label1.Text = "Angle (Degre)"
		# 
		# label2
		self._label2.Location = System.Drawing.Point(156, 79)
		self._label2.Name = "label2"
		self._label2.Size = System.Drawing.Size(119, 23)
		self._label2.TabIndex = 3
		self._label2.Text = "X (millimeter)"
		# 
		# label3
		self._label3.Location = System.Drawing.Point(156, 129)
		self._label3.Name = "label3"
		self._label3.Size = System.Drawing.Size(119, 23)
		self._label3.TabIndex = 3
		self._label3.Text = "Y (millimeter)"
		# 
		# numericAngle
		self.numericaNgle.Location = System.Drawing.Point(12, 29)
		self.numericaNgle.Maximum = System.Decimal(System.Array[System.Int32]([1000,0,0,0]))
		self.numericaNgle.Minimum = System.Decimal(System.Array[System.Int32]([1000,0,0,-2147483648]))
		self.numericaNgle.Name = "numericAngle"
		self.numericaNgle.Size = System.Drawing.Size(120, 20)
		self.numericaNgle.TabIndex = 4
		# 
		# numericX
		self.numericx.Location = System.Drawing.Point(12, 77)
		self.numericx.Maximum = System.Decimal(System.Array[System.Int32]([1000,0,0,0]))
		self.numericx.Minimum = System.Decimal(System.Array[System.Int32]([1000,0,0,-2147483648]))
		self.numericx.Name = "numericX"
		self.numericx.Size = System.Drawing.Size(120, 20)
		self.numericx.TabIndex = 4
		# 
		# numericY
		self.numericy.Location = System.Drawing.Point(12, 127)
		self.numericy.Maximum = System.Decimal(System.Array[System.Int32]([1000,0,0,0]))
		self.numericy.Minimum = System.Decimal(System.Array[System.Int32]([1000,0,0,-2147483648]))
		self.numericy.Name = "numericY"
		self.numericy.Size = System.Drawing.Size(120, 20)
		self.numericy.TabIndex = 4
		# 
		# Form9
		self.ClientSize = System.Drawing.Size(295, 261)
		self.FormBorderStyle = FormBorderStyle.FixedSingle
		self.Controls.Add(self.numericy)
		self.Controls.Add(self.numericx)
		self.Controls.Add(self.numericaNgle)
		self.Controls.Add(self._label3)
		self.Controls.Add(self._label2)
		self.Controls.Add(self._label1)
		self.Controls.Add(self._buttonOk)
		self.Controls.Add(self._buttonCancel)
		self.Name = "Form9"
		self.Text = "Change Column Location"
		self.numericaNgle.EndInit()
		self.numericx.EndInit()
		self.numericy.EndInit()
		self.ResumeLayout(False)

TransactionManager.Instance.EnsureInTransaction(doc)
out = []
i = 0
while i < 200:
	i += 1
	objform = MyForm()
	objform.ShowDialog()
	if objform.DialogResult == DialogResult.OK:
		try:
			ref = uidoc.Selection.PickObject(ObjectType.Element, 'Select Column, press ECS key to quit')
		except Exception as ex:
			break
		else:
			elem = doc.GetElement(ref)
			angle = System.Decimal.ToDouble(objform.numericaNgle.Value) * 0.0174533 # convert degree to radian
			x_translate = System.Decimal.ToDouble(objform.numericx.Value) * 0.00328084 # convert millimeter to feet
			y_translate = System.Decimal.ToDouble(objform.numericy.Value) * 0.00328084 # convert millimeter to feet
			locPt = elem.Location.Point
			axis = DB.Line.CreateUnbound(locPt, DB.XYZ(0,0,1))
			DB.ElementTransformUtils.RotateElement(doc, elem.Id, axis, angle)
			DB.ElementTransformUtils.MoveElement(doc, elem.Id, DB.XYZ(x_translate, y_translate, 0))
			doc.Regenerate()
			out.append(elem)
	else:
		break
	objform.Dispose()

TransactionManager.Instance.TransactionTaskDone()
OUT = out

```

As a reminder, the forum is not a “do your job”  
the forum rules ([How to get help on the Dynamo forums](https://forum.dynamobim.com/t/how-to-get-help-on-the-dynamo-forums/4677))  
the community guidelines ([https://forum.dynamobim.com/faq](https://forum.dynamobim.com/faq))

---

_[View the full topic](https://forum.dynamobim.com/t/repeat-the-process-until-user-click-cancel-button/75065)._
