Skip to content

Instantly share code, notes, and snippets.

@Groostav
Created April 19, 2018 22:27
Show Gist options
  • Save Groostav/d5e83cd563bcd47b258f4d4ba67f0c52 to your computer and use it in GitHub Desktop.
Save Groostav/d5e83cd563bcd47b258f4d4ba67f0c52 to your computer and use it in GitHub Desktop.
thoughts on moldflow
'%RunPerInstance
'@
'@ taken without permission from: http://help.autodesk.com/view/MFIA/2016/ENU/?guid=GUID-202AB85B-5E58-47C9-9514-13BFF790A38D
'@
'@ DESCRIPTION
'@ Split Presssure Time Series Result into Individual Results.
'@ Recreate the Pressure Time Series Result
'@
'@ SYNTAX
'@ ReadingPressureData
'@
'@ PARAMETERS
'@ none
'@
'@ DEPENDENCIES/LIMITATIONS
'@ none
'@
'@ History
'@ Created DRA 9/8/2006
'@@
Option Explicit
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 PlotManager
Dim ResultID, Header, UserPlot, Indp, nodeID, Value, IndpValues, i, j ,Ave, Count, Str
ResultID = 1180
' Split Presssure Result into Individual Results.
Set PlotManager = Synergy.PlotManager()
Set IndpValues = Synergy.CreateDoubleArray()
PlotManager.GetIndpValues ResultID, IndpValues
' Display to Screen Average Pressure at interval through results
For i = 0 to IndpValues.size()-1 Step 5
Set PlotManager = Synergy.PlotManager()
Set Indp = Synergy.CreateDoubleArray()
Indp.AddDouble(IndpValues.val(i))
Set nodeID = Synergy.CreateIntegerArray()
Set Value = Synergy.CreateDoubleArray()
PlotManager.GetScalarData ResultID, Indp, nodeID, Value
Ave = 0.0
Count = 0.0
For j = 0 To nodeID.size - 1
Count = Count +1
Ave = Ave + Value.val(j)
Next
If Count > 0 Then
Ave = Ave / cdbl(count)
End If
Str = Str + "Time=" & CStr(IndpValues.val(i)) & " Average P =" & Ave &" MPa" & vbCRLF
Next
MsgBox Str
'Recreate current Time Series Pressure Result
Set UserPlot = PlotManager.CreateUserPlot()
Header = "New Pressure Time Series"
PlotManager.DeletePlotByName(Header)
UserPlot.SetName(Header)
UserPlot.SetDataType("NDDT")
UserPlot.SetDeptUnitName("MPa")
UserPlot.SetDeptName("Time")
UserPlot.SetVectorAsDisplacement(False)
For i = 0 to IndpValues.size-1
Set Indp = Synergy.CreateDoubleArray()
Indp.AddDouble(IndpValues.Val(i))
Set nodeID = Synergy.CreateIntegerArray()
Set Value = Synergy.CreateDoubleArray()
PlotManager.GetScalarData ResultID, Indp, nodeID, Value
UserPlot.AddScalarData IndpValues.Val(i), nodeID, Value
Next
UserPlot.Build()
MsgBox "Script Complete"
Wscript.Quit
API seems simple enough and reasonably well documented. Perhaps nicer even than solidworks API.
API root page: http://help.autodesk.com/view/MFIA/2016/ENU/?guid=GUID-13E6FA4F-F18F-4045-BCCC-6BD9ECD7F40E
their integration strategy is kind've interesting, it seems that they suggest shipping them *.vbs scripts (source code), and then ask you to invoke moldflow yourself from the command line with some special options.
http://help.autodesk.com/view/MFIA/2016/ENU/?guid=GUID-584419BD-155F-429C-85BE-6816D6B39D2F
Interesting, and hardly seemless, nor what we've done with any plugin before. Its nice because its fast and entirely dynamic. Is annoying because it will be difficult to test and will require us to find out what sockets/pipes look like in vbs scripts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment