How to extract Design Point information using Workbench or Mechanical scripting?
I'm trying to get the information from the Table of Design Points in the Parameter Set stored as variables. How can I do that using either Workbench or Mechanical scripting?
Best Answer
-
The data in the Table of Design Points is accessible by using Workbench Scripting commands. The most effective and direct way to approach this would be to use Workbench's Scripting console (File > Scripting). With the following script you can retrieve the most essential information regarding the data in the parameters table:
# Create list of lists containing essential Parameter information parameter, parameterName, parameterValueType, parameterValue, parameterValueUnit = ([] for i in range(5)) for param in Parameters.GetAllParameters(): parameter.append(param.Name) parameterName.append(param.DisplayText) parameterValueType.append(param.ValueQuantityName) parameterValueUnit.append(param.Value.Unit) parameters = [parameter, parameterName, parameterValueType, parameterValueUnit] # Create list of lists containing essential Design Point information designPointName, designPointValues = ([] for i in range(2)) for dp in Parameters.GetAllDesignPoints(): designPointName.append(dp.DisplayText) subList = [] for param in Parameters.GetAllParameters(): subList.append(dp.GetParameterValue(param).Value) designPointValues.append(subList) designPoints = [designPointName, designPointValues]
The same commands can be executed through Mechanical Scripting. This would, however, require to import the Workbench Journal library (wbjn). An intro guide to this approach can be found here.
In summary, you would create a parameters_cmd and designPoints_cmd that contain the respective section of the above commands enclosed in triple (''') quotes, and issue a returnValue() function for the parameters and designPoints lists. For example:
import wbjn parameters_cmd = ''' RespectiveSectionFromCodeAbove returnValue(parameters) ''' param = wbjn.ExecuteCommand(ExtAPI,parameters_cmd) designPoints_cmd = ''' RespectiveSectionFromCodeAbove returnValue(designPoints) ''' dp = wbjn.ExecuteCommand(ExtAPI,designPoints_cmd)
1
Answers
-
This has always been a pain and I am glad Nikos had the ability to figure it out!
0