The following example can be used as a basis of either the solve or evaluate script.
#we need to use arrays for the ElementsByIds and NodesByIds methods
from System import Array
def runClassDemo_MeshData():
MeshDataObject = DesignAssessment.MeshData #Get the MeshData object
#Output some data to the debug log file.
print "Number of Nodes = " + str(MeshDataObject.NodeCount)
print "Number of Elements = " + str(MeshDataObject.ElementCount)
#Loop around all element objects.
for ElementIterator in MeshDataObject.Elements():
print "ElementId = " + str(ElementIterator.Id)
#Three ways of getting elements.
#It can not be assumed that Element Ids start at 1 and are contiguous
Elements = MeshDataObject.Elements()
FirstElementId = Elements[0].Id
ByIdMethodElement = MeshDataObject.ElementById(FirstElementId)
# print true if they are the same Id.
print str(FirstElementId == ByIdMethodElement.Id)
# Create an Array so we can iterface with the .NET code
ElementIdArray = Array[int]([FirstElementId,MeshDataObject.Elements()[1].Id])
print ElementIdArray
#Pass the array into the ElementsById method.
ByIdArrayMethodElement = MeshDataObject.ElementsByIds(ElementIdArray)
# print true if they are the same Id.
print str(FirstElementId == ByIdArrayMethodElement[0].Id)
#Three ways of getting nodes.
#It can not be assumed that Node Ids start at 1 and are contiguous
Nodes = MeshDataObject.Nodes()
FirstNodeId = Nodes[0].Id
ByIdMethodNode = MeshDataObject.NodeById(FirstNodeId)
# print true if they are the same Id.
print str(FirstNodeId == ByIdMethodNode.Id)
# Create an Array so we can iterface with the .NET code
NodeIdArray = Array[int]([FirstNodeId,MeshDataObject.Nodes()[1].Id])
print NodeIdArray
#Pass the array into the NodesById method.
ByIdArrayMethodNode = MeshDataObject.NodesByIds(NodeIdArray)
# print true if they are the same Id.
print str(FirstNodeId == ByIdArrayMethodNode[0].Id)
runClassDemo_MeshData()