Is it possible to use Moldlfow API to extract specific settings from a study before the study is solved/run?
I need to get things like Melt Temperate, Filling Control, etc. and output them to a txt file.
Hello @JacobFilek3443 ,
You should be able to extract that data from the log files after solving. Here is an example API from our help files on completing something similar:
Mason
Sorry for missing that detail @JacobFilek3443 . I have only used the API to pull the information post solving. It might be possible to do this before solving however I do not know that workflow.
Mason
Hi,
it is possible to extract the data and setting from Process controller.
You first need to set the Process controller.
Then you need to use the tcode ID to extract information.
tcode and tcodeset Reference
> At top of Synergy UI, click the small arrow down and select "tcode and tcodeset Reference"
This will provide a list of tcodes and tcodeset references in browser.
A tcode corresponds to a single feature in the process settings, geometry, or solver parameters.
A tcodeset comprises the tcodes which together control one aspect of a solver.
When programming with the Moldflow API, it is necessary for you to know the numeric ID that corresponds to a particular solver or modeling feature.
Tip: Usually you could use Ctrl+F in browser to search the html-file.
You could also record a macro.
In your case, start the recording, change process settings like mold and melt temperatures, then stop the recording.
Then open the recorded file and review tcodes.
Example of macro recording where Mold surface temperature and Melt temperature is changed.
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"
Set PropEd = Synergy.PropertyEditor()
Set Prop = PropEd.FindProperty(30011, 1)
Set DVec = Synergy.CreateDoubleArray()
DVec.AddDouble 230
Prop.FieldValues 11002, DVec
Set DVec = Synergy.CreateDoubleArray()
DVec.AddDouble 55
Prop.FieldValues 11108, DVec
PropEd.CommitChanges "Process Conditions"
Example of Moldflow API that extracts the Mold surface temperature.
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"
' tcodeset reference
' tcode 30011 Process controller
Set PropED = Synergy.PropertyEditor()
Set PropProcess = PropED.FindProperty(30011, 1)
'tcode reference
' 11108 Mold surface temperature
' Mold surface temperature from Process settings
TcodeID = 11108
Set DVec = PropProcess.FieldValues(TcodeID)
If DVec.Val(0) > 0 Then
MoldTemperature = DVec.Val(0)
Else
MoldTemperature = " - "
End If
MsgBox "Mold Temperature = " & MoldTemperature ,,"Process settings"
A bit of research and coding needed to accomplish what you wish and need.
Hope this helps.
Happy coding! 😊
Regards,
Berndt
@bernor_mf
hi,
Base on your script I want to screen out the material recommended process like max and min mold/melt temperature.
I used TSET ID 21000 Thermoplastics material but it screen out the different material value. not the material I set up..
Can you tell me how can I fix this? Thank you
Hi,
'tcode reference
' 1800 "Melt temperature range (recommended)"
is a range, and holds two items.
To get the values the code looks like:
'tcode reference
' 1800 "Melt temperature range (recommended)"
TcodeID = 1800
Set DVec = PropProcess.FieldValues(TcodeID)
If DVec.Val(0) > 0 Then
MinMeltTemperature = DVec.Val(0)
MaxMeltTemperature = DVec.Val(1)
Else
MaxMeltTemperature = " - "
MinMeltTemperature = " - "
End If
MsgBox "Min Melt Temperature = " & MinMeltTemperature & vbCRLF & "Max Melt Temperature = " & MaxMeltTemperature,,"Melt temperature range (recommended)"
Regards,
Berndt
Sorry for bother you again @bernor_mf
The tcodeset that I used to get the setting material data is below:
' tcodeset reference
' tcode 21000 熱可塑性樹脂
Set PropED = Synergy.PropertyEditor()
Set Prop = PropED.FindProperty(21000,2)
But some study this script export the default material data.
If I change to PropED.FindProperty(21000,3) it was resolved.
I dont know why it happened.
Can you explain the different between subID (21000,1) & (21000,2) & (21000,3) to me?
now I understand 1: default material data, 2: user setting data(is it true?), and 3 is what?
Thank you, have a good day!
Regards,
Duy
'%RunPerInstance
'@
'@ DESCRIPTION
'@ This script will load an Excel document in readonly mode, collect come values from the output file
'@ and fill them into specific cells. Both excel document name and cells are hardoced into the script!!
'@ Uses core classes from customreport.vbs (Message and ScreenOutput)/
'@
'@ SYNTAX
'@ CustomExcel.vbs
'@
'@ PARAMETERS
'@ None
'@
'@ DEPENDENCIES/LIMITATIONS
'@ Limited error checking.
'@
'@@
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 DVec
' tcodeset reference
' tcode 21000 熱可塑性樹脂
Set PropED = Synergy.PropertyEditor()
Set Prop = PropED.FindProperty(21000,2)
TcodeID = 1998
tradename = Prop.FieldDescription(TcodeID)
TcodeID = 1997
Manufacturer = Prop.FieldDescription(TcodeID)
TcodeID = 1999
familyname = Prop.FieldDescription(TcodeID)
TcodeID = 1991
material_ID = Prop.FieldDescription(TcodeID)
StrMsg = "Material ID : " & material_ID + vbNewLine
StrMsg = StrMsg + "Trade name : " & tradename + vbNewLine
StrMsg = StrMsg + "Manufacturer : " & Manufacturer + vbNewLine
MsgBox StrMsg
Hello Duy,
No worries! 😊
My understanding is as you clarify:
SubID 1 : default material data
SubID 2 : user selected material data
Do you know or recall of any specific changes in study regarding material data?
(I cannot see it is related to personal material data either.)
Further, I think another approach is needed here to find subID.
To find the property from tcodeset
40000 Injection location for thermoplastics processes
and
20020 Molding material
which reference to
21000 Thermoplastics material
I will have a look.
Regards,
Berndt
Hello Duy,
Could you try this piece of code, if it resolves the issue to get the information about material?
I think it will. 😊
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 PropEditor, Prop
Set PropEditor = Synergy.PropertyEditor()
Dim MtrlID, MtrlSubID
MtrlID = -1
' 40000 Injection location for thermoplastics processes
Set Prop = PropEditor.FindProperty(40000, 1)
If Not Prop Is Nothing Then
Dim Field
Field = Prop.GetFirstField()
While Not Field = 0 And (MtrlID < 0)
' Material reference Tcode
Dim FieldValues
If Field = 20020 Then '20020 Molding material exists
Set FieldValues = Prop.FieldValues(Field)
MtrlID = FieldValues.Val(0)
MtrlSubID = FieldValues.Val(1)
End If
Field = Prop.GetNextField(Field)
Wend
End If
Set Prop = PropEditor.FindProperty(MtrlID, MtrlSubID)
If Not Prop Is Nothing Then
' Manufacturer
TcodeID = 1997
Manufacturer = Prop.FieldDescription(TcodeID)
' Trade Name
TcodeID = 1998
TradeName = Prop.FieldDescription(TcodeID)
MsgBox "Manufacturer : " & Manufacturer & vbCRLF & " ; TradeName : " & TradeName ,, "Material info"
End If
Hope this helps.
Regards,
Berndt
Hi Mr.Berndt,
It's resolved. I'm very grateful.
I still dont know why some my studies had subID = 3.
I didn't find out anything specific changes in study.
From 1 dual domain study, I copied and turned to 2 3D studies.
after running analysis, 1 study had subID = 3 and 1 study had subID = 2. It's so strange to me.
but anyway, it's resolved.
Thank you very much!!!
Hi Duy,
Thank you for the update and feedback.
Do agree it sounds strange.
Happy to hear the provided code resolved your issue. 😊
Happy coding. 😊
Regards,
Berndt
Can't find what you're looking for? Ask the community or share your knowledge.