Code: Select all
OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: English/United States (en_US)
Installed mods:
* Help 1.0.3
I am attempting to adapt an example from pyside examples and have a cancel work.
If I run this, it works and I can draw two lines, and no errors. However on the second loop if I hit cancel I would expect the first line to be there but of course no second line. But nothing is drawn. I am still new to this.
Code:
Code: Select all
import FreeCAD, FreeCADGui
import Draft
from math import cos, sin, radians
from PySide import QtGui
WIRE = True
INPUTININCHES = True
if INPUTININCHES:
convert = 25.4
else:
convert = 1.0
getDouble = QtGui.QInputDialog.getDouble
Vector, Placement = App.Vector, App.Placement
doc = App.ActiveDocument
sel = Gui.Selection.getSelectionEx()
start_point = Vector(0, 0, 0)
if sel:
sel, = sel
if sel.PickedPoints:
start_point = sel.PickedPoints[-1]
FLAG = 0
I = 1
while I < 3:
REPLY = QtGui.QInputDialog.getText(None, "Ouija Central", "Length:")
if REPLY[1]:
# user clicked OK
MYREPLY = float(REPLY[0])
else:
# user clicked Cancel
#MYREPLY = REPLY[0] # which will be "" if they clicked Cancel
sys.exit(0)
ANG = QtGui.QInputDialog.getText(None, "Ouija Central", "Angle:")
if ANG[1]:
# user clicked OK
ANG = float(ANG[0])
else:
# user clicked Cancel
ANG = ANG[0] # which will be "" if they clicked Cancel
def line_length(x1=0.0, y1=0.0, z1=0.0, length=10.0, angle=0.0):
x2 = x1 + (length * cos(radians(angle)))
y2 = y1 + (length * sin(radians(angle)))
z2 = z1 # + ()
Draft.makeWire([FreeCAD.Vector(x1, y1, z1), FreeCAD.Vector(x2, y2, z2)])
# Example:
# x1 = 0.0 # Edit coordinate x1 origin
# y1 = 0.0 # Edit coordinate y1 origin
# z1 = 0.0 # Edit coordinate z1 origin
# length = 50.0 # Edit length
# angle = 45.0 # Edit angle plane XY
# line_length(x1, y1, z1, length, angle)
x1 = 0.0 # Edit coordinate x1 origin
y1 = 0.0 # Edit coordinate y1 origin
z1 = 0.0 # Edit coordinate z1 origin
length = MYREPLY * 25.4 # Edit length
angle = ANG # Edit angle plane XY
line_length(x1, y1, z1, length, angle)
I = I + 1
Edit:: <unknown exception data>
Found this:
I added:
Code: Select all
if MYREPLY == 9999:
return