<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need help with API to extract Mesh Information from Mesh Log in Moldflow Insight Forum</title>
    <link>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12779574#M558</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12821173"&gt;@mantd&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;BR /&gt;I found your workaround interesting.&lt;BR /&gt;Made some improvements, as the id of mesh.out varies.&lt;BR /&gt;It basically finds the "*mesh.out" connected to study, and also if not existing.&lt;BR /&gt;Paste it piece of code in here:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim StudyDoc
Set StudyDoc = Synergy.StudyDoc()

Dim fso, lOutName_mesh, StudyName
StudyName = left(StudyDoc.StudyName, len(StudyDoc.StudyName)-4)
Set fso = CreateObject("Scripting.FileSystemObject")

Dim strPattern , StudyNameMesh
strPattern = StudyName &amp;amp; "*mesh.out"
StudyNameMesh = GetFiles( strPattern )
'There should only be one file. Split and read the first.
StudyNameMesh = Split( Mid( StudyNameMesh, 2 ), ";" )
If Not (Ubound(StudyNameMesh)) = -1 Then
 
  lOutName_mesh = StudyNameMesh(0)
Else
  MsgBox "No mesh output file found.",,"Information"
  Wscript.Quit
End If
 
Function GetFiles( strFilespec )
 
	Dim colFiles, objFile, objFSO, objRE, wshShell
	Dim strFiles, strPattern
 
	' Return "Error" on missing or invalid filespec
	GetFiles = Array( "Error" )
	If Trim( strFilespec ) = ""  Then Exit Function
	If InStr( strFilespec, "\" ) Then Exit Function
 
	Set wshShell = CreateObject( "WScript.Shell" )
	Set objFSO   = CreateObject( "Scripting.FileSystemObject" )
	Set objRE    = New RegExp
 
	' Convert DOS wildcards to regex pattern
	objRE.Pattern    = "([\.\(\)\[\]\{\}\$])"
	objRE.Global     = True
	objRE.IgnoreCase = True
	strPattern       = objRE.Replace( strFilespec, "\$1" )
	strPattern       = Replace( strPattern,  "?", "[^\\]"  )
	strPattern       = Replace( strPattern,  "*", "[^\\]*" )
	objRE.Pattern    = "(^|\\)" &amp;amp; strPattern &amp;amp; "$"
 
	' Get a collection of files
	Set colFiles  = objFSO.GetFolder( wshShell.CurrentDirectory ).Files
	strFiles = ""
	' Iterate through the list of files
	For Each objFile In colFiles
		' Check if the file name matches filespec
		If objRE.Test( objFile.Path ) Then
			' Add the file to the list
			strFiles = strFiles &amp;amp; ";" &amp;amp; objFile.Name
		End If
	Next
 
	' Return the list of files as an array
	'GetFiles = Split( Mid( strFiles, 2 ), ";" )
	GetFiles = strFiles

	' Cleanup
	Set colFiles  = Nothing
	Set objRE     = Nothing
	Set objFSO    = Nothing
	Set wshShell  = Nothing
End Function&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Berndt&lt;/P&gt;</description>
    <pubDate>Fri, 17 May 2024 05:52:08 GMT</pubDate>
    <dc:creator>bernor_mf</dc:creator>
    <dc:date>2024-05-17T05:52:08Z</dc:date>
    <item>
      <title>Need help with API to extract Mesh Information from Mesh Log</title>
      <link>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12745349#M549</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello everyone,&lt;BR /&gt;I'm trying to output "Mesh type and global edge length" from an ".out" file using the "cmmessage".&amp;nbsp;&lt;BR /&gt;I understand the MSCD formatting to some extent (through the API examples&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://help.autodesk.com/view/MFIA/2023/ENU/?guid=MoldflowInsight_CLC_Automation_synergy_application_program_synergy_api_examples_API_example_Extract_information_html" target="_blank" rel="nofollow noopener noreferrer"&gt;here&lt;/A&gt;&lt;SPAN&gt;)&amp;nbsp;to be able to extract information from the log.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;Because mesh information from the Mesh Log file, I can not use StudyDoc.GetResultPrefix go with ("Flow"),("Cool") or&amp;nbsp;("Warp") . I tried&amp;nbsp;StudyDoc.GetResultPrefix("Mesh Log") but it did not work.&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help to understand how to work with Mesh Log would be appreciated.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;My script below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;'%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  &amp;lt;study&amp;gt; -message &amp;lt;sequence&amp;gt;  &amp;lt;message ID&amp;gt; &amp;lt;occurrence&amp;gt; &amp;lt;item&amp;gt;

'@ 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 &amp;amp; ".out"

' Create and Populate the ScreenOutput Class for the lOutName
Dim lMessages
Set lMessages = New ScreenOutput
lMessages.LoadOutputFile(lOutName)

Dim MM, lStr

'MSCD 1902014 1 0 0 0 0 1 1
'      Mesh type:     
Set MM = lMessages.GetMessage(1902014,0)
lStr = " Mesh type = " &amp;amp; CStr(MM.GetString(0)) 
MsgBox CStr(lStr)

'MSCD 1902003 1 0 0 0 0 0 1
'      Global edge length:                                   %11.4G
'    m,1,1
Set MM = lMessages.GetMessage(1902003,0)
lStr = "Global edge length = " &amp;amp; CStr(MM.GetFloat(0)*1000)
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 &amp;gt;= 0 And aIndex &amp;lt; mNumString Then
       GetString = mStrings(aIndex)
    End if
  End Function

  Public Function GetFloat(aIndex)
    GetFloat = ""
    If aIndex &amp;gt;= 0 And aIndex &amp;lt; 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;lt; 0 Then
      lFindInstance = 0
    End if
    Dim Count
    Count = 0
    For j = 0 To mNumMessages-1
      'MsgBox mMessages(j).GetMSCD &amp;amp;"|"&amp;amp; aMSCD
      If CStr(mMessages(j).GetMSCD) = CStr(aMSCD) Then
         Count = Count + 1
         If Count &amp;gt;= 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&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 22:57:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12745349#M549</guid>
      <dc:creator>mantd</dc:creator>
      <dc:date>2024-05-01T22:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with API to extract Mesh Information from Mesh Log</title>
      <link>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12759477#M550</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I believe this is a limitation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As stated in code:&lt;BR /&gt;'@ This script shows how to extract information from the screen out (.out) file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you extract data from .out.&lt;BR /&gt;This means data from tab Analysis Log.&lt;BR /&gt;Hence using "Flow" to ensure the .out and data is there.&lt;BR /&gt;Basically only information about mesh from log information "Model details :".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Further, the tab "Mesh Log" could be saved to .txt-file by right-click in area and do a "Save As..."&lt;BR /&gt;But, unfortunately there is no API code to do this automatically.&lt;BR /&gt;Otherwise that could have been a workaround.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get mesh type this piece of code does the job.&lt;BR /&gt;(Note: Mesh type "Dual Domain" is named and hard coded to "Fusion", hence a change of mesh type name.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;SetLocale("en-us")
Dim SynergyGetter, Synergy
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("synergy.Synergy")
End If
Synergy.SetUnits "Metric"

Dim StudyDoc
Set StudyDoc = Synergy.StudyDoc()
Dim CurrentMeshType
CurrentMeshType = StudyDoc.MeshType

If (CurrentMeshType = "Fusion" ) Then
  CurrentMeshType = "Dual Domain"
End If

Msgbox "Current Mesh Type : " &amp;amp; CurrentMeshType ,,"CurrentMeshType"&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;So I have no solution to your request due to limitations. Sorry.&lt;BR /&gt;Regards,&lt;BR /&gt;Berndt&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 04:45:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12759477#M550</guid>
      <dc:creator>bernor_mf</dc:creator>
      <dc:date>2024-05-08T04:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with API to extract Mesh Information from Mesh Log</title>
      <link>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12759516#M551</link>
      <description>&lt;P&gt;thank for your attention.&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3208057"&gt;@bernor_mf&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;actually I solved this case.&lt;/P&gt;&lt;P&gt;find and read the "mesh.out" in folder and it worked well&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim lOutName_mesh
If fso.FileExists(StudyName &amp;amp; "~7Mesh" &amp;amp; ".out") = True then
    lOutName_mesh = StudyName &amp;amp; "~7Mesh" &amp;amp; ".out"
ElseIf fso.FileExists(StudyName &amp;amp; "~9Mesh" &amp;amp; ".out") = True Then
    lOutName_mesh = StudyName &amp;amp; "~9Mesh" &amp;amp; ".out"
ElseIf fso.FileExists(StudyName &amp;amp; "~1Mesh" &amp;amp; ".out") = True Then
    lOutName_mesh = StudyName &amp;amp; "~1Mesh" &amp;amp; ".out"
ElseIf fso.FileExists(StudyName &amp;amp; "~3Mesh" &amp;amp; ".out") = True Then
    lOutName_mesh = StudyName &amp;amp; "~3Mesh" &amp;amp; ".out"
Else
    ' Default case (if none of the specific mesh folders exist)
    lOutName_mesh = StudyName &amp;amp; "~Mesh" &amp;amp; ".out"
End If

' Create and Populate the ScreenOutput Class for lOutName_mesh
Dim lMessages_mesh
Set lMessages_mesh = New ScreenOutput
lMessages_mesh.LoadOutputFile(lOutName_mesh)

'MSCD 1902003 1 0 0 0 0 0 1
'      Global edge length:                                   %11.4G
'    m,1,1
Set MM = lMessages_mesh.GetMessage(1902003,0)
lStr = "Global edge = " &amp;amp; CStr(MM.GetFloat(0)*1000)
MsgBox CStr(lStr)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 06:08:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12759516#M551</guid>
      <dc:creator>mantd</dc:creator>
      <dc:date>2024-05-08T06:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with API to extract Mesh Information from Mesh Log</title>
      <link>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12759675#M552</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12821173"&gt;@mantd&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;happy to hear you resolved the issue.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And thank you for sharing your creative solution with the community.&lt;/P&gt;&lt;P&gt;Very much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Berndt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 06:53:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12759675#M552</guid>
      <dc:creator>bernor_mf</dc:creator>
      <dc:date>2024-05-08T06:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with API to extract Mesh Information from Mesh Log</title>
      <link>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12779522#M553</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12821173"&gt;@mantd&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I found your workaround interesting.&lt;/P&gt;&lt;P&gt;Made an improvement, as id of mesh file varies, and sometimes does not exist.&lt;/P&gt;&lt;P&gt;Basically look for first connected "*.mesh.out", if existing.&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;'%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  &amp;lt;study&amp;gt; -message &amp;lt;sequence&amp;gt;  &amp;lt;message ID&amp;gt; &amp;lt;occurrence&amp;gt; &amp;lt;item&amp;gt;

'@ 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()

Dim fso, lOutName_mesh, StudyName
StudyName = left(StudyDoc.StudyName, len(StudyDoc.StudyName)-4)
Set fso = CreateObject("Scripting.FileSystemObject")

Dim strPattern , StudyNameMesh
strPattern = StudyName &amp;amp; "*mesh.out"
StudyNameMesh = GetFiles( strPattern )
'There should only be one file. Split and read the first.
StudyNameMesh = Split( Mid( StudyNameMesh, 2 ), ";" )
If Not (Ubound(StudyNameMesh)) = -1 Then
    lOutName_mesh = StudyNameMesh(0)
Else
  MsgBox "No mesh output file found.",,"Information"
  Wscript.Quit
End If
 
Function GetFiles( strFilespec )
 
	Dim colFiles, objFile, objFSO, objRE, wshShell
	Dim strFiles, strPattern
 
	' Return "Error" on missing or invalid filespec
	GetFiles = Array( "Error" )
	If Trim( strFilespec ) = ""  Then Exit Function
	If InStr( strFilespec, "\" ) Then Exit Function
 
	Set wshShell = CreateObject( "WScript.Shell" )
	Set objFSO   = CreateObject( "Scripting.FileSystemObject" )
	Set objRE    = New RegExp
 
	' Convert DOS wildcards to regex pattern
	objRE.Pattern    = "([\.\(\)\[\]\{\}\$])"
	objRE.Global     = True
	objRE.IgnoreCase = True
	strPattern       = objRE.Replace( strFilespec, "\$1" )
	strPattern       = Replace( strPattern,  "?", "[^\\]"  )
	strPattern       = Replace( strPattern,  "*", "[^\\]*" )
	objRE.Pattern    = "(^|\\)" &amp;amp; strPattern &amp;amp; "$"
 
	' Get a collection of files
	Set colFiles  = objFSO.GetFolder( wshShell.CurrentDirectory ).Files
	strFiles = ""
	' Iterate through the list of files
	For Each objFile In colFiles
		' Check if the file name matches filespec
		If objRE.Test( objFile.Path ) Then
			' Add the file to the list
			strFiles = strFiles &amp;amp; ";" &amp;amp; objFile.Name
		End If
	Next
 
	' Return the list of files as an array
	'GetFiles = Split( Mid( strFiles, 2 ), ";" )
	GetFiles = strFiles

	' Cleanup
	Set colFiles  = Nothing
	Set objRE     = Nothing
	Set objFSO    = Nothing
	Set wshShell  = Nothing
End Function


' Create and Populate the ScreenOutput Class for lOutName_mesh
Dim lMessages_mesh
Set lMessages_mesh = New ScreenOutput
lMessages_mesh.LoadOutputFile(lOutName_mesh)

Dim MM, lStr

'MSCD 1902003 1 0 0 0 0 0 1
'      Global edge length:                                   %11.4G
'    m,1,1
Set MM = lMessages_mesh.GetMessage(1902003,0)
lStr = "Global edge = " &amp;amp; CStr(MM.GetFloat(0)*1000)
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 &amp;gt;= 0 And aIndex &amp;lt; mNumString Then
       GetString = mStrings(aIndex)
    End if
  End Function

  Public Function GetFloat(aIndex)
    GetFloat = ""
    If aIndex &amp;gt;= 0 And aIndex &amp;lt; 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;lt; 0 Then
      lFindInstance = 0
    End if
    Dim Count
    Count = 0
    For j = 0 To mNumMessages-1
      'MsgBox mMessages(j).GetMSCD &amp;amp;"|"&amp;amp; aMSCD
      If CStr(mMessages(j).GetMSCD) = CStr(aMSCD) Then
         Count = Count + 1
         If Count &amp;gt;= 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&lt;/LI-CODE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Berndt&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 05:17:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12779522#M553</guid>
      <dc:creator>bernor_mf</dc:creator>
      <dc:date>2024-05-17T05:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with API to extract Mesh Information from Mesh Log</title>
      <link>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12779527#M554</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12821173"&gt;@mantd&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;BR /&gt;I found your workaround interesting.&lt;BR /&gt;Made some improvements, as the id of mesh.out varies.&lt;BR /&gt;It basically finds the "*mesh.out" connected to study, and also if not existing.&lt;BR /&gt;Paste it in here:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;'%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  &amp;lt;study&amp;gt; -message &amp;lt;sequence&amp;gt;  &amp;lt;message ID&amp;gt; &amp;lt;occurrence&amp;gt; &amp;lt;item&amp;gt;

'@ 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()

Dim fso, lOutName_mesh, StudyName
StudyName = left(StudyDoc.StudyName, len(StudyDoc.StudyName)-4)
Set fso = CreateObject("Scripting.FileSystemObject")

Dim strPattern , StudyNameMesh
strPattern = StudyName &amp;amp; "*mesh.out"
StudyNameMesh = GetFiles( strPattern )
'There should only be one file. Split and read the first.
StudyNameMesh = Split( Mid( StudyNameMesh, 2 ), ";" )
If Not (Ubound(StudyNameMesh)) = -1 Then
    lOutName_mesh = StudyNameMesh(0)
Else
  MsgBox "No mesh output file found.",,"Information"
  Wscript.Quit
End If
 
Function GetFiles( strFilespec )
 
	Dim colFiles, objFile, objFSO, objRE, wshShell
	Dim strFiles, strPattern
 
	' Return "Error" on missing or invalid filespec
	GetFiles = Array( "Error" )
	If Trim( strFilespec ) = ""  Then Exit Function
	If InStr( strFilespec, "\" ) Then Exit Function
 
	Set wshShell = CreateObject( "WScript.Shell" )
	Set objFSO   = CreateObject( "Scripting.FileSystemObject" )
	Set objRE    = New RegExp
 
	' Convert DOS wildcards to regex pattern
	objRE.Pattern    = "([\.\(\)\[\]\{\}\$])"
	objRE.Global     = True
	objRE.IgnoreCase = True
	strPattern       = objRE.Replace( strFilespec, "\$1" )
	strPattern       = Replace( strPattern,  "?", "[^\\]"  )
	strPattern       = Replace( strPattern,  "*", "[^\\]*" )
	objRE.Pattern    = "(^|\\)" &amp;amp; strPattern &amp;amp; "$"
 
	' Get a collection of files
	Set colFiles  = objFSO.GetFolder( wshShell.CurrentDirectory ).Files
	strFiles = ""
	' Iterate through the list of files
	For Each objFile In colFiles
		' Check if the file name matches filespec
		If objRE.Test( objFile.Path ) Then
			' Add the file to the list
			strFiles = strFiles &amp;amp; ";" &amp;amp; objFile.Name
		End If
	Next
 
	' Return the list of files as an array
	'GetFiles = Split( Mid( strFiles, 2 ), ";" )
	GetFiles = strFiles

	' Cleanup
	Set colFiles  = Nothing
	Set objRE     = Nothing
	Set objFSO    = Nothing
	Set wshShell  = Nothing
End Function


' Create and Populate the ScreenOutput Class for lOutName_mesh
Dim lMessages_mesh
Set lMessages_mesh = New ScreenOutput
lMessages_mesh.LoadOutputFile(lOutName_mesh)

Dim MM, lStr

'MSCD 1902003 1 0 0 0 0 0 1
'      Global edge length:                                   %11.4G
'    m,1,1
Set MM = lMessages_mesh.GetMessage(1902003,0)
lStr = "Global edge = " &amp;amp; CStr(MM.GetFloat(0)*1000)
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 &amp;gt;= 0 And aIndex &amp;lt; mNumString Then
       GetString = mStrings(aIndex)
    End if
  End Function

  Public Function GetFloat(aIndex)
    GetFloat = ""
    If aIndex &amp;gt;= 0 And aIndex &amp;lt; 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;lt; 0 Then
      lFindInstance = 0
    End if
    Dim Count
    Count = 0
    For j = 0 To mNumMessages-1
      'MsgBox mMessages(j).GetMSCD &amp;amp;"|"&amp;amp; aMSCD
      If CStr(mMessages(j).GetMSCD) = CStr(aMSCD) Then
         Count = Count + 1
         If Count &amp;gt;= 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&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Berndt&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 05:21:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12779527#M554</guid>
      <dc:creator>bernor_mf</dc:creator>
      <dc:date>2024-05-17T05:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with API to extract Mesh Information from Mesh Log</title>
      <link>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12779531#M555</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12821173"&gt;@mantd&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;BR /&gt;I found your workaround interesting.&lt;BR /&gt;Made some improvements, as the id of mesh.out varies.&lt;BR /&gt;It basically finds the "*mesh.out" connected to study, and also if not existing.&lt;BR /&gt;Paste it in here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;'%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  &amp;lt;study&amp;gt; -message &amp;lt;sequence&amp;gt;  &amp;lt;message ID&amp;gt; &amp;lt;occurrence&amp;gt; &amp;lt;item&amp;gt;

'@ 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()

Dim fso, lOutName_mesh, StudyName
StudyName = left(StudyDoc.StudyName, len(StudyDoc.StudyName)-4)
Set fso = CreateObject("Scripting.FileSystemObject")

Dim strPattern , StudyNameMesh
strPattern = StudyName &amp;amp; "*mesh.out"
StudyNameMesh = GetFiles( strPattern )
'There should only be one file. Split and read the first.
StudyNameMesh = Split( Mid( StudyNameMesh, 2 ), ";" )
If Not (Ubound(StudyNameMesh)) = -1 Then
    lOutName_mesh = StudyNameMesh(0)
Else
  MsgBox "No mesh output file found.",,"Information"
  Wscript.Quit
End If
 
Function GetFiles( strFilespec )
 
	Dim colFiles, objFile, objFSO, objRE, wshShell
	Dim strFiles, strPattern
 
	' Return "Error" on missing or invalid filespec
	GetFiles = Array( "Error" )
	If Trim( strFilespec ) = ""  Then Exit Function
	If InStr( strFilespec, "\" ) Then Exit Function
 
	Set wshShell = CreateObject( "WScript.Shell" )
	Set objFSO   = CreateObject( "Scripting.FileSystemObject" )
	Set objRE    = New RegExp
 
	' Convert DOS wildcards to regex pattern
	objRE.Pattern    = "([\.\(\)\[\]\{\}\$])"
	objRE.Global     = True
	objRE.IgnoreCase = True
	strPattern       = objRE.Replace( strFilespec, "\$1" )
	strPattern       = Replace( strPattern,  "?", "[^\\]"  )
	strPattern       = Replace( strPattern,  "*", "[^\\]*" )
	objRE.Pattern    = "(^|\\)" &amp;amp; strPattern &amp;amp; "$"
 
	' Get a collection of files
	Set colFiles  = objFSO.GetFolder( wshShell.CurrentDirectory ).Files
	strFiles = ""
	' Iterate through the list of files
	For Each objFile In colFiles
		' Check if the file name matches filespec
		If objRE.Test( objFile.Path ) Then
			' Add the file to the list
			strFiles = strFiles &amp;amp; ";" &amp;amp; objFile.Name
		End If
	Next
 
	' Return the list of files as an array
	'GetFiles = Split( Mid( strFiles, 2 ), ";" )
	GetFiles = strFiles

	' Cleanup
	Set colFiles  = Nothing
	Set objRE     = Nothing
	Set objFSO    = Nothing
	Set wshShell  = Nothing
End Function


' Create and Populate the ScreenOutput Class for lOutName_mesh
Dim lMessages_mesh
Set lMessages_mesh = New ScreenOutput
lMessages_mesh.LoadOutputFile(lOutName_mesh)

Dim MM, lStr

'MSCD 1902003 1 0 0 0 0 0 1
'      Global edge length:                                   %11.4G
'    m,1,1
Set MM = lMessages_mesh.GetMessage(1902003,0)
lStr = "Global edge = " &amp;amp; CStr(MM.GetFloat(0)*1000)
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 &amp;gt;= 0 And aIndex &amp;lt; mNumString Then
       GetString = mStrings(aIndex)
    End if
  End Function

  Public Function GetFloat(aIndex)
    GetFloat = ""
    If aIndex &amp;gt;= 0 And aIndex &amp;lt; 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;lt; 0 Then
      lFindInstance = 0
    End if
    Dim Count
    Count = 0
    For j = 0 To mNumMessages-1
      'MsgBox mMessages(j).GetMSCD &amp;amp;"|"&amp;amp; aMSCD
      If CStr(mMessages(j).GetMSCD) = CStr(aMSCD) Then
         Count = Count + 1
         If Count &amp;gt;= 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&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Berndt&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 05:23:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12779531#M555</guid>
      <dc:creator>bernor_mf</dc:creator>
      <dc:date>2024-05-17T05:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with API to extract Mesh Information from Mesh Log</title>
      <link>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12779533#M556</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I found your workaround interesting.&lt;BR /&gt;Made some improvements, as the id of mesh.out varies.&lt;BR /&gt;It basically finds the "*mesh.out" connected to study, and also if not existing.&lt;BR /&gt;Paste it in here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;'%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  &amp;lt;study&amp;gt; -message &amp;lt;sequence&amp;gt;  &amp;lt;message ID&amp;gt; &amp;lt;occurrence&amp;gt; &amp;lt;item&amp;gt;

'@ 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()

Dim fso, lOutName_mesh, StudyName
StudyName = left(StudyDoc.StudyName, len(StudyDoc.StudyName)-4)
Set fso = CreateObject("Scripting.FileSystemObject")

Dim strPattern , StudyNameMesh
strPattern = StudyName &amp;amp; "*mesh.out"
StudyNameMesh = GetFiles( strPattern )
'There should only be one file. Split and read the first.
StudyNameMesh = Split( Mid( StudyNameMesh, 2 ), ";" )
If Not (Ubound(StudyNameMesh)) = -1 Then
    lOutName_mesh = StudyNameMesh(0)
Else
  MsgBox "No mesh output file found.",,"Information"
  Wscript.Quit
End If
 
Function GetFiles( strFilespec )
 
	Dim colFiles, objFile, objFSO, objRE, wshShell
	Dim strFiles, strPattern
 
	' Return "Error" on missing or invalid filespec
	GetFiles = Array( "Error" )
	If Trim( strFilespec ) = ""  Then Exit Function
	If InStr( strFilespec, "\" ) Then Exit Function
 
	Set wshShell = CreateObject( "WScript.Shell" )
	Set objFSO   = CreateObject( "Scripting.FileSystemObject" )
	Set objRE    = New RegExp
 
	' Convert DOS wildcards to regex pattern
	objRE.Pattern    = "([\.\(\)\[\]\{\}\$])"
	objRE.Global     = True
	objRE.IgnoreCase = True
	strPattern       = objRE.Replace( strFilespec, "\$1" )
	strPattern       = Replace( strPattern,  "?", "[^\\]"  )
	strPattern       = Replace( strPattern,  "*", "[^\\]*" )
	objRE.Pattern    = "(^|\\)" &amp;amp; strPattern &amp;amp; "$"
 
	' Get a collection of files
	Set colFiles  = objFSO.GetFolder( wshShell.CurrentDirectory ).Files
	strFiles = ""
	' Iterate through the list of files
	For Each objFile In colFiles
		' Check if the file name matches filespec
		If objRE.Test( objFile.Path ) Then
			' Add the file to the list
			strFiles = strFiles &amp;amp; ";" &amp;amp; objFile.Name
		End If
	Next
 
	' Return the list of files as an array
	'GetFiles = Split( Mid( strFiles, 2 ), ";" )
	GetFiles = strFiles

	' Cleanup
	Set colFiles  = Nothing
	Set objRE     = Nothing
	Set objFSO    = Nothing
	Set wshShell  = Nothing
End Function


' Create and Populate the ScreenOutput Class for lOutName_mesh
Dim lMessages_mesh
Set lMessages_mesh = New ScreenOutput
lMessages_mesh.LoadOutputFile(lOutName_mesh)

Dim MM, lStr

'MSCD 1902003 1 0 0 0 0 0 1
'      Global edge length:                                   %11.4G
'    m,1,1
Set MM = lMessages_mesh.GetMessage(1902003,0)
lStr = "Global edge = " &amp;amp; CStr(MM.GetFloat(0)*1000)
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 &amp;gt;= 0 And aIndex &amp;lt; mNumString Then
       GetString = mStrings(aIndex)
    End if
  End Function

  Public Function GetFloat(aIndex)
    GetFloat = ""
    If aIndex &amp;gt;= 0 And aIndex &amp;lt; 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;lt; 0 Then
      lFindInstance = 0
    End if
    Dim Count
    Count = 0
    For j = 0 To mNumMessages-1
      'MsgBox mMessages(j).GetMSCD &amp;amp;"|"&amp;amp; aMSCD
      If CStr(mMessages(j).GetMSCD) = CStr(aMSCD) Then
         Count = Count + 1
         If Count &amp;gt;= 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&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Berndt&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 05:26:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12779533#M556</guid>
      <dc:creator>bernor_mf</dc:creator>
      <dc:date>2024-05-17T05:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with API to extract Mesh Information from Mesh Log</title>
      <link>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12779537#M557</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12821173"&gt;@mantd&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;BR /&gt;I found your workaround interesting.&lt;BR /&gt;Made some improvements, as the id of mesh.out varies.&lt;BR /&gt;It basically finds the "*mesh.out" connected to study, and also if not existing.&lt;BR /&gt;Paste it in here:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;'%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  &amp;lt;study&amp;gt; -message &amp;lt;sequence&amp;gt;  &amp;lt;message ID&amp;gt; &amp;lt;occurrence&amp;gt; &amp;lt;item&amp;gt;

'@ 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()

Dim fso, lOutName_mesh, StudyName
StudyName = left(StudyDoc.StudyName, len(StudyDoc.StudyName)-4)
Set fso = CreateObject("Scripting.FileSystemObject")

Dim strPattern , StudyNameMesh
strPattern = StudyName &amp;amp; "*mesh.out"
StudyNameMesh = GetFiles( strPattern )
'There should only be one file. Split and read the first.
StudyNameMesh = Split( Mid( StudyNameMesh, 2 ), ";" )
If Not (Ubound(StudyNameMesh)) = -1 Then
    lOutName_mesh = StudyNameMesh(0)
Else
  MsgBox "No mesh output file found.",,"Information"
  Wscript.Quit
End If
 
Function GetFiles( strFilespec )
 
	Dim colFiles, objFile, objFSO, objRE, wshShell
	Dim strFiles, strPattern
 
	' Return "Error" on missing or invalid filespec
	GetFiles = Array( "Error" )
	If Trim( strFilespec ) = ""  Then Exit Function
	If InStr( strFilespec, "\" ) Then Exit Function
 
	Set wshShell = CreateObject( "WScript.Shell" )
	Set objFSO   = CreateObject( "Scripting.FileSystemObject" )
	Set objRE    = New RegExp
 
	' Convert DOS wildcards to regex pattern
	objRE.Pattern    = "([\.\(\)\[\]\{\}\$])"
	objRE.Global     = True
	objRE.IgnoreCase = True
	strPattern       = objRE.Replace( strFilespec, "\$1" )
	strPattern       = Replace( strPattern,  "?", "[^\\]"  )
	strPattern       = Replace( strPattern,  "*", "[^\\]*" )
	objRE.Pattern    = "(^|\\)" &amp;amp; strPattern &amp;amp; "$"
 
	' Get a collection of files
	Set colFiles  = objFSO.GetFolder( wshShell.CurrentDirectory ).Files
	strFiles = ""
	' Iterate through the list of files
	For Each objFile In colFiles
		' Check if the file name matches filespec
		If objRE.Test( objFile.Path ) Then
			' Add the file to the list
			strFiles = strFiles &amp;amp; ";" &amp;amp; objFile.Name
		End If
	Next
 
	' Return the list of files as an array
	'GetFiles = Split( Mid( strFiles, 2 ), ";" )
	GetFiles = strFiles

	' Cleanup
	Set colFiles  = Nothing
	Set objRE     = Nothing
	Set objFSO    = Nothing
	Set wshShell  = Nothing
End Function


' Create and Populate the ScreenOutput Class for lOutName_mesh
Dim lMessages_mesh
Set lMessages_mesh = New ScreenOutput
lMessages_mesh.LoadOutputFile(lOutName_mesh)

Dim MM, lStr

'MSCD 1902003 1 0 0 0 0 0 1
'      Global edge length:                                   %11.4G
'    m,1,1
Set MM = lMessages_mesh.GetMessage(1902003,0)
lStr = "Global edge = " &amp;amp; CStr(MM.GetFloat(0)*1000)
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 &amp;gt;= 0 And aIndex &amp;lt; mNumString Then
       GetString = mStrings(aIndex)
    End if
  End Function

  Public Function GetFloat(aIndex)
    GetFloat = ""
    If aIndex &amp;gt;= 0 And aIndex &amp;lt; 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;gt;= 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 &amp;lt; 0 Then
      lFindInstance = 0
    End if
    Dim Count
    Count = 0
    For j = 0 To mNumMessages-1
      'MsgBox mMessages(j).GetMSCD &amp;amp;"|"&amp;amp; aMSCD
      If CStr(mMessages(j).GetMSCD) = CStr(aMSCD) Then
         Count = Count + 1
         If Count &amp;gt;= 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&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Berndt&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 05:28:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12779537#M557</guid>
      <dc:creator>bernor_mf</dc:creator>
      <dc:date>2024-05-17T05:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with API to extract Mesh Information from Mesh Log</title>
      <link>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12779574#M558</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12821173"&gt;@mantd&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;BR /&gt;I found your workaround interesting.&lt;BR /&gt;Made some improvements, as the id of mesh.out varies.&lt;BR /&gt;It basically finds the "*mesh.out" connected to study, and also if not existing.&lt;BR /&gt;Paste it piece of code in here:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim StudyDoc
Set StudyDoc = Synergy.StudyDoc()

Dim fso, lOutName_mesh, StudyName
StudyName = left(StudyDoc.StudyName, len(StudyDoc.StudyName)-4)
Set fso = CreateObject("Scripting.FileSystemObject")

Dim strPattern , StudyNameMesh
strPattern = StudyName &amp;amp; "*mesh.out"
StudyNameMesh = GetFiles( strPattern )
'There should only be one file. Split and read the first.
StudyNameMesh = Split( Mid( StudyNameMesh, 2 ), ";" )
If Not (Ubound(StudyNameMesh)) = -1 Then
 
  lOutName_mesh = StudyNameMesh(0)
Else
  MsgBox "No mesh output file found.",,"Information"
  Wscript.Quit
End If
 
Function GetFiles( strFilespec )
 
	Dim colFiles, objFile, objFSO, objRE, wshShell
	Dim strFiles, strPattern
 
	' Return "Error" on missing or invalid filespec
	GetFiles = Array( "Error" )
	If Trim( strFilespec ) = ""  Then Exit Function
	If InStr( strFilespec, "\" ) Then Exit Function
 
	Set wshShell = CreateObject( "WScript.Shell" )
	Set objFSO   = CreateObject( "Scripting.FileSystemObject" )
	Set objRE    = New RegExp
 
	' Convert DOS wildcards to regex pattern
	objRE.Pattern    = "([\.\(\)\[\]\{\}\$])"
	objRE.Global     = True
	objRE.IgnoreCase = True
	strPattern       = objRE.Replace( strFilespec, "\$1" )
	strPattern       = Replace( strPattern,  "?", "[^\\]"  )
	strPattern       = Replace( strPattern,  "*", "[^\\]*" )
	objRE.Pattern    = "(^|\\)" &amp;amp; strPattern &amp;amp; "$"
 
	' Get a collection of files
	Set colFiles  = objFSO.GetFolder( wshShell.CurrentDirectory ).Files
	strFiles = ""
	' Iterate through the list of files
	For Each objFile In colFiles
		' Check if the file name matches filespec
		If objRE.Test( objFile.Path ) Then
			' Add the file to the list
			strFiles = strFiles &amp;amp; ";" &amp;amp; objFile.Name
		End If
	Next
 
	' Return the list of files as an array
	'GetFiles = Split( Mid( strFiles, 2 ), ";" )
	GetFiles = strFiles

	' Cleanup
	Set colFiles  = Nothing
	Set objRE     = Nothing
	Set objFSO    = Nothing
	Set wshShell  = Nothing
End Function&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Berndt&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 05:52:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/moldflow-insight-forum/need-help-with-api-to-extract-mesh-information-from-mesh-log/m-p/12779574#M558</guid>
      <dc:creator>bernor_mf</dc:creator>
      <dc:date>2024-05-17T05:52:08Z</dc:date>
    </item>
  </channel>
</rss>

