<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">
<div style="font-family: Times New Roman; color: #000000; font-size: 16px"><br>
<div></div>
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Hello,<br>
<br>
I am trying to simply add up all the values of a variable in the CTH dataset using programmable filter with the python code at the end of this email..<br>
<br>
The code seems to be working for the other dataset that I worked in the past. But for CTH dataset, it is giving me an error with GetCellData<br>
<br>
<style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#800000;">Traceback (most recent call last):</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#800000;">File "<string>", line 22, in <module></span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#800000;">File "<string>", line 43, in RequestData</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#800000;">File "<string>", line 8, in calculateSum</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#800000;">AttributeError: GetCellData</span></p>
<br>
When I printed the output for CTH dataset it is giving me <br>
<br>
<style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">vtkNonOverlappingAMR (0x7f96ca7675c0)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Debug: Off</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Modified Time: 860345754</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Reference Count: 2</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Registered Events: (none)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Information: 0x7f96ca767040</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Data Released: False</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Global Release Data: Off</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">UpdateTime: 856914636</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Field Data:</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Debug: Off</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Modified Time: 855459763</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Reference Count: 1</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Registered Events: (none)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Number Of Arrays: 4</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Array 0 name = GlobalBounds</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Array 1 name = GlobalBoxSize</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Array 2 name = MinLevel</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Array 3 name = MinLevelSpacing</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Number Of Components: 4</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" font-family:'Courier'; font-size:9pt; color:#008000;">Number Of Tuples: 6</span></p>
<br>
Any help is in adding a variable in a CTH dataset is much appreciated.<br>
<br>
thank you<br>
-simon<br>
<br>
p/s: sorry for the other unfinished email sent....<br>
<br>
<br>
<br>
=========================================<br>
def calculateSum(input, output):<br>
    # Copy the cells etc.<br>
    output.ShallowCopy(input)<br>
<br>
    # Get the array to calculate the coefficient<br>
    toSum = output.GetPointData().GetArray("MOMENT_X")<br>
<br>
    # for each of the elements, calculate the three roots and store the real and imaginary output in separate arrays<br>
    numPoints = toSum.GetSize()<br>
<br>
    # create the output arrays<br>
    sum = vtk.vtkDoubleArray()<br>
    sum.SetNumberOfValues(numPoints)<br>
    sum.SetName("sum")<br>
    tsum = 0<br>
<br>
    for i in range(0, numPoints):<br>
        tsum = tsum + toSum.GetValue(i)<br>
<br>
    for j in range(0, numPoints):<br>
        sum.SetValue(j, tsum)<br>
<br>
    output.GetPointData().AddArray(sum)<br>
<br>
input = self.GetInputDataObject(0, 0)<br>
output = self.GetOutputDataObject(0)<br>
<br>
if input.IsA("vtkMultiBlockDataSet"):<br>
    output.CopyStructure(input)<br>
    iter = input.NewIterator()<br>
    iter.UnRegister(None)<br>
    iter.InitTraversal()<br>
    while not iter.IsDoneWithTraversal():<br>
        curInput = iter.GetCurrentDataObject()<br>
        curOutput = curInput.NewInstance()<br>
        curOutput.UnRegister(None)<br>
        output.SetDataSet(iter, curOutput)<br>
        calculateSum(curInput, curOutput)<br>
        iter.GoToNextItem();<br>
else:<br>
    calculateSum(input, output)<br>
</div>
</div>
</div>
</div>
</body>
</html>