Script Utility

GetEntityFromGroup

This function is used to get entities (Face/Edge/Node/Element) from groups which can be used as inputs for other operations.

Syntax:

var EntityIdArray =[];

SimlabDoc.GetEntityFromGroup("GroupName ", EntityIdArray);
Sample Script

getSupportEntitiesForSet

This function is used to get support entities (Face/Edge/Node/Element) from sets which can be used as inputs for other operations.

Syntax:

var EntityIdArray =[];
SimLabUtility.getSupportEntitiesForSet ("SetName ", EntityIdArray);
Sample Script

GetGeomEntitiesFromBody

This function is used to get entities (Face/Edge/Vertex) from body which can be used as inputs for other operations.

Syntax:

var BodyNameArray=["Body 1"];
var EntityIdArray =[];
var NumEntities1=SimLabUtility.GetGeomEntitiesFromBody ("ModelName", BodyNameArray,EntityType, EntityIdArray);
Sample Script

GetCylindricalFaceAttributes

This function is used to get axis points and radius from cylindrical face group or face ID.

Syntax:

var AxisPt1=[];
var AxisPt2=[];
var Radius=[];
SimLabUtility.GetCylindricalFaceAttributes("Group Name",AxisPt1, AxisPt2, Radius);
                                          (or)
SimLabUtility.GetCylindricalFaceAttributes("ModelName",FaceID,AxisPt1, AxisPt2, Radius);
Sample Script
Note:
  • Only cylindrical face group can be used.
  • The axis points are at the 2 ends of the cylinder.

GetArcEdgeAttributes

This function is used to get center points and radius from edge group or edge ID.

Syntax:

var CenterPoint=[];
var Radius=[];
SimLabUtility.GetArcEdgeAttributes("Group Name", Centre point array, Radius);
                                  (or)
SimLabUtility.GetArcEdgeAttributes("Model Name",Edge ID, Centre point array, Radius);
Sample Script
Note:
  • The given edges should be arc edge or circular edges.
  • More than one edge loop is not allowed.

GetConicalFaceAttributes

This function is used to get axis points, minimum radius and maximum radius from conical face group or face ID.

Syntax:

var AxPt1=[];
var AxPt2=[];
var MinRad=[];
var MaxRad=[];
SimLabUtility.GetConicalFaceAttributes("GroupName",AxPt1,AxPt2,MinRad,MaxRad);
                                      (or)
SimLabUtility.GetConicalFaceAttributes("ModelName",FaceID,AxPt1,AxPt2,MinRad,MaxRad);
Sample Script

DefinePlaneFromGroup

This function is used to identify plane points from face group (or) edge group.

Syntax:

var PlanePoint1=[];
var PlanePoint2=[];
var PlanePoint3=[];
SimLabUtility.DefinePlaneFromGroup("GroupName", " GroupType(FACEGROUPINPUT (or) EDGEGROUPINPUT)", PlanePoint1,PlanePoint2,PlanePoint3);
Sample Script

DefinePlaneFromEntity

This function is used to identify plane points from face ID (or) edge ID.

Syntax:

var PlanePoint1=[];
var PlanePoint2=[];
var PlanePoint3=[];
SimLabUtility.DefinePlaneFromEntity("ModelName", " EntityID(Face ID (or) Edge ID)", PlanePoint1,PlanePoint2,PlanePoint3);
Sample Script

OffsetPlane

This function is used to offset the given plane points to the specified offset distance. The output plane points is update in the same input plane points array.

Syntax:

var PlanePoint1=[];
var PlanePoint2=[];
var PlanePoint3=[];
SimLabUtility.OffsetPlane(PlanePoint1, PlanePoint2, PlanePoint3, offsetDistance);
Sample Script

GetFirstElementFromFaceGroup

This function is used to get one reference element (First element) from the given face group. It return element id as the output.

Syntax:

var nElementId=SimLabUtility.GetFirstElementFromFaceGroup("GroupName");
Sample Script

GetNormalFromFaceGroup

This function is used to get normal from one reference element (First element) from the given face group. The faces under face group should be planar.

Syntax:

var DirectionPt1=[]
var DirectionPt2=[]
var DirectionPt3=[]
SimLabUtility.GetNormalFromFaceGroup("GroupName",DirectionPt1,DirectionPt2,DirectionPt3);
Sample Script

GetInDoubleStringParameter

This function is used to get the integer(or)double(or)string value from parameter. This will be helpful for script functions which do not have direct parameter input.

Syntax:

Integer Parameter
    var Result = SimLabUtility.GetIntParameter("SimLab Parameters");
Double Parameter
    var Result = SimLabUtility.GetDoubleParameter("SimLab Parameters");
String Parameter
    var Result = SimLabUtility.GetStringParameter("SimLab Parameters");
Sample Script

GetBoxPointsForBodies

This function is used to get the points that define the bounding box of a body.

The output from this function can be used to specify bounding box points for creating body from solid elements and body break operations.

Syntax:

var BoxPoint1 = [];
var BoxPoint2 = [];
var BoxPoint3 = [];
var BoxPoint4 = [];
var BoxPoint5 = [];
var BoxPoint6 = [];
var BoxPoint7 = [];
var BoxPoint8 = [];
var PositiveBuff= [500,500,500];
var NegativeBuff= [500,500,500];
var EntityInfo=[]
SimLabUtility.GetBoxPointsForBodies("Model Name",Input Bodies Array, Positive Buffer, Negative Buffer ,Box Point 1 Array, Box Point 2 Array, Box Point 3 Array, Box Point 4 Array, Box Point 5 Array, Box Point 6 Array, Box Point 7 Array, Box Point 8 Array);
Sample Script

getNodePositionFromNodeID

This function is used to get the XYZ coordinate array of a node from its ID.

Syntax:

var XYZ_Array = [];
SimLabUtility.getNodePositionFromNodeID("Model Name",NodeID, XYZ_Array);
Sample Script

getVertexPositionFromVertexID

This function is used to get the XYZ coordinate array of a vertex from its ID.

Syntax:

var XYZ_Array = [];
SimLabUtility.getVertexPositionFromVertexID("Model Name",VertexID, XYZ_Array);
Sample Script

GetBodiesWithSubString

This function is used to retrieve an array of body names which have a given substring.

The output array can be used in other functions that need the name array as input.

Syntax:

var SubStringArray=["Body1*"];
var BodyNameArray=[];
SimLabUtility.GetBodiesWithSubString("Model Name",SubStringArray,BodyNameArray);
Sample Script

createGroupsOfConnectedEntities

This function is used to create and get the output group name array of connected faces or edges.

Syntax:

var OutputGroupNames = [];
SimLabUtility.createGroupsOfConnectedEntities("GroupName",OutputGroupNames);
Sample Script

IsGroupPresent

This function is used to find whether the group with given name is present or not.

Syntax:

var GrpFound = IsGroupPresent("GroupName");
Sample Script

IsParameterPresent

This function is used to find whether the parameter with given name is present or not.

Syntax:

var ParameterFound = IsParameterPresent("ParameterName");
Sample Script

CommentMessagePopUp

This function is useful to post a message in the middle of the script. A use case is where the author of the script can ask the user to do manual operations, for example, create a group, before continuing with subsequent operations in the script. This function posts a message box during interactive play.

It will be helpful to provide a description of the process as well as to alert the user to perform any manual process like creating/updating groups, creating mesh controls, etc.

Syntax:

SimLabUtility.CommentMessagePopUp("Comment Text to Display");
Sample Script

Spawn_Process

This function is used to call a batch file inside SimLab JavaScript.

Syntax:

var args_new = [];
SimLabUtility.Spawn_Process("BatchFileLocation", args_new);
Note: arguments array can be empty if there are no arguments to call a batch file.

getGroupsWithSubString

This function is used to retrieve an array of group names which have a given substring.

The output array can be used in other functions that need the group name array as input.

Syntax:

var SubStringArray=["test*"];
var OutputGroupNameArray=[];
SimLabUtility.getGroupsWithSubString("GroupType",SubStringArray,OutputGroupNameArray);
Note: OutputGroupNameArray will be appended with the group names that matches the given sub string.
Sample Script

PrintLapseTime

This function is used to print the lapse timing for the scripting process.

The lapse timing of the process is written in log file during auto play and in status window during interactive play.

Sample Script

resetModel

This function is used to brings visible model view to the original state including the view angle.

Syntax:

SimLabUtility.resetModel();
Sample Script

getModelName

This function is used to get the name of the model in database. Based on the model type (FEM (or) CAD) it returns the first model name of the current GDA.

Syntax:

var OutModelName=SimLabUtility.getModelName("ModelType (FEM (or) CAD)");
Sample Script

PrintToLogFile

This function is used to print the given text in log file. For interactive play, the given text is displayed in script debugger widget status window, otherwise the text is written in ProjectLogfile.txt.

Syntax:

SimLabUtility.PrintToLogFile("Text want to display in log file");
Sample Script

getEntityFromElementEdgeGroup

This function is used to get element edge id's and element edge index from element edge group which can be used as inputs for other operations.

Syntax:

var EntityIdArray =[];
var EntityIndexArray =[];
SimlabDoc.GetEntityFromGroup("GroupName ", EntityIdArray, EntityIndexArray);
Sample Script

stopExecutionOnError

This function is used to stop the script execution at the time of failure case.

Syntax:

SimLabUtility.stopExecutionOnError();

Sample Script

Note: After this function called if any operation fails, the script execution will be stop.

SetActiveDocument

This function is used to active the document as current document for a given database index or database name.

Syntax:

Simlab.SetActiveDocument(DataBaseIndex or DataBase Name);

Sample Script

GetChildrenInAssembly

This function is used to get the sub models or bodies of the given model name or submodel name.

Syntax:

var OutputList =[];
SimLabUtility.GetChildrenInAssembly("ModelName","ModelName or SubModelName","Method Type(SUBASSEMBLIES or BODIES or ALLBODIES)",OutputList);

Sample Script

GetSelectedEntities

This function is used to get selected entities for a given entity type.

Syntax:

var EntityIds =[];
SimLabUtility.GetSelectedEntities("Entity Type(FACE/EDGE/VERTEX/ELEMENT/NODE)",EntityIds);

Sample Script

GetSelectedBodies

This function is used to get selected bodies.

Syntax:

var BodyNames =[];
SimLabUtility.GetSelectedBodies(BodyNames);

Sample Script

getAllRootModelNames

This function is used to get all root model names in the database. Based on model type (FEM/CAD/All) it return all model names in the same sequence as present in the database.

Syntax:

var OutModelNames=[];
SimLabUtility.getAllRootModelNames("ModelType(FEM/CAD/All)", OutModelNames);

Sample Script

GetBodiesFromGroup

This function is used to get body names from groups which can be used as inputs for other operations.

Syntax:

var Bodies = [];
SimlabDoc.GetBodiesFromGroup("GroupName",Bodies);

Sample Script

getAnalysisLCS_FromNode

This function is used to get the coordinate ID and name for a given node ID.

Syntax:

SimLabUtility.getAnalysisLCS_FromNode("modelName",NodeID);

Sample Script

setTransparency

This function is used to set (or) reset the transparency for a given group. The group input may be body group (or) face group.

Syntax:

SimLabUtility.setTransparency("GroupName", true(or)false);

Sample Script

resetTransparency

This function is used to reset all transparency faces in a database.

Syntax:

SimLabUtility.resetTransparency();

Sample Script

getEntitiesFromSet

This function is used to get actual entities from the given set. Set name is input and set type is optional to get entities from specified type.

Syntax:

  • Without set type:
    var EntityIdArray=[];
    SimLabUtility.getEntitiesFromSet("SetName",EntityIdArray);

  • With set type:
    var EntityIdArray=[];
    SimLabUtility.getEntitiesFromSet("SetName",EntityIdArray,"SetType");

Sample Script

showOrHideEntities

This function is used to show (or) hide (or) isolate the given bodies / faces / edges / groups.

Syntax:

var inputEntities=[];
SimLabUtility.showOrHideEntities(inputEntities, "OperationType(Show /Hide /Isolate)", "ModelName", "EntityType(Body /Face /Edge)");

Sample Script

setSelectionFilter

This function is used to update the selection filter in GUI based on the given filter type.

Syntax:

SimLabUtility.setSelectionFilter("FilterType");

where:

  • FilterType = Vertex; to set vertex filter.
  • FilterType = Edge; to set edge filter.
  • FilterType = Edge; to set edge filter.
  • FilterType = CircleEdge; to set circle filter.
  • FilterType = EdgePath; to set edge path filter.
  • FilterType = FreeEdgeLoop; to set free edge loop filter.
  • FilterType = EdgeLoop; to set edge loop filter.
  • FilterType = Face; to set face filter.
  • FilterType = CylinderFace; to set cylinder filter.
  • FilterType = FilletFace; to set fillet filter.
  • FilterType = Body; to set body filter.
  • FilterType = RBEBody; to set RBE body filter.
  • FilterType = Node; to set node filter.
  • FilterType = RBENode; to set RBE node filter.
  • FilterType = ElementEdge; to set element edge filter.
  • FilterType = BarElement; to set bar filter.
  • FilterType = Element; to set shell elementfilter.
  • FilterType = SolidElement; to set solid element filter.
  • FilterType = Load; to set loads filter.
  • FilterType = RBE; to set RBE filter.
  • FilterType = Coordinate; to set coordinates filter.
  • FilterType = RBar; to set RBAR filter.

Sample Script

fitView

This function will bring the selected entities to the view area with fit to screen view.

Syntax:

var InputEntities = [];
SimLabUtility.fitView("EntityType","ModelName",InputEntities);

where:

  • EntityType:
    • Model/Body/Face/Edge/Node/ShellElement/SolidElement.
  • InputEntities:
    • Body ["Body 1", "Body 2", "Body 3"].
    • Face/ Edge/ Node/ShellElement/SolidElement [ Id1, Id2, Id3 ].

Sample Script

redisplayEntity

This function redisplays the hidden entities of body/model.

Syntax:

var inputBodyNames = [];
SimLabUtility.redisplayEntity("EntityType(Body/Model)","ModelName",inputBodyNames(Optional));

Sample Script

getResultLoadCases

This function is used to extract the list of load cases names from the results. This can be used as input for other operations.

Syntax:

var ResultLoadCaseNameList =[];
SimLabUtility.getResultLoadCases(ResultLoadCaseNameList);

Sample Script

getResultLoadCases

This function is used to retrieve an array of sets which matches a given substring.

Syntax:

var SubSetNameList = ["Intake*"];
var SetNameList = [];
SimLabUtility.getSetsWithSubString("Node", SubSetNameList, SetNameList);

Sample Script