1
2 import sys
3 import types
4
5 import empro
6
7 if not hasattr(empro.internal, "adv"):
8 empro.internal.adv = types.ModuleType("empro.internal.adv")
9
10
12 import os
13 import empro
14 import gui
15 import json
16 import shutil
17
18 gui.initialize()
19
20 path = kwargs.get("path","")
21 hpeesof_dir = kwargs.get("hpeesof_dir","")
22 if hpeesof_dir:
23 empro.liboa.loadOALibraries(path, hpeesof_dir)
24 else:
25 empro.liboa.loadOALibraries(path)
26
27 oaDesignRef = empro.geometry.OaDesignRef()
28 lib = kwargs.get("lib","")
29 oaDesignRef.lib = lib
30 cell = kwargs.get("cell","")
31 oaDesignRef.cell = cell
32 view = kwargs.get("view","")
33 oaDesignRef.view = view
34 oaDesignRef.substLib = kwargs.get("substlib","")
35 oaDesignRef.subst = kwargs.get("substname","")
36
37 defaultSimDir = empro.liboa.getVirtualCellViewSimulationPath(lib, cell, "_3DViewer")
38 extraInputBaseDir = os.path.join(defaultSimDir, "extra")
39 defaultExtraInputDir = os.path.join(extraInputBaseDir, "0")
40 kw_libS3D = kwargs.get("libS3D","")
41 if kw_libS3D:
42 if os.path.exists(kw_libS3D):
43 if not os.path.exists(defaultExtraInputDir): os.makedirs(defaultExtraInputDir)
44 shutil.copyfile(kw_libS3D, os.path.join(defaultExtraInputDir, "proj_libS3D.xml"))
45 elif os.path.exists(os.path.join(defaultExtraInputDir, "proj_libS3D.xml")):
46 os.remove(os.path.exists(os.path.join(defaultExtraInputDir, "proj_libS3D.xml")))
47 var_dict = kwargs.get("var_dict")
48 if var_dict is not None:
49 if not os.path.exists(defaultExtraInputDir): os.makedirs(defaultExtraInputDir)
50 with open(os.path.join(defaultExtraInputDir, "varDict.json"), 'w') as outfile:
51 json.dump(var_dict, outfile)
52 expr_dict = kwargs.get("expr_dict")
53 if expr_dict is not None:
54 if not os.path.exists(defaultExtraInputDir): os.makedirs(defaultExtraInputDir)
55 with open(os.path.join(defaultExtraInputDir, "exprDict.json"), 'w') as outfile:
56 json.dump(expr_dict, outfile)
57
58 try:
59 with empro.activeProject as project:
60 sim = project.createSimulationData()
61 sim.engine="FemEngine"
62 layout = empro.geometry.OaLayout.readLayoutEx(oaDesignRef, 0, extraInputBaseDir)
63 project.geometry().append(layout)
64 project._clearUndoStack()
65 except:
66 from empro.gui import MessageBox
67 import sys
68 msg = str(sys.exc_info()[1])
69 MessageBox.critical( "Load Project", "The project has failed to load: " + msg, 0, 0 )
70
71
72
73
74
75
76
77
78
79 pv = empro.gui.activeProjectView()
80 gv = pv.geometryView()
81
82
83 pv.windowTitle = cell + " [" + lib + ":" + cell + ":" + view + "] " + "(View3D)"
84
85 gv.useCamera("swiso")
86 pv.showGeometryView()
87
88 adv = empro.gui.AdvView()
89 adv.showAll()
90
91
92 gv.zoomGeometryViewToExtents()
93
94
95 if hasattr(empro.addons, "LayersDisplay"):
96 try:
97 empro.addons.LayersDisplay.activateDockWidget()
98 except:
99 pass
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
118