SimSolid JavaScript Reference
This document provides a comprehensive guide to interacting with SimSolid programmatically using JavaScript. It details the available objects, their attributes, and functions, along with clear examples to help you automate your SimSolid workflows.
1. Global Object
The global object acts as a central hub for managing application-wide information and controls. It provides a way to interact with the core state of the SimSolid application, including its execution status and error handling.
Functions
A key function of the global object is errorCode, which is used for
diagnostics and to communicate the success or failure of a script's execution. This
object is fundamental for writing robust scripts that can gracefully handle errors
and provide meaningful feedback about the analysis process.
errorCode-
- Integer
- This function returns an integer representing the exit code of the SimSolid.exe process. A value of 0 typically indicates successful execution.
Example:
(Checking Exit Code in a Batch Script/Command Prompt)
Before proceeding with the analysis, this if statement checks if there are any parts or groups of parts that are not connected to the main assembly.// check if any disconnected groups of parts if (!study.hasDisconnectedGroupsOfParts()) { // ... (rest of the analysis setup) } else this.errorCode = 1; // error code if disconnected groups of parts!study.hasDisconnectedGroupsOfParts()- If this condition is true (meaning there are no disconnected groups), the script proceeds to set up and run the modal analysis.
this.errorCode = 1- If disconnected groups are found, it sets an error code 1 and skips the analysis, as a disconnected model would yield incorrect or unfeasible results.
In JavaScript, this attribute is primarily for diagnostic purposes after the script has run within SimSolid's context.
2. Project Object
The project object allows you to manage global settings for your project.
Functions
setDefaultUnits-
- Sets the default units to be used throughout the project
- Helps maintain consistency and avoids the need to specify units repeatedly for each individual operation
Parameters:Table 1. Name Type Accepted Values Default Value length String ‘mm’, ‘cm’, ‘m’, ‘in’ ‘mm’ angle String ‘deg’, ‘rad’ ‘deg’ force String 'N', 'lbf', 'kip' 'N' moment String 'N*m', 'N*mm', 'lbf*in' 'N*m' Example:// Set default units for the project Project.setDefaultUnits ({ length: 'cm', force: 'N' }); addDesignStudy-
- Creates a new design study by importing geometry from a CAD file and returns the Design Study object
Parameters:Table 2. Name Type Accepted Values Default Value file String Path to a CAD file reader String ‘parasolid’, ‘ct’, 'parasolid+spatial' ‘parasolid’ resolution String ‘standard’, ‘enhanced’, ‘fine’, ‘custom’ ‘standard’ geomType String 'solids+skins', 'solids', 'skins' 'solids+skins' angularDev Number 15.0, deg chordalDev Number 0.635, mm units Object Same as for setDefaultUnits Taken from the Project level Example:// create a new design study var study = Project.addDesignStudy({ file: 'D:/Batch mode/Modal_Analysis/Pullup bar V1.step', reader: ‘ct’, //ct is the SimSolid legacy reader resolution: 'custom', angularDev: 12, chordalDev: 0.5, units: { length: 'cm', force: ‘N’ } }); save-
- Saves the project into .ssp and returns false if it fails
Parameters:Table 3. Name Type Accepted Values Default Value file String Path to a .ssp file. NA Syntax:Project.save ({ file: ‘<File_path>/<File_name>.ssp' }); open-
- Open the existing .ssp
- Returns false if it fails
Parameters:Name Type Accepted Values Default Value file String Path to a .ssp file. NA Syntax:Project.open ({ file: ‘<File_path>/<File_name>.ssp' }); initializeSolutions-
- Deletes all solutions and response meshes
Syntax:Project.initializeSolutions(); solveAllAnalyses-
- Solves all analyses
Syntax:Project.solveAllAnalyses(); getDesignStudies-
- Returns the collection of all Design Studies objects
Syntax:Project.getDesignStudies())Example:
The above script performs a series of actions namely - opens an SSP file, runs Modal 1 analysis in Design study 1, and saves the SSP by appending _solved to the original file name.// open project Project.open({ file: D:/Batchmode/ fin2.ssp}); //Set number of logical cores for the solution Project.setOptions({ numOfCoresToUse: 12 }); // Adjust to your desired number of cores // run specific analysis var analysisSpecific = null; for (var study of Project.getDesignStudies()) { if (study.getName() == 'Design study 1') { // Specify the exact name of your design study for (var analysis of study.getAnalyses()) { if (analysis.getName() == 'Modal 1') { // Specify the exact name of your analysis analysisSpecific = analysis; break; } } break; } } if (analysisSpecific) { analysisSpecific.solve(); // Solve the identified specific analysis } else { // Optional: Add logging or error handling if the specified analysis is not found Log.write ('Error: Specified design study or analysis not found.'); } // save project Project.save({ file: '%1%_solved.ssp'}); setOptions-
- Sets options to pick the number of cores to use for the solution
Parameters:Name Type Accepted Values Default Value numOfCoresToUse Number All available cores Syntax://Set number of logical cores for the solution Project.setOptions({ numOfCoresToUse: 12 });
3. Design Study Object
The design study object represents the current analysis study in SimSolid. It provides functions to define and modify various aspects of your simulation, such as applying materials, defining connections, and setting up loads and boundary conditions.
Functions
applyMaterial- Applies a specified material to one or more parts within the current
design studyParameters:
Table 4. Name Type Accepted Values Default Value material String Name of a defined material in SimSolid NA partNameMask String Wildcard pattern (for example, 'Part 1', '*plate*', '*') ‘*’ partNameMaskDelimiter String Any single character (for example, ',' ';' ' ') ',' Note:- Ensure the material is already available in the SimSolid material library or defined within the project.
- A mask (pattern) is used to identify the parts to which the material will be applied. Wildcard characters (*) are supported. Use * to apply to all parts.
- The delimiter character used to separate multiple
partNameMaskentries when applying material to a specific set of parts. By default, a comma (,) is used.
Example:- Applying common material to all parts in the
assembly
study.applyMaterial({ material: 'Aluminum', partNameMask: '*' }); - Applying different material to parts in the
assembly
// Apply 'Steel' to a part exactly named 'plate 1' study.applyMaterial({ material: 'Steel', partNameMask: 'plate 1' }); // Apply 'Rubber' to parts named 'plate 2' and 'plate 4' // The default delimiter (comma) is used here. study.applyMaterial({ material: 'Rubber', partNameMask: 'plate 2, plate 4' }); // Apply 'Nickel' to parts named 'plate 3' and 'plate 5' // Explicitly setting the delimiter, though not strictly necessary here as it's the default. study.applyMaterial({ material: 'Nickel', partNameMask: 'plate 3, plate 5', partNameMaskDelimiter: ',' });
Tip:- Case sensitivity:
SimSolid part names are
typically case-sensitive. Ensure
partNameMaskmatches the exact capitalization of your part names in the Assembly Tree. - Wildcard usage:
'Part*' will match 'Part A', 'Part B', 'Particle'
'*Bolt*' will match 'Front Bolt', 'Bolt 123', 'Hex Bolt'
'Plate 1' will only match a part exactly named 'Plate 1'
- Material library: Before using
applyMaterial, ensure the specified material name exists in your SimSolid material library.
addConnections- Creates regular connections automatically between all
partsParameters:
Table 5. Name Type Accepted Values Default Value gap Number Any positive numerical value Calculated based on geometry penetration Number Any positive numerical value Calculated based on geometry resolution String ‘normal, ‘increased’, ‘high’ ‘normal’ units Object Same as for setDefaultUnits Taken from the Project level Description:- Gap and penetration: This defines the maximum allowable gap or overlap between faces for connection. SimSolid can auto-calculate this but adjust it if parts are not connecting as expected or if unwanted connections form.
- Resolution: This controls how sensitive the connection detection is. Higher settings (increased, high) find more subtle connections but increase processing time. Normal is good for most cases; High is for fine details or complex geometries.
- Units: This specifies the units for the gap and penetration parameters, primarily using the length property. If not specified, project-level length units are used. Refer to setDefaultUnits documentation for accepted unit properties.
Example:// Automatically find all connections study.addConnections({ gap: 0.1 penetration: 0.2 resolution: 'normal', units: { length: 'mm' } });Tip:- Review connections: After running
addConnections, always review the created connections in the SimSolid user interface. - Adjust parameters for missing
connections: If you notice that expected
connections are not being formed,
consider:
- Increasing gap: If parts are slightly separated.
- Increasing penetration: If parts are slightly overlapping.
- Increasing resolution to Increased or High: Only increase resolution for very small features or complex interfaces. Be aware that higher resolution can increase processing time.
- Units consistency: Be aware of the units used, especially when manually specifying gap and penetration values. Ensure the units align with the model's geometry and the units parameter.
hasDisconnectedGroupsOfParts- Checks if there are more than one disconnected group of
partsSyntax:
study.hasDisconnectedGroupsOfParts()Example:
Checking for disconnected groups before performing a modal analysis:
This example demonstrates a common use case: usinghasDisconnectedGroupsOfPartsas a conditional check before proceeding with a modal analysis. If parts are disconnected, a modal analysis might incorrectly show rigid body modes or fail to solve.// Check if there are any disconnected groups of parts if (!study.hasDisconnectedGroupsOfParts()) { // If no disconnected groups are found (i.e., returns false), proceed with analysis setup // Create a modal analysis object with 9 modes to find var analysis = study.addModalAnalysis({ numOfModes: 9 }); // Set global and local solution settings for the analysis analysis.setSolutionSettings({ adaptation: 'global+local', // Define the solution adaptation method }); // Add a specific solution settings group for parts matching 'PLATE*' analysis.addSolutionSettingsGroup({ partNameMask: 'PLATE*', // Apply these settings to parts whose names start with 'PLATE' adaptToFeatures: true, // Enable adaptation around geometric features adaptToThinSolids: true, // Enable adaptation for thin-solid geometries refinement: 'standard' // Set refinement level to standard }); // Attempt to solve the analysis if (analysis.solve()) { // If the analysis solves successfully // Import a set of datum points from a CSV file var datumPointSet = study.addDatumPointSet({ file: 'D:/Batch mode/Modal_Analysis/DatumPoints_Bar.csv', units: { length: 'mm' } // Specify units for the imported points }); // Export analysis results to a UNV file analysis.exportToUNV({ file: 'D:/Batch mode/Modal_Analysis/DatumPoints_Bar.unv', datumPointSet: datumPointSet // Include the imported datum points in the export }); // Save the current project state to an .ssp file Project.save({ file: 'D:/Batch mode/Modal_Analysis/Pullup bar.ssp' }); } else { // If analysis fails to solve this.errorCode = 2; // Custom error code indicating analysis failure } }else { // If disconnected groups are found (i.e., returns true) this.errorCode = 1; // Custom error code indicating disconnected parts issue }Tip:- Pre-analysis check: Always include
hasDisconnectedGroupsOfPartsin the batch scripts or automation workflows as a crucial pre-analysis check. This can prevent wasted computational time on models that are fundamentally ill-defined due to connectivity issues. - Troubleshooting disconnections: If
hasDisconnectedGroupsOfPartsreturns true, it indicates a problem with your connections. One should:- Review connections in the SimSolid GUI: Visually inspect the assembly and the connections display.
- Adjust
addConnectionsparameters: If you are usingaddConnectionsfor automatic connection generation, try modifying gap, penetration, or resolution to capture missing connections.
- Error handling: The example demonstrates using
errorCodeto signal whether disconnected groups were found or if the analysis failed. Implementing robust error handling is crucial for automated workflows.
- Pre-analysis check: Always include
addModalAnalysis-
- Creates a new modal analysis
- Returns the analysis object
Parameters:Table 6. Name Type Accepted Values Default Value numOfModes Number Syntax:// create a modal analysis var analysis = study.addModalAnalysis({ numOfModes: 9 }); addDatumPointSet- Imports datum points from a .csv file and returns the datum point set
objectParameters:
Table 7. Name Type Accepted Values Default Value file String Path to a CSV file units Object Same as for setDefaultUnits Taken from the Project level Syntax:// import datum points var datumPointSet = study.addDatumPointSet({ file: ‘<File_path>/<File_name>.csv', units: {length: 'mm'} }); addStructuralAnalysis- Creates a new structural analysis and returns the analysis
objectParameters:
Table 8. Name Type Accepted Values Default Value type String 'multiload' Syntax:// create a multi-loadcase structural analysis var analysis = study.addStructuralAnalysis({ type: 'multiload' }); getName-
- Returns the name of the design study
- This is primarily used when solving a specific design study or analysis.
getAnalyses-
- Returns the collection of all analysis objects
- This helps to gather all the analysis under a particular design study.
Example:
This script demonstrates how to target and solve a particular analysis within a designated design study using the API –getNameandgetAnalysis.// open project Project.open({ file: D:/Batchmode/ fin2.ssp}); //Set number of logical cores for the solution Project.setOptions({ numOfCoresToUse: 12 }); // Adjust to your desired number of cores // run specific analysis var analysisSpecific = null; for (var study of Project.getDesignStudies()) { if (study.getName() == 'Design study 1') { // Specify the exact name of your design study for (var analysis of study.getAnalyses()) { if (analysis.getName() == 'Modal 1') { // Specify the exact name of your analysis analysisSpecific = analysis; break; } } break; } } if (analysisSpecific) { analysisSpecific.solve(); // Solve the identified specific analysis } else { // Optional: Add logging or error handling if the specified analysis is not found Log.write ('Error: Specified design study or analysis not found.'); } // save project Project.save({ file: '%1%_solved.ssp'});The above script performs a series of actions namely - opens an SSP file, runs Modal 1 analysis in Design study 1, and saves the SSP by appending _solved to the original file name.
addGravityLoad- Apply gravity load for the specific loadcase under
multi-loadcase
structural
analysis.
Example:
This script demonstrates how to apply Gravity load to a loadcase under multi-loadcase analysis in three methods.- Add a gravity load to the load case directly.
- Add a gravity load to the load case via analysis by load case name.
- Find the load case by the name and add a gravity load to that load case.
// create a new design study var study = Project.addDesignStudy({ file: 'C:/Users/Batchmode/Pullup bar V1.x_t', reader: 'parasolid', resolution: 'standard' }); // apply material to all parts study.applyMaterial({ material: 'Steel', partNameMask: '*' }); //partNameMask: // find all connections automatically study.addConnections({ resolution: 'normal', //units: { length: 'mm' } }); // take the first design study //var study = Project.getDesignStudies()[0]; // create a new multi-load analysis var analysis = study.addStructuralAnalysis({ type: 'multiload'}); // set global+local solution settings analysis.setSolutionSettings({ adaptation: 'global+local', }); // create a new load case 1 var loadCase = analysis.addLoadCase(); // Option 1 - add a gravity load to the load case directly loadCase.addGravityLoad({ direction: [0.2, 0.5, 0], factor: 10 }); // add constraint and loads analysis.importSpotDisplacements({ file: 'C:/Users/Batchmode/spot_displacement.csv'}); analysis.importRemoteLoads({ file: 'C:/Users/Batchmode/import_loads.csv'}); // Option 2 - add a gravity load to the load case via analysis by load case name analysis.addGravityLoad({ direction: [0.5, 0.5, 0], factor: 4, loadCaseName: 'Vertical' }); analysis.addGravityLoad({ direction: [0.5, 0.6, 0], factor: 8, loadCaseName: 'Horizontal' }); // Option 3 - find the load case by the name and add a gravity load to that load case for (var loadCase of analysis.getLoadCases()) { if (loadCase.getName() == 'Vertical_right') loadCase.addGravityLoad({ direction: [0, 0, -1], factor: 2 }); } for (var loadCase of analysis.getLoadCases()) { if (loadCase.getName() == 'Horizontal_Right') loadCase.addGravityLoad({ direction: [0, 0, 1], factor: 3 }); } // solve if (analysis.solve()) { //import datum points var datumPointSet = study.addDatumPointSet({ file: 'C:/Users/Batchmode/DatumPoints_Bar.csv', units: {length: 'mm'} }); analysis.exportToCSV({ file: 'C:/Users/Batchmode/gravity_test_result_datum_points.csv' , datumPointSet: datumPointSet}); Project.exportToCSV({ file: 'C:/Users/Batchmode/gravity_export_results.csv', maxVonMises: true, maxDisplacement: true }); Project.save({ file: 'C:/Users/Batchmode/Pullup_bar_gravity_results.ssp' }); } else this.errorCode = 2; // error code if analysis fails
getDatumPointSets- Returns the collection of all datum point set objects
addParts-
- Import new parts into the design study
- Can add new connections automatically
Parameters:Table 9. Name Type Accepted Values Default Value file String Path to a CAD file reader String 'parasolid', 'ct', 'parasolid+spatial' 'parasolid' resolution String 'standard', 'enhanced', 'fine', 'custom' 'standard' angularDev Number '15.0', 'deg' chordalDev Number '0.5', 'mm' units Object Same as for setDefaultUnits Taken from the Project level addConnections Boolean 'true', 'false' 'false' connGap Number Calculated based on geometry connPenetration Number Calculated based on geometry connResolution String 'normal', 'increased', 'high' 'normal' Example://import part in assembly study.addParts({ file: D:/Batchmode/plate_1.x_b', reader:'parasolid', resolution:'fine', addConnections:true, connGap:2, connPenetration: 2}); deleteParts-
- Delete specific parts from the design study
- To set multiple masks the delimiter specified by partNameMaskDelimiter is used, for example, partNameMask: ‘Part 1, Part 2’.
Parameters:Table 10. Name Type Accepted Values Default Value partNameMask String partNameMaskDelimiter String Example:// delete part from assembly study.deleteParts({partNameMask: 'plate 1'}); Project.save({ file: ' D:/Batchmode//3_plates_part_delete.ssp' })
Geometry Defect Check Functions
With the below API user can check for geometry defects upon importing the file and write a CSV file for faceting defects, part overlaps and self-intersections. User can define the file name for each one and depending upon the number of design studies it will generate CSV files.
study.checkGeometryForDefects- Check geometry defects for faceting defects.
study.checkGeometryForOverlaps- Check geometry defects for part overlaps.
study.checkGeometryForSelfIntersections- Check geometry defects for parts
self-intersection.Example:
//open project Project.open({ file: '<File_Directory>/example.ssp'}); var counter = 1; Project.getDesignStudies().forEach(study => { study.checkGeometryForDefects({ file: '<File_Directory>/geometry_defects_test' + counter + '.csv' }); study.checkGeometryForOverlaps({ file: '<File_Directory>/geometry_overlaps_test' + counter + '.csv' }); study.checkGeometryForSelfIntersections({ file: '<File_Directory>/geometry_selfintersects_test' + counter + '.csv' }); counter++; }); Project.save({ file: ‘<File_Directory>/example_saved.ssp' });
Export Results Function
Exporting the max displacement and max Von misses results from the solved project to a CSV file.
Currently supported for structural linear and multi-load case analysis. CSV file can output co-ordinates, displacement, stress, strain and strain energy density at those coordinates. It will also write Part ID, Part name, analysis name and design study.
maxVonMisesandmaxDisplacement-
Example:
•Option 1 - export all analyses from all design studies to a single file Project.exportToCSV({ file: <File_Directory> /All_analysis.csv', maxVonMises: true, maxDisplacement: true });•Option 2 - export all analyses from all design studies into one file per design study var counter = 1; Project.getDesignStudies().forEach(study => { study.exportToCSV({ file: ‘<File_Directory>/structural_output_per_ds' + (counter++) + '.csv', maxVonMises: true, maxDisplacement: true }); });•Option 3 - export all analyses from all design studies into one file per analysis var counter = 1; Project.getDesignStudies().forEach(study => { study.getAnalyses().forEach(analysis => { analysis.exportToCSV({ file: '<File_Directory>/sequential ' + (counter++) + '.csv', maxVonMises: true, maxDisplacement: true }); }); });
4. Analysis Object
The analysis object is a crucial part of the SimSolid scripting environment, primarily responsible for managing the project-level settings and the creation of design studies.
Functions
setDefaultUnits-
- Sets the default units to be used throughout the project
- This function helps maintain consistency and avoids the need to specify units repeatedly for each individual operation.
Parameters:Table 11. Name Type Accepted Values Default Value length String ‘mm’, ‘cm’, ‘m’, ‘in’ ‘mm’ angle String ‘deg’, ‘rad’ ‘deg’ force String 'N', 'lbf', 'kip' 'N' moment String 'N*m', 'N*mm', 'lbf*in' 'N*m' Example:// Set default units for the project Project.setDefaultUnits ({ length: 'cm', force: 'N' }); addDesignStudy-
- Creates a new design study by importing geometry from a CAD file and returns the Design Study object
Parameters:Table 12. Name Type Accepted Values Default Value file String Path to a CAD file reader String ‘parasolid’, ‘ct’, 'parasolid+spatial' ‘parasolid’ resolution String ‘standard’, ‘enhanced’, ‘fine’, ‘custom’ ‘standard’ geomType String 'solids+skins', 'solids', 'skins' 'solids+skins' angularDev Number 15.0, deg chordalDev Number 0.635, mm units Object Same as for setDefaultUnits Taken from the Project level Example:// create a new design study var study = Project.addDesignStudy({ file: 'D:/Batch mode/Modal_Analysis/Pullup bar V1.step', reader: ‘ct’, //ct is the SimSolid legacy reader resolution: 'custom', angularDev: 12, chordalDev: 0.5, units: { length: 'cm', force: ‘N’ } }); save-
- Saves the project into .ssp and returns false if it fails
Parameters:Table 13. Name Type Accepted Values Default Value file String Path to a .ssp file. NA Syntax:Project.save ({ file: ‘<File_path>/<File_name>.ssp' });