-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframingreload.py
More file actions
133 lines (106 loc) · 3.62 KB
/
framingreload.py
File metadata and controls
133 lines (106 loc) · 3.62 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import FreeCAD
import FreeCADGui
import Part
import os
from importlib import reload
class FramingReload_Command:
def GetResources(self):
image_path = '/stickframe/icons/reload.png'
global_path = FreeCAD.getHomePath()+"Mod"
user_path = FreeCAD.getUserAppDataDir()+"Mod"
icon_path = ""
if os.path.exists(user_path + image_path):
icon_path = user_path + image_path
elif os.path.exists(global_path + image_path):
icon_path = global_path + image_path
return {"MenuText": "FramingReload",
"ToolTip": "Reload my classes",
'Pixmap': str(icon_path)}
def IsActive(self):
if FreeCAD.ActiveDocument == None:
return False
else:
return True
def Activated(self):
import os
import fnmatch
cmds_path = FreeCAD.getUserAppDataDir()+"Mod/framing/commands"
# print (cmds_path)
# listOfFiles = os.listdir(cmds_path)
# pattern = "*.py"
# for entry in listOfFiles:
# if fnmatch.fnmatch(entry, pattern):
# print (entry)
# mod_name = entry.split(".")[0]
# print ("Module Name: ", mod_name)
# com_name = str(mod_name).capitalize()
# print ( "Command Name: ",com_name )
# TODO : add code to exclude empty __init__.py, empty __init__.py is added
# to sub-directories so that the files may be imported otherwise
# python blocks them, for security.
# try:
# # TODO : Load from commands. directory
# #module = __import__ ("commands." + mod_name)
# module = __import__(mod_name)
# print (module)
# reload(module)
# except ImportError as ie:
# raise ImportError(
# "Error: {} when importing {}".format(ie, mod_name))
# FreeCADGui.removeWorkbench("StickFrameWorkbench")
#import StickFrameWorkbench
#nw = FreeCADGui.Workbench
#sf = StickFrameWorkbench
# sf.StickFrameWorkbench.Initialize
try:
import stud
import plate
import floorjoist
import floor
# from floor import Floor_Command
import wall
import staircase
import door
import window
import ceilingjoist
import rafter
import collarbeam
import studspacer
import ridgebeam
import header
import panel
import floorpanel
import ceilingpanel
import roofpanel
# import stringer
# from stringer import Stringer
except:
print ("Import Error")
try:
#reload is only for modules ( not classes )
reload(stud)
reload(plate)
reload(floorjoist)
reload(floor)
# reload(Floor_Command)
reload(wall)
reload(staircase)
reload(door)
reload(window)
reload(ceilingjoist)
reload(rafter)
reload(collarbeam)
reload(studspacer)
reload(ridgebeam)
reload(header)
reload(panel)
reload(floorpanel)
reload(ceilingpanel)
reload(roofpanel)
# reload(stringer)
# reload(Stringer)
except Exception as e:
print ("Reload Error:")
print ( e )
print ("Framing Commands Reloaded")
FreeCADGui.addCommand('FramingReload', FramingReload_Command())