Lsppscripting
Lsppscripting
Rev. 1
Date revised: Aug 08, 2016
By Philip Ho
Introduction
The LS-PrePost Scripting Command Language (SCL) is designed to allow a user
to write their own script to perform data manipulation for many different
purposes. The LS-PrePost SCL is a C like computer language that is executed
inside LS-PrePost. The user can execute LS-PrePost commands, retrieve results,
apply LS-DYNA data center extraction functions, and extract results from LSDYNA d3plot files and model data in the keyword input file. Also, perform
additional operations to the extracted data that were not developed within LSPrePost. The resultant data can be output to the LS-PrePost message file, a user
created file, or send it back to LS-PrePost for fringing or plotting. This document
describes the application functions interface (API) and how to use SCL along
with some example scripts for various operations.
API Functions
void ExecuteCommand(char *cmd)
Purpose:
Execute a LS-PrePost command
Input:
cmd - a string contains the LS-PrePost command
Return:
none
...............................................................................................................................
void Echo(char *string)
Purpose:
Display the text in the LS-PrePost message dialog and in the
lspost.msg file
Input:
string - text string
Output:
none
Return:
none
...............................................................................................................................
Int SCLSwitchStateTo(Int ist)
Purpose:
Switch the current state to a specified state
Input:
ist - state number, 0 > ist <= largest state
Output:
none
Return:
flag, 1=success, 0=fail
...............................................................................................................................
Int SCLGetDataCenterInt(char *parameter_name)
Purpose : Get an integer scalar value from the model. See user parameter
name list below for the available scalar values that can be retrieved.
Input:
parameter name
Output:
none
Return:
integer value
...............................................................................................................................
Float SCLGetDataCenterFloat(char *parameter_name, Int typecode, Int index,
Int ipt)
Purpose : Get a floating point value from the model. See Data Center
Parameter Name List below for the available floating point value that
can be retrieved.
Input:
parameter name
Typecode - Element or node type, constants such as "SOLID",
"SHELL", "BEAM", "TSHELL", "NODE","SPHNODE" can be
used. Not used for the parameter_name, enter as zero.
Index - Index to the component array.
Ipt - Integration points. Only valid for component values from
element shell, beam and tshell, such as "MID", "INNER", "OUTER",
1, 2, etc, can be used.
Output:
none
Return:
float value
...............................................................................................................................
void SCLGetDataCenterVector(char *parameter_name, Int externalid,
NDCOOR *result)
Purpose:
Get a vector from the model data, a vector such as nodal coordinate,
displacement vector, velocity vector, acceleration vector, and so on.
typedef ndcoor {
Float xyz[3];
} NDCOOR;
Input:
parameter_name
Externalid - Index in the component value array.
Output:
result: vector
Return:
none
...............................................................................................................................
void SCLGetDataCenterTensor(char *parameter_name, Int elementType, Int
externalid, Int ipt, TENSOR *result)
Purpose: Get stress/strain tensor from the model data.
typedef tensor{
Float xyz[6];
} TENSOR;
Input:
parameter name
elementType - "SOLID", "SHELL","TSHELL","SPHNODE" can be
used.
Externalid - Index in the component tensor array.
Ipt - Integaration points or layer. Only used for getting component
values from shell, beam and tshell, such as "MID", "INNER",
"OUTER", 1, 2, etc, can be used.
Output:
result - tensor
Return:
none
...............................................................................................................................
Int SCLGetDataCenterIntArray(char *parameter_name, Int **results,Int type,
Int id)
Purpose:
Get an integer array from the model data
Input:
parameter_name
type - element type, (only if parameter is element_connectivity)
id - element id. (only if parameter is element_connectivity)
Output:
results - integer array
Return:
array size
...............................................................................................................................
Int SCLGetDataCenterFloatArray(char *parameter_name, Int typecode, Int ipt,
Float **results)
Purpose:
Get a floating point array from the model data
Input:
parameter_name
Typecode - Element type or node type, constant such as "SOLID",
"SHELL", "BEAM", "TSHELL", "NODE","SPHNODE" can be
used. Not used for the parameter_name, enter zero.
Ipt - Integration points or layer. Only valid for getting component
values from shell, beam and tshell, such as "MID", "INNER",
"OUTER", 1, 2, etc, can be used.
Output:
results - float array
Return:
array size
...............................................................................................................................
Int SCLGetDataCenterVectorArray(char *parameter_name, NDCOOR
**results)
Purpose:
Get a vector array from the model data
Input:
parameter_name
Output:
results: vector array
Return:
array size
...............................................................................................................................
Int SCLGetDataCenterTensorArray(char *parameter_name, Int typecode,
Int ipt, TENSOR **results)
Purpose:
Get a stress or strain tensor from the model data
Input:
parameter_name
Typecode - Element type or node type, constant such as "SOLID",
"SHELL", "BEAM", "TSHELL", "NODE","SPHNODE" can be
used. If it parameter is not needed, please give it zero.
Ipt - Integration points or layer. Only valid for getting component
values from element shell, beam and tshell, such as "MID",
"INNER", "OUTER", 1, 2, etc, can be used.
Output:
results: tensor array
Return:
array size
...............................................................................................................................
void SCLFringeDCToModel(Int typecode, Int avg_opt, Int num, Float* data, Int
ist, char *label)
Purpose:
Fringe the data center array to current model.
Input:
typecode - Node or element type, constant such as "NODE",
"0","SOLID","BEAM","SHELL","TSHELL","SPHNODE" can be
used.
avg_opt nodal averaging option, 0=none, 1=nodal
num - array size
data - Float array
ist - State number which data will be assigned
Label - Name of the fringing data to be shown on fringe plot
Output:
none
Return:
none
...............................................................................................................................
Input:
Output:
Return:
...............................................................................................................................
Int SCLInquiryPartTypeI(Int iid)
Purpose:
Check the type of element for a given internal part id.
Input:
iid internal ID for part
Output:
none
Return:
element type code:
1 BEAM, 2 SHELL, 3 SOLID, 4 TSHELL
5 NRBODY, 6 MASS, 7 DISCRETE, 8 SEATBELT
9 INERTIA, 10 RGSURF, 11 SPHNODE,
12 FLUID, 13 NURBSPATCH, 14 - PARTICLE
...............................................................................................................................
void SCLGetModelDirectory(char *dir)
Purpose:
Get model directory.
Input:
dir the directory where model is put
Output:
none
...............................................................................................................................
Int SCLGetDataCenterString(char *parameter_name, Int iid, char *result)
Purpose:
Get string from model data.
Input:
parameter_name(like part_name).
iid - internal id(zero-based).
Output:
result - the string to be obtained.
Return:
1 is valid, 0 invalid.
...............................................................................................................................
exact capital letter as shown in the table to define the type in the
API functions
OBJ_SOLID
OBJ_SHELL
OBJ_FACE
OBJ_WIRE
OBJ_EDGE
OBJ_VERTEX
Output:
Iyz, Izz.
principalVector principal vector.
Return:
1=success, 0=fail
...............................................................................................................................
void SCLGeomMeasureToText(Int id, Int obj_type)
Purpose:
Issues a geometry measurement for a specified geometry shape
Input:
id - the geometry entity id
obj_type - Geometry object type, see geometry object type table
above for definition
Output:
none
Return:
none
...............................................................................................................................
void SCLGeomMeasureToText2(Int id1, Int obj_type1, Int id2, Int obj_type2)
Purpose:
Issues a geometry measurement for two specified geometry shapes
Input:
id1 - the geometry entity id for shape 1
obj_type1 - Geometry object type for shape 1, see geometry object
type table above for definition
id2 - the geometry entity id for shape 2
obj_type2 Geometry object type for shape 2
Output:
none
Return:
none
...............................................................................................................................
Int SCLGeomMeasureGetValueCount()
Purpose:
Get number of return values from Geometry measurement operation.
Input:
none
Output:
none
Return:
Number of return values.
...............................................................................................................................
void SCLGeomMeasureGetValue(Int i, char *p1, char *p2)
Purpose:
Input:
Output:
Return:
number of children
...............................................................................................................................
Int SCLIsSonParentRelationship(Int childID,Int obj_type1, Int parentID, Int
obj_type2)
Purpose:
Check if the child entity belongs to a parent entity
Input:
childID the child entity ID
obj_type1 object type of the child entity
parentID the parent entity ID
obj_type2 object type of the parent entity
Output:
none
Return:
True or False
...............................................................................................................................
Int SCLMidPlaneSearchFacePairs(Int ID,Int obj_type, Int bStrict, Int **ids)
Purpose:
Find the mid-plane faces pairs for a given solid entity
Input:
ID the solid entity ID
obj_type object type, must be OBJ_SOLID
bStrict key for setting the searching tolerance, 0=relax, 1=strict
Output:
face ids array, 2 ids make up a pair
Return:
number of pairs
...............................................................................................................................
Int SCLPropagateFacesByAngle(Int* IDs, Int nFace, Float angleTol, Int**
FaceIDs, Int* FaceNum)
Purpose:
Given several seed faces, find the same level faces by angle. This is
API is from Shell by Angle in Middle Surface dialog.
Input:
IDs several seed faces ID
nFace number of seed faces
angleTol angle tolerance to propagate
Output:
FaceIDs several seed faces ID
FaceNum number of propagated faces
Return:
0: no propagated faces found; 1: find propagated faces
...............................................................................................................................
Int SCLSearchSimilarShapes(Int* IDs, Int* Types, Int n, Float relativeRatio, Int
...............................................................................................................................
void SCLCopyAssembly(Int fromAssemblyID, Int toAssemblyID)
Purpose:
Copy all entities(shapes, reference geometry and FEM parts) in some
assembly to another assembly
Input:
fromAssemblyID the source assembly ID
toAssemblyID the destination assembly ID. -1: copy to a new
assembly
...............................................................................................................................
void SCLCopyAssemblyShape(Int fromAssemblyID, Int toAssemblyID)
Purpose:
Copy all shapes in some assembly to another assembly
Input:
fromAssemblyID the source assembly ID
toAssemblyID the destination assembly ID. -1: copy to a new
assembly
...............................................................................................................................
void SCLCopyAssemblyRefGeom(Int fromAssemblyID, Int toAssemblyID)
Purpose:
Copy all reference geometry in some assembly to another assembly
Input:
fromAssemblyID the source assembly ID
toAssemblyID the destination assembly ID. -1: copy to a new
assembly
...............................................................................................................................
void SCLCopyAssemblyFEMPart(Int fromAssemblyID, Int toAssemblyID)
Purpose:
Copy all FEM parts in some assembly to another assembly
Input:
fromAssemblyID the source assembly ID
toAssemblyID the destination assembly ID. -1: copy to a new
assembly
...............................................................................................................................
void SCLCopyGPart(Int fromGpartID, Int toGPartID)
Purpose:
Copy all entities in some GPart to another GPart
Input:
fromGpartID the source GPart ID
toGPartID the destination GPart ID. -1: copy to a new GPart
...............................................................................................................................
...............................................................................................................................
Int SCLHoleManage_GetInnerHoleCount()
Purpose:
After analysis, get number of inner holes (inner loop from face)
Return:
number of inner hole
...............................................................................................................................
Int SCLHoleManage_GetOutHoleCount()
Purpose:
After analysis, get number of out holes (out hole is grouped by
multiple faces)
Return:
number of out hole
...............................................................................................................................
Int SCLHoleManage_GetInnerHoleInfor(Int holeID, char** holeName, Int*
holeWireID, Int** holeEdgeIDs, Int* holeEdgeCount, Float* size)
Purpose:
After analysis, get the inner hole geometry information
Input:
holeID the inner holes ID
Output:
holeName the inner holes name
holeWireID wire ID of the inner hole
holeEdgeIDs edges ID of the inner hole
holeEdgeCount number of edges from the inner hole
size diagonal length of the inner holes bounding box
Return:
0: invalid inner hole; 1: success
...............................................................................................................................
Int SCLHoleManage_GetOutHoleInfor(Int holeID, char** holeName, Int**
holeEdgeIDs, Int* holeEdgeCount, Float* size, Int* bFilled)
Purpose:
After analysis, get the out hole geometry information
Input:
holeID the out holes ID
Output:
holeName the out holes name
holeEdgeIDs edges ID of the out hole
holeEdgeCount number of edges from the out hole
size diagonal length of the inner holes bounding box
bFilled out hole filled tag (some large out hole should not be filled)
Return:
0: invalid out hole; 1: success
...............................................................................................................................
Int SCLHoleManage_FillHole(Int bInnerHole, Int holeID)
Purpose:
After analysis, fill specified inner or out hole
Input:
bInnerHole tag of inner hole or out hole
holeID the holes ID
Return:
0: invalid out hole; 1: success
...............................................................................................................................
void SCLHollowManage_Analysis(Int bSimpleHollowOnly)
Purpose:
Input:
...............................................................................................................................
void SCLHollowManage_AnalysisShape(Int id, Int type, Int
bSimpleHollowOnly)
Purpose:
Start analysis hollow in geometry shell or solid
Input:
id the shell or solid shapes ID
type the shapes type
bSimpleHollowOnly a tag to check simple or complex hollow
...............................................................................................................................
Int SCLHollowManage_GetHollowCount()
Purpose:
After analysis, get number of hollow
Return:
number of hollow
...............................................................................................................................
Int SCLHollowManage_GetHollowInfor(Int hollowID, char** hollowName,
Int** hollowFaceIDs, Int* holeFaceCount, Float* size)
Purpose:
After analysis, get the hollow geometry information
Input:
hollowID the hollows ID
Output:
hollowName the hollows name
hollowFaceIDs faces ID of the hollow
holeFaceCount number of faces from the hollow
size diagonal length of the hollows bounding box
Return:
0: invalid hollow; 1: success
...............................................................................................................................
Int SCLHollowManage_FillHollow(Int hollowID)
Purpose:
After analysis, fill one hollow
Input:
hollowID the hollowIDs ID
Return:
0: failed; 1: success
...............................................................................................................................
Int SCLHollowManage_FillAll()
Purpose:
After analysis, fill all hollows
Return:
0: failed; 1: success
...............................................................................................................................
Int SCLSetDBEntityColor(Int ID, Int type, Float* color)
Purpose:
Set entitys color
Input:
ID the entity ID
type the entity type
color the color array (size 4, the last component is transparency)
Return:
0: failed; 1: success
...............................................................................................................................
Int SCLGetDBEntityColor(Int ID, Int type, Float* color)
Purpose:
Get entitys color
Input:
ID the entity ID
type the entity type
Output:
color the color array (size 4, the last component is transparency)
Return:
0: failed; 1: success
The syntax:
runscript sclfilename optional parameters
Example: the following command file will execute the script that creates a X-Y
curve with the parameters defined in the command file.
parameter pa 9.0E+07
parameter pb 7000.0
parameter pc 4.0E+07
parameter npt 300
parameter xmin 0.0
parameter xmax 0.00126
runscript "customcurve.scl"
2. Run it by going to the Application pull down menu, select Customize and in
the pop up dialog, click Load to load the SCL file, then click Run to execute.
Running script this way parameter cannot be passed to the script file, as shown in
the following pictures:
Type
Status
num_states
Int
Availabl
e
num_parts
Int
Availabl
e
num_nodes
Int
Availabl
e
num_elements
Int
Availabl
e
largest_node_id
Int
Availabl
e
largest_element_id
Int
Availabl
e
num_shell_elements
Int
Availabl
e
num_beam_elements
Int
Availabl
e
num_solid_elements
Int
Availabl
e
num_tshell_elements
Int
Availabl
e
num_sph_elements
Int
Availabl
e
num_discrete_element
s
Int
Availabl
e
num_seatbelt_element
s
Int
Availabl
e
num_mass_elements
Int
Availabl
e
num_inertia_elements
Int
Availabl
e
num_validparts
Int
Availabl
e
num_beam_intp
Int
Availabl
e
largest_point_id
Int
Availabl
e
largest_vertex_id
Int
Availabl
e
largest_edge_id
Int
Availabl
e
largest_surface_id
Int
Availabl
e
node_ids
Int array
Availabl
e
element_ids
Int array
Availabl
e
elemofpart_ids
Int array
Availabl
e
validpart_ids
Int array
Availabl
e
element_connectivity
Int array
Availabl
e
largest_time
Float
Availabl
e
largest_disp_magnitud
e
Float
Availabl
e
max_stress_x
Float
Availabl
e
max_stress_y
Float
Availabl
e
max_stress_z
Float
Availabl
e
max_stress_xy
Float
Availabl
e
max_stress_yz
Float
Availabl
e
max_stress_zx
Float
Availabl
e
max_strain_x
Float
Availabl
e
max_strain_y
Float
Availabl
e
max_strain_z
Float
Availabl
e
max_strain_xy
Float
Availabl
e
max_strain_yz
Float
Availabl
e
max_strain_zx
Float
Availabl
e
state_times
Float array
Availabl
e
nodal_temperatures
Float array
Availabl
e
node_x
Float or float
array
Availabl
e
node_y
Float or float
array
Availabl
e
node_z
Float or float
array
Availabl
e
disp_x
Float or float
array
Availabl
e
disp_y
Float or float
array
Availabl
e
disp_z
Float or float
array
Availabl
e
disp_magnitude
Float or float
array
Availabl
e
velo_x
Float or float
array
Availabl
e
velo_y
Float or float
array
Availabl
e
velo_z
Float or float
array
Availabl
e
velo_magnitude
Float or float
array
Availabl
e
accel_x
Float or float
array
Availabl
e
accel_y
Float or float
array
Availabl
e
accel_z
Float or float
array
Availabl
e
accel_magnitude
Float or float
array
Availabl
e
stress_x
Float or float
array
Availabl
e
stress_y
Float or float
array
Availabl
e
stress_z
Float or float
array
Availabl
e
stress_xy
Float or float
array
Availabl
e
stress_yz
Float or float
array
Availabl
e
stress_zx
Float or float
array
Availabl
e
effective_plastic_str
ain
Float or float
array
Availabl
e
stress_1stprincipal
Float or float
array
Availabl
e
stress_2ndprincipal
Float or float
array
Availabl
e
stress_3rdprincipal
Float or float
array
Availabl
e
strain_x
Float or float
array
Availabl
e
strain_y
Float or float
array
Availabl
e
strain_z
Float or float
array
Availabl
e
strain_xy
Float or float
array
Availabl
e
strain_yz
Float or float
array
Availabl
e
strain_zx
Float or float
array
Availabl
e
strain_1stprincipal_i
nfin
Float or float
array
Availabl
e
strain_2ndprincipal_i
nfin
Float or float
Availabl
array
strain_3rdprincipal_i
nfin
Float or float
array
Availabl
e
lower_eps1
Float array
Availabl
e
upper_eps1
Float array
Availabl
e
mean_eps1
Float array
Availabl
e
lower_eps2
Float array
Availabl
e
upper_eps2
Float array
Availabl
e
mean_eps2
Float array
Availabl
e
sigma1
Float array
Availabl
e
sigma2
Float array
Availabl
e
mx
Float or float
array
Availabl
e
my
Float or float
array
Availabl
e
mxy
Float or float
array
Availabl
e
qx
Float or float
array
Availabl
e
qy
Float or float
array
Availabl
e
nx
Float or float
array
Availabl
e
ny
Float or float
array
Availabl
e
nxy
Float or float
array
Availabl
e
Nx/t-6*Mx/(t*t)
Float or float
array
Availabl
e
Nx/t+6*Mx/(t*t)
Float or float
array
Availabl
e
Ny/t-6*My/(t*t)
Float or float
array
Availabl
e
Ny/t+6*My/(t*t)
Float or float
array
Availabl
e
Nxy/t-6*Mxy/(t*t)
Float or float
array
Availabl
e
Nxy/t+6*Mxy/(t*t)
Float or float
array
Availabl
e
strain_energy_density
Float or float
array
Availabl
e
kinetic_energy
Float or float
array
Availabl
e
internal_energy
Float or float
array
Availabl
e
total_energy
Float or float
array
Availabl
e
rigidbody_dispx
Float or float
array
Availabl
e
rigidbody_dispy
Float or float
array
Availabl
e
rigidbody_dispz
Float or float
array
Availabl
e
result_rigidbody_disp
Float or float
array
Availabl
e
rigidbody_velx
Float or float
array
Availabl
e
rigidbody_vely
Float or float
array
Availabl
e
rigidbody_velz
Float or float
array
Availabl
e
result_rigidbody_vel
Float or float
array
Availabl
e
rigidbody_accelx
Float or float
array
Availabl
e
rigidbody_accely
Float or float
array
Availabl
e
rigidbody_accelz
Float or float
array
Availabl
e
result_rigidbody_accel
Float or float
array
Availabl
e
von_mises
Float or float
array
Availabl
e
thickness
Float or float
array
Availabl
e
area
Float or float
array
Availabl
e
volume
Float or float
array
Availabl
e
shell_normal
Vector
Availabl
e
displacement
Vector or vector
array
Availabl
e
velocity
Vector or vector
array
Availabl
e
acceleration
Vector or vector
array
Availabl
e
global_stress
Tensor or tensor
array
Availabl
e
global_strain
Tensor or tensor
array
Availabl
e
axial_force
Float or Float
array
Availabl
e
s_shear_resultant
Float or Float
array
Availabl
e
t_shear_resultant
Float or Float
array
Availabl
e
s_bending_moment
Float or Float
array
Availabl
e
t_bending_moment
Float or Float
array
Availabl
e
torsional_resultant
Float or Float
array
Availabl
e
axial_stress
Float or Float
array
Availabl
e
rs_shear_stress
Float or Float
array
Availabl
e
tr_shear_stress
Float or Float
array
Availabl
e
plastic_strain
Float or Float
array
Availabl
e
axial_strain
Float or Float
array
Availabl
e
Examples:
The examples can be download from the LSTC ftp site:
ftp://ftp.lstc.com/outgoing/lsprepost/SCLexamples/SCL_Examples.zip