-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateSimiluation.lua
68 lines (61 loc) · 2.34 KB
/
CreateSimiluation.lua
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
require "CalculateAngle"
require 'lfs'
require "MakeForm"
paths = getFileProperty()
targetFile = paths["targetFile"]
savePath = paths["savePath"]
dataPath = paths["dataPath"]
fileName = paths["fileName"]
print(targetFile)
print(savePath)
print(dataPath)
app = cf.GetApplication()
project = app:NewProject()
-- project = app:OpenFile([[D:\FEKO\SoftWare\F35\f35.cfx]])
project = app:OpenFile(targetFile)
config_source = project.SolutionConfigurations[1].Sources[1]
-- inspect()
config_source.StartPhi = "phi1"
config_source.EndPhi = "phi2"
config_source.PhiIncrement = "dphi"
config_source.StartTheta = 90
config_source.EndTheta = 90
config_source.ThetaIncrement = 10
properties = config_source:GetProperties()
-- inspect(properties)
-- properties.StartPhi
string.split = function(s, p)
local rt= {}
string.gsub(s, '[^'..p..']+', function(w) table.insert(rt, w) end )
return rt
end
--local file = assert(io.open("D:/FEKO/SoftWare/ISARScripts/data2.txt", "r" ), "Could not create the file for writing. Ensure that you have write access.")
local file = assert(io.open(dataPath, "r" ), "Could not create the file for writing. Ensure that you have write access.")
local read_matrix = file:read('*a')
local mat_list = string.split(read_matrix, "\n")
-- for f=1,2 do
for f=1,#mat_list-1 do
anglenow = string.split(mat_list[f]," ")
anglenext = string.split(mat_list[f+1]," ")
U_V = calculateAngle(anglenow[2],anglenow[1],anglenext[2],anglenext[1])
properties.LocalWorkplane.UVector.X = U_V["U"]["x"]
properties.LocalWorkplane.UVector.Y = U_V["U"]["y"]
properties.LocalWorkplane.UVector.Z = U_V["U"]["z"]
properties.LocalWorkplane.VVector.X = U_V["V"]["x"]
properties.LocalWorkplane.VVector.Y = U_V["V"]["y"]
properties.LocalWorkplane.VVector.Z = U_V["V"]["z"]
config_source:SetProperties(properties)
app:Save()
-- Mesh the model
project.Mesher:Mesh()
-- Save project
-- lfs.mkdir(string.format("D:/FEKO/SoftWare/F35/Data2MakeFile/F35%d",f))
-- app:SaveAs(string.format("D:/FEKO/SoftWare/F35/Data2MakeFile/F35%d/F35_%d.cfx",f,f))
lfs.mkdir(savePath.."/"..fileName..string.format("_%d",f))
app:SaveAs(savePath.."/"..fileName..string.format("_%d",f).."/"..fileName..string.format("_%d.cfx",f))
-- app:Save()
-- RunFEKO
project.Launcher:RunFEKO()
app:Save()
-- project.Launcher:RunPOSTFEKO()
end