class MyMouseCreatePointCommand: def GetResources(self): return {'Pixmap': 'a2p_Solver', 'MenuText': '鼠标创建点', 'ToolTip': '创建点'} def Activated(self): #点击按钮执行的动作 """Do something here""" import Draft import Part from FreeCAD import Base # 遍历选择的对象 for o in FreeCADGui.Selection.getSelectionEx(): o.PickedPoints[0] # 创建点 Draft.makePoint(o.PickedPoints[0]) # 打印点坐标 print(o.PickedPoints[0]) def IsActive(self): """Here you can define if the command must be active or not (greyed) if certain conditions are met or not. This function is optional.""" return True FreeCADGui.addCommand('MyMouseCreatePointCommand', MyMouseCreatePointCommand()) 程序员阿飞 2021年4月21日
程序员阿飞
2021年4月21日