I tried
pos = FreeCADGui.ActiveDocument.ActiveView.getPoint(mouseposition)
I hope you can help
Thanks,
Code: Select all
import Part, FreeCAD, PartGui, FreeCADGui
from FreeCAD import Base, Console
#App.newDocument()
#This class logs any mouse button events. As the registered callback function fires twice for 'down' and
#'up' events we need a boolean flag to handle this.
class ViewObserver:
def __init__(self):
secondtime = 1
def subselect(self, info):
DOWN = (info["State"] == "DOWN")
left = (info["Button"] == "BUTTON1")
pixpos = info["Position"]
pos = FreeCADGui.ActiveDocument.ActiveView.getPoint(pixpos)
if (left and DOWN):
# try:
pre = FreeCADGui.Selection.getPreselection()
param = pre.SubObjects[0].Surface.parameter(pos)
FreeCAD.Console.PrintMessage(pre.ObjectName+","+pre.SubElementNames[0]+"\n")
App.Console.PrintMessage("is and edge " + str(pos) + "\n")
# except:
# App.Console.PrintMessage("Oups"+"\n\n")
actview=Gui.activeDocument().activeView()
o = ViewObserver()
c = actview.addEventCallback("SoMouseButtonEvent",o.subselect)
# actview.removeEventCallback("SoMouseButtonEvent",c)