Mechanical Worksheets

This section describes how to use the ACT API to automate the creation of worksheets in Mechanical. ACT enables you to create and populate worksheets by entering commands into the ACT Console and executing them in Mechanical. For more information, see ACT Console.

The following examples are used to illustrate worksheet capabilities in ACT:

Named Selection Worksheets

This section describes how to use the ACT API to automate the creation of a named selection worksheet in Mechanical. It assumes that the Scoping Method for your named selection is already set to Worksheet.

ACT supports all available actions for named selection worksheets, as described in Specifying Named Selections Using Worksheet Criteria in the ANSYS Mechanical User’s Guide. This example focuses on the Add Row action to add new geometric entities to a named selection.

Creating the Named Selection Worksheet

To create the named selection worksheet, execute the following commands in the ACT Console:

model = ExtAPI.DataModel.Project.Model
sel = model.AddNamedSelection()
sel.Name = "Pipe"
selws = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.WorksheetSpecific)
sel.Location = selws
pipews = sel.Location

This creates the named selection object, renames it Pipe, and creates the worksheet for your named selection.

Adding New Rows

Data in the named selection worksheet defines the criteria based on geometric or meshing entities. Each row of the worksheet performs a calculation for the specified criteria.

The command AddRow adds worksheet rows according to the standard behavior of the Add option in Mechanical named selection worksheets. It adds the information defined in the current row to information in the previous row, provided that the Entity Type is the same for both rows.

To add the first row in your worksheet, you execute these commands:

pipews.AddRow()
pipews.SetEntityType(0,NamedSelectionWorksheetEntityType.Body)
pipews.SetCriterion(0,NamedSelectionWorksheetCriterion.Size)
pipews.SetOperator(0,NamedSelectionWorksheetOperator.GreaterThan)
pipews.SetValue(0,3.8e-5)
pipews.Generate()

This example uses set methods to define a Body with a Size value greater than 3.8e-5.

The method Generate generates the body. After executing this method, the pipe body is selected in the Graphics view. In Details, the property Total Selection is set to 1 Body.

Next, you define and generate another body:

pipews.AddRow()
pipews.SetEntityType(1,NamedSelectionWorksheetEntityType.Body)
pipews.SetCriterion(1,NamedSelectionWorksheetCriterion.Size)
pipews.SetOperator(1,NamedSelectionWorksheetOperator.LessThan)
pipews.SetValue(1,8e-6)
pipews.Generate()

In this row, set methods define a Body with a Distance value less than 3.8e-6. When there are no locally defined coordinate systems, you don’t need to set the Coordinate System value. It is set to Global Coordinate System by default.

After executing the method Generate, the bolt body is now selected in the Graphics view, along with the pipe body. In Details, the property Total Selection is set to 2 Bodies.

Mesh Order Worksheets

This section describes how to use the ACT API to add rows to an existing mesh worksheet, specifying the order in which meshing steps are performed in Mechanical.

ACT supports most of the functionality available for mesh worksheets, which is described in Using the Mesh Worksheet to Create a Selective Meshing History in the ANSYS Meshing User’s Guide. The following exceptions apply:

  • The named selections must have Entity Type set to Body. Other entity types are not supported.

  • The Start Recording and Stop Recording buttons are not supported.

This section assumes that you have already defined two or more named selections in Mechanical. In your sample Static Structural analysis, you’ve defined three named selections, as shown in the following figure:

Displaying the Mesh Worksheet

To display the mesh worksheet, perform the following steps:

  1. Select the Mesh node in the tree.

  2. Click the Worksheet toolbar button.

The empty worksheet is displayed in the Worksheet tab.

Specifying the Mesh Worksheet and Named Selections

Next, you need to define variables for the mesh worksheet and the named selections to use in the worksheet rows:

model = ExtAPI.DataModel.Project.Model 
msh = model.Mesh 
mws = msh.Worksheet  
nsels = model.NamedSelections 
ns1 = nsels.Children[0]  
ns2 = nsels.Children[1] 
ns3 = nsels.Children[2]
Adding New Rows

Finally, you add new rows to the mesh worksheet. Each row in the worksheet corresponds to a step in the meshing sequence.

To add the first row to your worksheet, you execute these commands:

mws.AddRow()
mws.SetNamedSelection(0,ns1) 
mws.SetActiveState(0,True)
  • The command AddRow adds an empty row.

  • The command SetNamedSelection sets the Named Selection value to your named selection object ns1.

  • The command SetActiveState sets the property Active State at the row index (enables the row, as indicated by the check mark in the left column).

The following image shows the mesh worksheet after the execution of these commands.

Next, you add rows for your other two named selections, ns2 and ns3. Note that for ns3, you use the command SetNamedSelectionID to set the named selection.

mws.AddRow() 
mws.SetNamedSelection(1,ns2) 
mws.SetActiveState(1,True)
mws.AddRow()
mws.SetNamedSelectionId(2,ns3.Id)
mws.SetActiveState(2,True)

The following image shows the mesh worksheet after the two new rows have been added:

Meshing the Named Selections

When you check the Graphics tab, you can see that no mesh has been generated yet. To generate the mesh for the named selections in the mesh worksheet, execute the following command:

mws.GenerateMesh()

When you execute this command, the steps are processed one by one in the order specified by the worksheet. For each step, the bodies identified by the named selection are meshed using the meshing controls applied to them. By watching the mesh generation in the Graphics tab, you can see the order in which each body is meshed.

Additional Commands
Clear the Generated Mesh

To clear the generated mesh, execute the following command:

mws.ClearGenerateMesh()
Delete a Row

To delete a single row, execute the following command:

void DeleteRow(int index)
Delete All Rows

To delete all rows, execute the following command:

mws.DeleteAllRows()
Get Row Count

To display the row count in the ACT Console command history, execute the following command:

mws.RowCount

Layered Section Worksheets

This section describes how to use the ACT API to access the worksheet for a layered section definition in Mechanical. It assumes that you've already created a layered section and set the property Layers to Worksheet.

Displaying the Layered Section Worksheet

To display the layered section worksheet in Mechanical, perform the following steps:

  1. In the Project tree, expand the Geometry node and select the Layered Section node.

  2. In the details of the layered section, select the Layers property.

  3. To the right of the Worksheet selection for this property, click the right arrow and select Worksheet.

The layered section worksheet is displayed in the Worksheet tab.

Getting the Layered Section Worksheet and Its Properties

To get to the layered section worksheet object in the ACT Console, enter:

mymodel = ExtAPI.DataModel.Project.Model 
geo = mymodel.Geometry 
ls = geo.Children[1]  
lsws = ls.Layers
Getting and Displaying the Material Property

To get and display the material property for layer index 2, enter:

lsmat = lsws.GetMaterial(2)
lsmat

Assume that Structural Steel displays as the material property.

Getting and Displaying the Thickness Property

To get and display the thickness property for layer index 2, enter:

lsthick = lsws.GetThickness(2)
lsthick

Assume that 0.00253999746 displays as the thickness property.

To get and display the thickness property for a different layer index, such as layer index 3, enter:

lsws.GetThickness(3)

Assume that 0.004 displays as the thickness property.

Getting and Displaying the Angle Property

To get and display the angle property for layer index 2, enter:

lsang = lsws.GetAngle(2)
lsang

Assume that 45 displays as the angle property.

Setting and Displaying the Thickness Property

To set the thickness property for layer index 2 to 0.0999999 and display this value, enter:

lsthick = lsws.SetThickness(2,0.0999999)
lsthick = lsws.GetThickness(2)
lsthick

The thickness property then displays as 0.0999999.

Setting and Displaying the Angle Property

To set the angle property for layer index 2 to 22.5 and display this value, enter:

lsang = lsws.SetAngle(2,22.5)
lsang = lsws.GetAngle(2)
lsang

The angle property then displays as 22.5.

Bushing Joint Worksheets

This section describes how to use the ACT API to access the bushing joint worksheet for Mechanical. A bushing joint worksheet defines stiffness and damping coefficients via symmetric matrices. This section assumes that you’ve already created a bushing joint worksheet.

Displaying the Bushing Joint Worksheet

To display the worksheet for a bushing joint in Mechanical, perform the following steps:

  1. In the Project tree, expand the Connections node and then the Joints node.

  2. Select the node for the bushing joint.

  3. To the right of the Worksheet selection for this property, click the right arrow and select Worksheet.

The worksheet for the bushing joint displays in the Worksheet tab. The size of the matrices for stiffness and damping coefficients are fixed, which means that rows and columns cannot be added or deleted. Another aspect of these square matrices (6x6) is that they are both symmetric about their main diagonals. To ensure that these matrices are always symmetric, you cannot enter values into their upper right corners.

Getting the Bushing Joint Worksheet and Its Properties

To get to the bushing joint worksheet object in the ACT Console, enter:

mymodel = ExtAPI.DataModel.Project.Model 
joints = mymodel.Connections.Children[1]
bushing = joints.Children[0]
bws = bushing.BushingWorksheet
Getting the Value for a Specified Unit

The ACT API for a bushing joint worksheet enforces the fixed matrices by limiting the range of indices that can be specified to set or get the value from a particular cell. The row indices are zero-based.

For example, to get the coefficient for the stiffness per unit Y at row index 1, enter:

bws.GetBushingStiffnessPerUnitY(1)

Assume that 136073.550978543 displays as the stiffness per unit Y.

Now, assume you’ve entered the following:

bws.GetBushingStiffnessPerUnitZ(0)

The given index of 0 (zero) produces an error because that cell lies above the main diagonal. As indicated by the error message, the valid range of indices is equal to 2 and less than or equal to 5.

The following image displays some of the many methods available for getting coefficients for damping and stiffness.

 


Release 18.2 - © ANSYS, Inc. All rights reserved.