I'm a bit of an self-uneducated programming bungler, so please forgive the abysmal coding and general ignorance.
I'm using FreeCAD which has an API to access a point in a CAD model.
class mySnapper:
def __init__(self):
self.point = None
def getPoint(self):
FreeCADGui.Snapper.getPoint(callback=self.clicked)
def clicked(self,point,extra):
self.point = point
print point
s = mySnapper()
s.getPoint()
print "point outside is:",s.point
print "~~~~"
This gives me the following result:
point outside is:None
~~~~
Vector(320.0, -3414.0, 168.15)
Clearly the class function returns before the the coordinate point is picked (and when the point value is "None").
When the point is picked, then the vector values are printed, but by this time the class function has already returned, so I can't actually use them.
How can I access the value within the "clicked" callback function? Would it be possible to instantiate a global variable which is updated?
I hope this makes sense...