Customize with User Procedures

Customize Batchmesher by providing user-defined Tcl procedures that run at specific times during the Batchmesher process.

Procedures can be customized for pre-run, post-run, pre-geometry load, post-geometry load, pre-batchmesh, and post-batchmesh.

These scripts can perform a wide range of tasks, such as:
  • Exporting a mesh in solver format.
  • Generating the midsurface of a thin solid geometry.
  • Performing a surface offset to move a sheet geometry to a midsurface location.
  • Naming and numbering parts to user-specific requirements.
Batchmesher has the ability to specify user-specified procedures at the following steps for each job:
Pre-geometry load
Executed immediately after the job begins, before the input model is imported.
Pre-batch mesh
Executed immediately after the input model is imported, before the batch mesh begins. Examples include extracting a midsurface or performing a surface offset.
Post-batch mesh
Executed immediately after the batch mesh process is complete. Examples include creating solver specific cards, or exporting the mesh in a specific format.
Access to model-specific variables is possible within user-registered procedures. The array ::hmbm::gVarArray contains variables accessible by you.
CADImportOpt
String of CAD import options.
cadtype
Type of model file.
critername
Criteria file name, excluding the path.
criterpath
Criteria file name, including the path.
CurrentEventName
modelname
Input model file name, excluding the path.
modelpath
Input model file name, including the path.
outmodelname
Output model file name, excluding the path.
outpath
Output file path.
paramname
Parameter file name, excluding the path.
parampath
Parameter file name, including the path.
POST_BATCHMESH,tclparameters
Parameters passed to the post-batch mesh procedure. Only available when such a procedure is defined.
POST_BATCHMESH,tclprocedure
Post-batch mesh procedure name. Only available when such a procedure is defined.
POST_BATCHMESH,tclscriptpath
Post-batch mesh script name, including the path. Only available when such a procedure is defined.
PRE_BATCHMESH,tclparameters
Parameters passed to the pre-batch mesh procedure. Only available when such a procedure is defined.
PRE_BATCHMESH,tclprocedure
Pre-batch mesh procedure name. Only available when such a procedure is defined.
PRE_BATCHMESH,tclscriptpath
Pre-batch mesh script name, including the path. Only available when such a procedure is defined.
PRE_GEOMETRY_LOAD,tclparameters
Parameters passed to the pre-geometry load procedure. Only available when such a procedure is defined.
PRE_GEOMETRY_LOAD,tclprocedure
Pre-geometry load procedure name. Only available when such a procedure is defined.
PRE_GEOMETRY_LOAD,tclscriptpath
Pre-geometry load script name, including the path. Only available when such a procedure is defined.
resfilename
Output result file name, excluding the path.
By default, Batchmesher additionally passes in the name of the model file as the last argument to the Tcl procedures.
Note:

Tcl scripts must not automatically run any procedures, as this is handled by Batchmesher. Doing so will generate an error or unexpected results.

Save the model after running user procedures, as this is not done automatically. For example:
hm_answernext "yes"
*writefile "$::hmbm::gVarArray(outmodelname)" 0
proc nastran_export { modelName args }  {
set outputDir $::hwbm::gVarArray(modelpath)
set template_dir [ hm_info -appinfo SPECIFIEDPATH TEMPLATES_DIR]
set template [file join $template_dir "feoutput" "nastran" "general"]
*feoutput "$template" ${outputDir}/${modelName}.dat 1 1 1
}
Figure 1. Example: Post-Mesh User Procedure. This example exports the generated mesh to a NASTRAN file named <modelname>.dat in the same directory as the original input model.
Procedures can also be specified at the run level to enables you to perform operations such as reading all the batch-meshed parts into a single model, creating properties or materials, or creating connections such as welds between the parts. Customization options at the run level can be set to execute at two points in the batch mesh process:
Pre-run
Executed before the first model/job starts.
Post-run
Executed after the last model/job completes.
In the pre-run and post-run scripts, the model-specific variables are not available.