-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathhfcNastran95OpenF06.py
83 lines (65 loc) · 2.06 KB
/
hfcNastran95OpenF06.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
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
# hfcNastran95
#
# (c) Cean Wang ([email protected]) 2020
#
# This program is free software but WITHOUT ANY WARRANTY.
# Not for commercial use.
import FreeCAD,FreeCADGui
import Fem
import os
import subprocess
import PySide
from PySide import QtGui ,QtCore
from PySide.QtGui import *
from PySide.QtCore import *
class hfcNastran95OpenF06:
"hfcNastran95OpenF06"
def GetResources(self):
return {"MenuText": "F06",
"Accel": "Ctrl+t",
"ToolTip": "Open an F06 file",
"Pixmap": os.path.dirname(__file__)+"./resources/F06.svg"
}
def IsActive(self):
#if FreeCAD.ActiveDocument == None:
# return False
#else:
# return True
return True
def Activated(self):
import FreeCADGui
myDocument = FreeCAD.ActiveDocument
if myDocument==None:
pass
else:
iHfc =FreeCAD.ActiveDocument.getObject('hfc')
if iHfc==None:
ininame="Mod/hfcNastran95/hfcNastran95.ini"
inifile = FreeCAD.getHomePath()+ininame
if os.path.exists(inifile):
iniF = open(inifile,"r")
path=iniF.readline()
iniF.close()
else:
path=FreeCAD.getHomePath()
try:
filename = QFileDialog.getOpenFileName(None,QString.fromLocal8Bit("Read a Mystarn's F06 file"),path, "*.F06") # PyQt4
except Exception:
filename, Filter = PySide.QtGui.QFileDialog.getOpenFileName(None, "Read a Nastran95's F06 file", path, "*.F06") #PySide
data=filename.split("/")
n=len(data)
path=""
for i in range(n-1):
path=path+data[i]+"/"
inifileOut = FreeCAD.getHomePath()+ininame
iniFout = open(inifileOut,"w")
iniFout.writelines(path)
iniFout.close()
else:
path=iHfc.DatPath
filenameDat=iHfc.DatFile
#filename=filenameDat[:len(filenameDat)-3]+'dat'
filename=filenameDat
if os.path.exists(filename):
process=subprocess.Popen(["notepad",filename])
FreeCADGui.addCommand('hfcNastran95OpenF06',hfcNastran95OpenF06())