Expanding the Example

The example given was for a scalar, elemental result. However, if the result required was say a nodal, vector based result, then this example could easily modified by changing a few lines in the evaluate script.

Assume that the CSV file contains a first column for the node Id, then 3 columns for X, Y, Z components of the vector.

Then, these lines where it previously used SetElementValue:

DAResultSet = DAResult.CreateDAResultSet("Scalar","Elemental")

#2a - For each element set the value.
for Element in DA.MeshData.Elements():
    DAResultSet.SetElementalValue(Element.Id,1,IDToDataDict[Element.Id][ColIndex])

Would change to the following, using the SetNodalValue function:

DAResultSet = DAResult.CreateDAResultSet("Vector","Nodal")

#2a - For each element set the value.
for Node in DA.MeshData.Nodes():
    DAResultSet.SetNodalValue(Node.Id,1,IDToDataDict[Node.Id][0])
    DAResultSet.SetNodalValue(Node.Id,2,IDToDataDict[Node.Id][1])
    DAResultSet.SetNodalValue(Node.Id,3,IDToDataDict[Node.Id][2])

Alternatively, if the CSV file was always of this NodeId, X, Y, Z format, and given that this is converted into a dictionary of arrays using the Node Id as the key, then the SetNodalValues function could be used instead:

DAResultSet = DAResult.CreateDAResultSet("Vector","Nodal")

#2a - For each element set the value.
for Node in DA.MeshData.Nodes():
    DAResultSet.SetNodalValues(Node.Id,IDToDataDict[Node.Id])

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