Moldflow Insight Forum
Welcome to Autodesk’s Moldflow Insight Forums. Share your knowledge, ask questions, and explore popular Moldflow Insight topics.
abbrechen
Suchergebnisse werden angezeigt für 
Anzeigen  nur  | Stattdessen suchen nach 
Meintest du: 

I've set up a lot of projects in my project, and if there are 100 of them, I want to write a script to make Moldflow Synergy do the analysis automatically, how do I do that?

3 ANTWORTEN 3
GELÖST
Antworten
Nachricht 1 von 4
1292909313
84 Aufrufe, 3 Antworten

I've set up a lot of projects in my project, and if there are 100 of them, I want to write a script to make Moldflow Synergy do the analysis automatically, how do I do that?

I've set up a lot of projects in my project, and if there are 100 of them, I want to write a script to make Moldflow Synergy do the analysis automatically, how do I do that?

3 ANTWORTEN 3
Nachricht 2 von 4
mason.myers
als Antwort auf: 1292909313

Hello @1292909313 ,

 

Here is the code for a script that should run all the studies in your project.  If you have anything already solved in your project, it might re-solve those studies.

 

Mason

 

'@
'@ DESCRIPTION
'@ This command will run all Models in the current directory
'@ It will Delete all old results first then re-run all analyses
'@
'@ SYNTAX
'@ ReRunAllResults
'@
'@ PARAMETERS
'@ none
'@
'@ DEPENDENCIES/LIMITATIONS
'@@
Option Explicit

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

Dim StudyDoc,Project
Set StudyDoc = Synergy.StudyDoc()
Set Project = Synergy.Project
If Not Project Is nothing Then
Dim lStudy, Modified
lStudy = Project.GetFirstStudyName()
While lStudy <> ""
' Open the Study
Project.OpenItemByName lStudy, "Study"

' Delete All Results if they exist
Dim PlotMgr, Plot
Set PlotMgr = Synergy.PlotManager()
Set Plot = PlotMgr.GetFirstPlot
Modified = false
If Not Plot Is Nothing Then
Set StudyDoc = Synergy.StudyDoc
StudyDoc.DeleteResults(0)
Modified = true
End If
lStudy = Project.GetNextStudyName(lStudy)
Set StudyDoc = Synergy.StudyDoc()
If Modified Then
StudyDoc.Save
End if
StudyDoc.Close
Wend
Else
MsgBox "Please Open a Project",vbCritical,WScript.ScriptName
WScript.Quit(1)
End if

' Re run all the analyses one at a time
lStudy = Project.GetFirstStudyName()
While lStudy <> ""
Project.OpenItemByName lStudy, "Study"

Set StudyDoc = Synergy.StudyDoc
Dim NumberOfAnalysesInSequence
NumberOfAnalysesInSequence = StudyDoc.NumberOfAnalyses
' Run the Analysis
StudyDoc.AnalyzeNow2 False, True, False

' Check That the last analysis in the sequence has completed
Dim Running, Count, Status, Failed
Running = 1
Count = 0
While (Running)
' Wait 5 seconds
Wscript.Sleep(5000)
' Check Analysis status of last run in the Analysis sequence
Status = StudyDoc.AnalysisStatus(NumberOfAnalysesInSequence-1)
If Status = "Completed" Then
Running = 0
End If
If Status = "Failed" Then
Running = 0
End If
Wend
lStudy = Project.GetNextStudyName(lStudy)
StudyDoc.Save
StudyDoc.Close
Wend

MsgBox "Script Complete",,WScript.ScriptName
WScript.Quit(0)

Nachricht 3 von 4
1292909313
als Antwort auf: mason.myers

Thank you very much for your answer, if I want to use this script to automatically analyze a specific project, e.g. cap_1, how should the script be modified?
Nachricht 4 von 4
mason.myers
als Antwort auf: 1292909313

I opened the project and called the .vbs script from the Command Line within Moldflow Synergy.  You might be able to run this script from the Command Shell but I have not tried that approach.

 

Mason

Sie finden nicht, was Sie suchen? Fragen Sie die Community oder teilen Sie Ihr Wissen mit anderen.

In Foren veröffentlichen  

Autodesk Design & Make Report