-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathOSE_CommandButton.py
58 lines (52 loc) · 3.08 KB
/
OSE_CommandButton.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#***************************************************************************
#* *
#* This file is part of the FreeCAD_Workbench_Starter project. *
#* *
#* *
#* Copyright (C) 2017 *
#* Stephen Kaiser <[email protected]> *
#* *
#* This library is free software; you can redistribute it and/or *
#* modify it under the terms of the GNU Lesser General Public *
#* License as published by the Free Software Foundation; either *
#* version 2 of the License, or (at your option) any later version. *
#* *
#* This library is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
#* Lesser General Public License for more details. *
#* *
#* You should have received a copy of the GNU Lesser General Public *
#* License along with this library; if not, If not, see *
#* <http://www.gnu.org/licenses/>. *
#* *
#* *
#***************************************************************************
import FreeCAD, Part, OSEBase
from FreeCAD import Gui
class OSE_CommandButtonClass():
"""Command to add the printer frame"""
def GetResources(self):
return {'Pixmap' : OSEBase.ICON_PATH + '/DrawStyleWireFrame.svg', # the name of a svg file available in the resources
'Accel' : "Shift+S", # a default shortcut (optional)
'MenuText': "Add a frame",
'ToolTip' : "Adds a D3D printer frame"}
def Activated(self):
"Do something here when button is clicked"
FreeCAD.Console.PrintMessage("Workbench is working!")
if Gui.ActiveDocument == None:
FreeCAD.newDocument()
# view = Gui.activeDocument().activeView()
doc=FreeCAD.activeDocument()
n=list()
c = Part.Circle()
c.Radius=2.0
f = doc.addObject("Part::Feature", "Circle") # create a document with a circle feature
f.Shape = c.toShape() # Assign the circle shape to the shape property
doc.recompute()
return
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
Gui.addCommand('OSE_CommandButton', OSE_CommandButtonClass())