Introduction
The script feature in ShapeBuilder is a powerful tool used to add and modify shapes, apply loads, extract results, generate reports etc. using a command line interface. In addition to supporting the various Commands outlined in this Help File, the command line will accept any valid command in the C# Programming language (allowing the use of if statements, for loops, etc.). In addition to using the command line directly, more complex Scripts can be generated in any text file and read into the program. This allows shapes with complex geometry to be created, parametric studies to be performed, finite element meshes to be automatically refined until convergence, batch processing of CAD files, etc.
Command Line Basics
- Location
- The Script tool is accessed by clicking the Scripting button in the Home ribbon.
- Units
- Input and output are always in the current unit style. The style can be changed from the command line.
- Import CAD
- There are various options available when importing CAD files from the command line (see the Commands page for a complete list of the available parameters that the ImportCAD() command can accept). Note: Paths must be enclosed in quotes and must contain forward slashes (/) not backslashes (\).
- Add Shapes
- Add any of the simple, rolled, and bent parametric shapes to the model from the command line (see the Commands page for a complete list of the available parametric shapes). The PickDatabaseSection() command can be used to launch the Shape Database dialog box to choose a shape from the database.
- The return value can be suppressed by using a semi-colon on at the end of the command.
- Information can be stored in variables and math can be performed in the command line. Variables circumvent the need to input the same number repeatedly. The example below uses variables and math in the command line to define the height and width of the first rectangle which is then scaled to create the second rectangle. Note: When storing a value in a variable, the line must end with a semicolon.
- A shape can be added to the model from lists of the X and Y coordinates.
- Modify Shapes
- Selection: Specific shapes can be selected using the Select() call. Note: Shapes and other item names must be enclosed in quotes. The SelectAllShapes() call selects every shape in the model.
- Delete: The selected shapes can be removed using the DeleteSlected() command or specific shapes can be deleted by name.
- Move & Rotate: Shapes can be moved and rotated to a certain value or by a certain value using the command line.
- Set Material: The material can be set for a specific shape and the base material can be defined for the model. The PickMaterial() command can be used to launch the Material Database to choose a material if its exact name is unknown.
- Apply Loads & Mesh Refinement
- Normal force, shear forces, moments, and torsion can be applied to the cross-section using coordinate systems (see the Commands page for a complete list).
- The finite element mesh size can be set from the command line. Note: The mesh refinement is exponential where 0 = coarse and 10 = fine..
- Obtain Results
- The various section properties can be obtained directly using the command line.
- The maximum or minimum values for the various stresses and the warping function can obtained directly using the command line.
- Reports
- Add Tables: The various tables can be added to the report via the command line.
- Export Reports: Reports can be exported to a specified location.
- Append Results: The section properties can be added to text file at a specified path.
- Miscellaneous
- Integer Math: In the command line, the quotient of two integers is an integer which may not produce the intended result. See the C# Numeric Types Tutorial for more information.
C# Programming
The command line accepts any valid command in the C# Programming Language, allowing the use of if statements, for loops, etc. In the example below, a command is defined to describe the y coordinate of a parabola terms of x. The Pow(Double, Double) method of the .Net System Math Class is used to perform squared operation. A four loop is used to add the x and y coordinates of the shape to lists which are then used to define the shape. In addition to using the command line to program directly, more complex Scripts can be generated in any text file and read into the program.