Hello.
I'm trying to screen out "** WARNING 220131 ** Short shot detected." by using the "cmmessage".
I understand the MSCD formatting to some extent (through the API examples) to be able to extract information from the log.
I had trouble with this script:
'MSCD 220131 2 0 0 0 0 0 11
' ** WARNING 220131 ** Short shot detected.
Set MM = lMessages.GetMessage(220131,0)
lStr = CStr(MM.GetString(0))
MsgBox CStr(lStr)
Short shot warning in "Flow" log but did not screen out.
Please help
Thank in advance
'%RunPerInstance
'@
'@ DESCRIPTION
'@ This script shows how to extract information from the screen out (.out) file.
'@ Several examples are shown
'@
'@ This script perfoms a similar function to the studyrlt command
'@ studyrlt <study> -message <sequence> <message ID> <occurrence> <item>
'@ Some knowledge of the format used in the .out file is required.
'@ please see details in the ..../data/dat/cmmesage.dat for details
'@ Some know of the analysis sequences is required.
'@ please see details in the ..../data/dat/process.dat for details
'@
'@ SYNTAX
'@ RaadScreenOutput
'@
'@ PARAMETERS
'@ none
'@
'@ DEPENDENCIES/LIMITATIONS
'@ Assumes a Flow analysis has been run and the required study file is selected and open.
'@ Some knowledge of the MSCD format as defined in message.dat is required
'@ Limited error checking is performed
'@
'@@
Option Explicit
SetLocale("en-us")
Dim Synergy
Dim SynergyGetter
On Error Resume Next
Set SynergyGetter = GetObject(CreateObject("WScript.Shell").ExpandEnvironmentStrings("%SAInstance%"))
On Error GoTo 0
If (Not IsEmpty(SynergyGetter)) Then
Set Synergy = SynergyGetter.GetSASynergy
Else
Set Synergy = CreateObject("amiws.Synergy")
End If
Dim StudyDoc
Set StudyDoc = Synergy.StudyDoc()
' Get the name of the .out file associated with the flow results.
' Note: This assumes a Flow analysis sequence was run.
Dim lName
lName = StudyDoc.GetResultPrefix("Flow")
Dim lOutName
lOutName = lName & ".out"
' Create and Populate the ScreenOutput Class for the lOutName
Dim lMessages
Set lMessages = New ScreenOutput
lMessages.LoadOutputFile(lOutName)
Dim MM, lStr
'MSCD 220131 2 0 0 0 0 0 11
' ** WARNING 220131 ** Short shot detected.
Set MM = lMessages.GetMessage(220131,0)
lStr = CStr(MM.GetString(0))
MsgBox CStr(lStr)
' ---- Message class
Class Message
Private mMSCD ' MSCD Message ID
Private mNumString ' Number of Strings associated with the Message
Private mNumFloat ' Number of Floats Associated with the Message
Private mStrings() ' The Strings Associated with the Message
Private mFloats() ' The Numerical Values Associated with the Message
Public Sub SetMSCD(aMSCD)
mMSCD = aMSCD
End Sub
Public Sub SetNumString(aNumString)
mNumString = aNumString
End Sub
Public Sub SetNumFloat(aNumFloat)
mNumFloat = aNumFloat
End Sub
Public Sub AddFloat(aFloat)
mNumFloat = mNumFloat + 1
ReDim Preserve mFloats(mNumFloat)
mFloats(mNumFloat-1) = aFloat
End Sub
Public Sub AddString(aString)
mNumString = mNumString + 1
ReDim Preserve mStrings(mNumString)
mStrings(mNumString-1) = aString
End Sub
Public Function GetMSCD()
GetMSCD = mMSCD
End Function
Public Function GetString(aIndex)
GetString = ""
If aIndex >= 0 And aIndex < mNumString Then
GetString = mStrings(aIndex)
End if
End Function
Public Function GetFloat(aIndex)
GetFloat = ""
If aIndex >= 0 And aIndex < mNumFloat Then
GetFloat = mFloats(aIndex)
End if
End Function
Public Function GetNumString()
GetNumString = mNumString
End Function
Public Function GetNumFloat()
GetNumFloat = mNumFloat
End Function
Private Sub Class_Initialize
mMSCD = -1
mNumString = 0
mNumFloat = 0
End Sub
End Class
Class ScreenOutput
Private mMessages() ' Array of Messages associate with the screen output File
Private mNumMessages ' Number of messages in the screen output file
Public Function LoadOutputFile(aFile)
Const ForReading = 1
Dim FS
Set FS = CreateObject("Scripting.FileSystemObject")
Dim File
Set File = FS.OpenTextFile(aFile, ForReading)
While Not File.AtEndOfStream
Dim ID
ID = -1
' Read the MSCD
Dim Line,lenLine
Line = File.ReadLine
lenLine = len(Line)
If Not File.AtEndOfStream or lenLine >= 1 Then
ID = Line
Dim curMessage
Set curMessage = New Message
curMessage.SetMSCD(ID)
' Read the number of strings
Line = File.ReadLine
lenLine = len(Line)
If Not File.AtEndOfStream or lenLine >= 1 Then
Dim numString
numString = Line
' Read Strings
Dim i
For i = 1 To numString
Line = File.ReadLine
lenLine = len(Line)
If Not File.AtEndOfStream or lenLine >= 1 Then
CurMessage.AddString(Line)
End if
Next
End if
' Read the number of floats
Line = File.ReadLine
lenLine = len(Line)
If Not File.AtEndOfStream or lenLine >= 1 Then
Dim numFloat
numFloat = Line
' Read Floats
For i = 1 To numFloat
Line = File.ReadLine
lenLine = len(Line)
If Not File.AtEndOfStream or lenLine >= 1 Then
CurMessage.AddFloat(Line)
End if
Next
End If
' Add current message to the list
AddMessage(CurMessage)
End If
Wend
File.Close
End Function
Public Sub AddMessage(aMessage)
mNumMessages = mNumMessages + 1
ReDim Preserve mMessages(mNumMessages)
Set mMessages(mNumMessages-1) = aMessage
End Sub
Public Function GetNumMessages()
GetNumMessages = mNumMessages
End Function
Public Function GetMessage(aMSCD,aOccur)
Set GetMessage = Nothing
Dim j
Dim lFindInstance
lFindInstance = aOccur
If aOccur < 0 Then
lFindInstance = 0
End if
Dim Count
Count = 0
For j = 0 To mNumMessages-1
'MsgBox mMessages(j).GetMSCD &"|"& aMSCD
If CStr(mMessages(j).GetMSCD) = CStr(aMSCD) Then
Count = Count + 1
If Count >= lFindInstance Then
Set GetMessage = mMessages(j)
Exit Function
End if
End if
Next
End Function
Private Sub Class_Initialize
mNumMessages = 0
End Sub
End Class
Solved! Go to Solution.
Solved by RK1097. Go to Solution.
Solved by bernor_mf. Go to Solution.
Hi,
I tried to get it to run, but unfortunately I found no solution.
Not sure why and where it goes wrong.
Tried different combinations and also short from Midplane:
" ** WARNING 128271 ** Short shot detected. The flow front froze before
the part could be filled. "
Did you resolve it?
Might be a limitation.
Let's see if someone else in community has any idea or solution to this.
Regards,
Berndt
Disclaimer: I have a very rudimentary understanding of MSCD and Synergy API in general. Absolutely no programming skills, so take everything you see below with a big grain of salt.
After spending a bit of time, I was able to determine whether a short shot exists in a midplane mesh, haven't yet tried a DD or 3D. Each mesh type has a different MSCD for short shot and each short shot "cause" has a different MSCD.
These are the ones I believe to be strictly related to Mid-plane mesh:
Based on this info, you would need to run through each MSCD depending on mesh type and see what values it returns.
Here's a very crude code that I was able to come up with (Strictly for Mid-Plane results):
If lOutName = "" then
Msgbox "Unable to fetch .Out file"
Wscript.quit
Else
' Create and Populate the ScreenOutput Class for the lOutName
Dim lMessages
Set lMessages = New ScreenOutput
lMessages.LoadOutputFile(lOutName)
Dim MM, lFloat0, lFloat1
Set MM = lMessages.GetMessage(128270,0)
'MSCD 128271 for mid-plane, short shot due to machine injection pressure or packing pressure is insufficient.
lFloat0 = CStr(MM.GetFloat(0))
Set MM = lMessages.GetMessage(128271,0)
'MSCD 128271 for mid-plane, short shot due to part frozen before it could fill.
lFloat1 = CStr(MM.GetFloat(1))
'If either of the MSCD return the value 0 then declare short shot
If ((lFloat0 OR lFloat1) <> 0) then
Msgbox "Short Shot"
else
Msgbox "No Short shot"
End If
End If
Wscript.quit
'MSCD 128270 3 0 0 0 0 0 11
'
' ** WARNING 128270 ** Short shot detected. The machine injection pressure or packing
' pressure is insufficient.
'----
'MSCD 128271 3 0 0 0 0 0 11
'
' ** WARNING 128271 ** Short shot detected. The flow front froze before
' the part could be filled.
'----
'MSCD 128272 3 0 0 0 0 0 11
'
' ** WARNING 128272 ** Short shot detected. The clamp force of the
' injection molding machine is insufficient.
'----
'MSCD 128273 3 0 0 0 0 0 11
'
' ** WARNING 128273 ** Short shot detected. The stroke volume of the
' injection molding machine is insufficient.
If there is no "128270" or "128271" line in the .out file that simply meant no short shot (due to "The Flow front froze..."). If there was another reason for short shot, I'd have gotten false output showing "No Short shot" whilst short shot existing in actuality. That's where you'd need to scan for other MSCDs "128272/73" for it to work perfectly (can add them easily in existing code above, if needed).
I had issue with .out file not being detected and that caused false reading in screen output, that's why the code starts with ensuring whether the script is able to read it, if you want to remove the check, you're welcome to delete it.
Just FYI, I think the reason you're not getting any output from your code is that there are no "String" values in the ".out" file that are associated to "Short shot". Although, I could be completely wrong about this.
Here's what my .out file had:
"128271
0
1
0"
So, only numbers (i.e. float values).
I hope this helps you, should be very easy to inject DD and 3D MSCD to make it a universal check tool.
hi,
thank for your attention @bernor_mf @RK1097
I resolved this case by "unofficial way". 😆
I exported the analysis log file, read this file and find the keyword "220131", if it found => short shot detected.
Have a good day!
'%RunPerInstance
'@
'@ DESCRIPTION
'@ This script shows how to extract information from the screen out (.out) file.
'@ Several examples are shown
'@
'@ This script perfoms a similar function to the studyrlt command
'@ studyrlt <study> -message <sequence> <message ID> <occurrence> <item>
'@ Some knowledge of the format used in the .out file is required.
'@ please see details in the ..../data/dat/cmmesage.dat for details
'@ Some know of the analysis sequences is required.
'@ please see details in the ..../data/dat/process.dat for details
'@
'@ SYNTAX
'@ RaadScreenOutput
'@
'@ PARAMETERS
'@ none
'@
'@ DEPENDENCIES/LIMITATIONS
'@ Assumes a Flow analysis has been run and the required study file is selected and open.
'@ Some knowledge of the MSCD format as defined in message.dat is required
'@ Limited error checking is performed
'@
'@@
Option Explicit
SetLocale("en-us")
Dim Synergy
Dim SynergyGetter
On Error Resume Next
Set SynergyGetter = GetObject(CreateObject("WScript.Shell").ExpandEnvironmentStrings("%SAInstance%"))
On Error GoTo 0
If (Not IsEmpty(SynergyGetter)) Then
Set Synergy = SynergyGetter.GetSASynergy
Else
Set Synergy = CreateObject("amiws.Synergy")
End If
'Export Analysis Log
StudyDoc.ExportAnalysisLog "......._analysis.log"
Set file = fso.OpenTextFile("......._analysis.log", ForReading)
content = file.ReadAll
substrToFind = "220131"
If InStr(content, substrToFind) <= 0 Then
WScript.Echo "No short shot"
Else
WScript.Echo "Short shot detected."
End If
Hi,
happy to hear you resolved the issue. 😊
And thank you for sharing your creative solution with the community.
Very much appreciated.
Regards,
Berndt
Hi,
right, agree on your comment and thank you for spending time to look in to it in detail.
Much appricated, and helpful for the community.
As there is no string value associated to MSCD code in .out, it makes it more complex.
Short shot message has different messages ID, depending on mesh type, process, and reason for short shot.
I would be nice that the ..../data/dat/cmmesage.dat could be read and and MSCD and string associated.
Increases the complexity quite a bit.
Believe the workaround provided by @mantd is the way to go for now.
Thanks.
Regards,
Berndt
Can't find what you're looking for? Ask the community or share your knowledge.