📄 cae试验.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 1800
TabIndex = 0
Top = 1320
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim c_XImag(0, 0) As Double
Dim sink() As Double
Dim para_XReal(0, 0) As Double
Dim para_XImag(0, 0) As Double
Dim c_XReal(0, 0) As Double
Dim column_XReal(0, 0) As Double
Dim column_XImag(0, 0) As Double
Dim row_XReal(0, 0) As Double
Dim row_XImag(0, 0) As Double
On Error Resume Next
Set Synergy = GetObject("synergy.Synergy")
If Err Then
Err.Clear
Set Synergy = CreateObject("synergy.Synergy")
End If
Set Matlab = CreateObject("Matlab.Application")
Matlab.Execute ("cd('D:\vb work')")
Synergy.SetUnits "METRIC"
Synergy.OpenProject "D:\My MPI 6.1 Projects\new\new.mpi"
Set Project = Synergy.Project()
Project.OpenItemByName "battery_cover_Study", "Study"
Set StudyDoc = Synergy.StudyDoc()
StudyDoc.DeleteResults (0)
'------------------------------------------- MF Analysis according DOE
Matlab.Execute ("load 400doe.mat ")
result = Matlab.Execute("y=C;")
result = Matlab.Execute("[row,column]=size(y);")
result = Matlab.GetFullMatrix("row", "base", row_XReal, row_XImag)
result = Matlab.GetFullMatrix("column", "base", column_XReal, column_XImag)
For c_XReal(0, 0) = 1 To column_XReal(0, 0)
c_XImag(0, 0) = 0
result = Matlab.PutFullMatrix("c", "base", c_XReal, c_XImag)
result = Matlab.Execute("para=y(1,c)")
result = Matlab.GetFullMatrix("para", "base", para_XReal, para_XImag)
mdtemp = para_XReal(0, 0)
result = Matlab.Execute("para=y(2,c)")
result = Matlab.GetFullMatrix("para", "base", para_XReal, para_XImag)
mltemp = para_XReal(0, 0)
result = Matlab.Execute("para=y(3,c)")
result = Matlab.GetFullMatrix("para", "base", para_XReal, para_XImag)
injtime = para_XReal(0, 0)
result = Matlab.Execute("para=y(4,c)")
result = Matlab.GetFullMatrix("para", "base", para_XReal, para_XImag)
Ppressure = para_XReal(0, 0)
result = Matlab.Execute("para=y(5,c)")
result = Matlab.GetFullMatrix("para", "base", para_XReal, para_XImag)
Ptime = para_XReal(0, 0)
'--------------------MF Analysis
StudyDoc.AnalysisSequence "Flow|Warp"
Set PropEd = Synergy.PropertyEditor()
Set Prop = PropEd.FindProperty(30011, 1)
Set DVec = Synergy.CreateDoubleArray()
DVec.AddDouble injtime * 0.285 + 0.765
Prop.FieldValues 10100, DVec
Set DVec = Synergy.CreateDoubleArray()
DVec.AddDouble 0
DVec.AddDouble Ppressure * 28.5 + 71.5
DVec.AddDouble Ptime * 2.85 + 10.15
DVec.AddDouble Ppressure * 28.5 + 71.5
Prop.FieldValues 10702, DVec
Set DVec = Synergy.CreateDoubleArray()
DVec.AddDouble mltemp * 28.5 + 271.5
Prop.FieldValues 11002, DVec
Set DVec = Synergy.CreateDoubleArray()
DVec.AddDouble mdtemp * 28.5 + 71.5
Prop.FieldValues 11108, DVec
PropEd.CommitChanges "Process Conditions"
Set StudyDoc = Synergy.StudyDoc()
StudyDoc.AnalyzeNow True, True
' ------------------Wait for Results
WAIT1:
If StudyDoc.AnalysisStatus(1) = "Completed" Then
For att = 1 To 50
hwndWin = FindWindow(vbNullString, "Moldflow Plastics Insight")
hwndBtn = FindWindowEx(hwndWin, 0, "Button", "确定")
hwndTt = SendMessage(hwndBtn, BM_CLICK, 0, 0)
Next att
GoTo OVER1
Else
For i = 0 To 1000
DoEvents
Next i
GoTo WAIT1
End If
OVER1:
'For a = 0 To 45
Set Viewer = Synergy.Viewer()
Set PlotMgr = Synergy.PlotManager()
Set plot = Viewer.GetPlot(30) '查找z方向翘曲量
Viewer.ShowPlot plot
plot.SaveResultInXML "d:\vb work\400DOE" & "\" & c_XReal(0, 0) & ".xml"
'Next a
'------------------ Delete Study
Set StudyDoc = Synergy.StudyDoc()
StudyDoc.DeleteResults (0)
Next c_XReal(0, 0)
'------------------
'-------------Get Object(Result)
ReDim sink(1 To column_XReal(0, 0)) As Double
Set xml_document = New DOMDocument
For j = 1 To column_XReal(0, 0)
xml_document.Load ("D:\vb work\400DOE" & "\" & j & ".xml")
intLnth = xml_document.getElementsByTagName("DeptValues").length
Set node_list = xml_document.getElementsByTagName("DeptValues")
Min = 100
Max = 0
For i = 0 To intLnth - 1
Set x = xml_document.getElementsByTagName("DeptValues")(i).childNodes(0)
If CDbl(x.substringData(32, 12)) < Min Then
Min = CDbl(x.substringData(32, 12))
End If
If CDbl(x.substringData(32, 12)) > Max Then
Max = CDbl(x.substringData(32, 12))
End If
Next i
If Min > 0 Then
sink(j) = Max * 10 ^ 3
Else
sink(j) = (Max - Min) * 10 ^ 3
End If
Next j
result = Matlab.MaximizeCommandWindow
result = Matlab.Execute("temp=[];")
For j = 1 To column_XReal(0, 0)
para_XReal(0, 0) = sink(j)
para_XImag(0, 0) = 0
result = Matlab.PutFullMatrix("af", "base", para_XReal, para_XImag)
result = Matlab.Execute("temp=[temp af];")
Next j
result = Matlab.Execute("Y=temp';")
result = Matlab.Execute("save 'D:\vb work\400doe.mat' Y -append;")
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -