Re: [Paraview] [EXT] Re: How to test for empty block in multi-block dataset

2017-10-18 Thread Andy Bauer
Glad to hear it works! A disclaimer -- I don't profess to write good Python
code, just mildly functional Python code :)

On Wed, Oct 18, 2017 at 2:11 PM, Dennis Conklin  wrote:

> Andy,
>
>
>
> That works!   Thanks much!
>
>
>
> Now I just have to add it to every filter I’ve ever written to protect
> them all against empty blocks!  I’m amazed it took this long for this to
> come up!
>
>
>
> Dennis
>
>
>
> *From:* Andy Bauer [mailto:andy.ba...@kitware.com]
> *Sent:* Wednesday, October 18, 2017 1:47 PM
>
> *To:* Dennis Conklin 
> *Cc:* Paraview (paraview@paraview.org) 
> *Subject:* Re: [EXT] Re: [Paraview] How to test for empty block in
> multi-block dataset
>
>
>
> Maybe try the following:
>
>if hasattr(block, "GetNumberOfCells") and block.GetNumberOfCells()
> > 0 and block.GetCellType(0)==12:
>
>   process_block(block)
>
>
>
> On Wed, Oct 18, 2017 at 1:05 PM, Dennis Conklin <
> dennis_conk...@goodyear.com> wrote:
>
> Andy,
>
>
>
> GetCellType works fine when I have cells in the block, but in this recent
> case I had zero cells in the block after a Threshold filter,   my code is
> of the form:
>
>
>
> Def process_block(block):
>
> Print block.GetNumberOfCells()
>
>
>
>
>
>
>
>
>
> ###
>
>
> # main routine starts here
>
> output.CopyStructure(inputs[0].VTKObject)
>
> # if you ShallowCopy, then new variables created in input to filter
>
> output.DeepCopy(inputs[0].VTKObject)
>
>
>
> #
>
> # Loop over blocks in composite (Exodus) data set
>
> for block in output:
>
>
>
># VTK element types:
>
># 12 = VTK_HEXAHEDRON (Gdyr Hex)
>
>#  9 = VTK_QUAD  (Gdyr Membrane)
>
>#  3 = VTK_LINE  (Gdyr 3D Truss)
>
># since EXODUS requires single element type per block, test 1st
> element only
>
>if block.GetCellType(0)==12:
>
>   process_block(block)
>
>
>
> I think GetCellType is dying as there is no element(0)
>
> I need a way to test the block before calling anything to see if it is
> empty
>
>
>
> Thanks!
>
> Dennis
>
>
>
> *From:* Andy Bauer [mailto:andy.ba...@kitware.com]
> *Sent:* Wednesday, October 18, 2017 11:39 AM
> *To:* Dennis Conklin 
> *Cc:* Paraview (paraview@paraview.org) 
> *Subject:* Re: [EXT] Re: [Paraview] How to test for empty block in
> multi-block dataset
>
>
>
> Hi Dennis,
>
> Maybe the block isn't a vtkDataSet and thus wouldn't have the
> GetCellType() method. You could try a print statement after the for loop to
> see what each block is by doing something like:
>
> print block
>
>
>
> Could you share your full python code for the programmable filter? That
> may make it easier to track down.
>
>
>
> Best,
>
> Andy
>
>
>
> On Wed, Oct 18, 2017 at 11:01 AM, Dennis Conklin <
> dennis_conk...@goodyear.com> wrote:
>
> Andy,
>
>
>
> I’m not sure about the multiblock, my routines generally look like:
>
>
>
> For block in output:
>
>  If block.GetCellType(0)=12;
>
>process_block(block)
>
>
>
> would this be
>
>
>
> If input.GetBlock(i)
>
> And I might not have loaded all the blocks in the set, then I might have
> eliminated some loaded blocks with earlier operations – what is the i in
> GetBlock?  Is it block_number as displayed in Spreadsheet or block index as
> in:
>
>
>
> block_index = block.FieldData.GetArray(‘ElementBlockIds’) - 1
>
>
>
> Sorry for such a basic question, but I only know the stuff I have used
> previously.
>
>
>
> Dennis
>
>
>
> *From:* Andy Bauer [mailto:andy.ba...@kitware.com]
> *Sent:* Wednesday, October 18, 2017 10:44 AM
> *To:* Dennis Conklin 
> *Cc:* Paraview (paraview@paraview.org) 
> *Subject:* [EXT] Re: [Paraview] How to test for empty block in
> multi-block dataset
>
>
>
>  *WARNING - External email; exercise caution.*
>
>
>
> Hi Dennis,
>
> I think something like:
>
> if multiblock.GetBlock(i) != None:
>   ...
>
> should work. You probably don't even need the "!=None" part.
>
> Cheers,
>
> Andy
>
>
>
> On Wed, Oct 18, 2017 at 10:41 AM, Dennis Conklin <
> dennis_conk...@goodyear.com> wrote:
>
> P.S.  I’m writing python inside a Programmable Filter
>
>
>
> Thanks again
>
> Dennis
>
>
> ___
> Powered by www.kitware.com
> 
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
> 
>
> Please keep messages on-topic and check the ParaView

Re: [Paraview] [EXT] Re: How to test for empty block in multi-block dataset

2017-10-18 Thread Dennis Conklin
Andy,

That works!   Thanks much!

Now I just have to add it to every filter I’ve ever written to protect them all 
against empty blocks!  I’m amazed it took this long for this to come up!

Dennis

From: Andy Bauer [mailto:andy.ba...@kitware.com]
Sent: Wednesday, October 18, 2017 1:47 PM
To: Dennis Conklin 
Cc: Paraview (paraview@paraview.org) 
Subject: Re: [EXT] Re: [Paraview] How to test for empty block in multi-block 
dataset

Maybe try the following:
   if hasattr(block, "GetNumberOfCells") and block.GetNumberOfCells() > 0 
and block.GetCellType(0)==12:
  process_block(block)

On Wed, Oct 18, 2017 at 1:05 PM, Dennis Conklin 
mailto:dennis_conk...@goodyear.com>> wrote:
Andy,

GetCellType works fine when I have cells in the block, but in this recent case 
I had zero cells in the block after a Threshold filter,   my code is of the 
form:

Def process_block(block):
Print block.GetNumberOfCells()




###
# main routine starts here
output.CopyStructure(inputs[0].VTKObject)
# if you ShallowCopy, then new variables created in input to filter
output.DeepCopy(inputs[0].VTKObject)

#
# Loop over blocks in composite (Exodus) data set
for block in output:

   # VTK element types:
   # 12 = VTK_HEXAHEDRON (Gdyr Hex)
   #  9 = VTK_QUAD  (Gdyr Membrane)
   #  3 = VTK_LINE  (Gdyr 3D Truss)
   # since EXODUS requires single element type per block, test 1st element 
only
   if block.GetCellType(0)==12:
  process_block(block)

I think GetCellType is dying as there is no element(0)
I need a way to test the block before calling anything to see if it is empty

Thanks!
Dennis

From: Andy Bauer [mailto:andy.ba...@kitware.com]
Sent: Wednesday, October 18, 2017 11:39 AM
To: Dennis Conklin 
mailto:dennis_conk...@goodyear.com>>
Cc: Paraview (paraview@paraview.org) 
mailto:paraview@paraview.org>>
Subject: Re: [EXT] Re: [Paraview] How to test for empty block in multi-block 
dataset

Hi Dennis,
Maybe the block isn't a vtkDataSet and thus wouldn't have the GetCellType() 
method. You could try a print statement after the for loop to see what each 
block is by doing something like:
print block

Could you share your full python code for the programmable filter? That may 
make it easier to track down.

Best,
Andy

On Wed, Oct 18, 2017 at 11:01 AM, Dennis Conklin 
mailto:dennis_conk...@goodyear.com>> wrote:
Andy,

I’m not sure about the multiblock, my routines generally look like:

For block in output:
 If block.GetCellType(0)=12;
   process_block(block)

would this be

If input.GetBlock(i)
And I might not have loaded all the blocks in the set, then I might have 
eliminated some loaded blocks with earlier operations – what is the i in 
GetBlock?  Is it block_number as displayed in Spreadsheet or block index as in:

block_index = block.FieldData.GetArray(‘ElementBlockIds’) - 1

Sorry for such a basic question, but I only know the stuff I have used 
previously.

Dennis

From: Andy Bauer [mailto:andy.ba...@kitware.com]
Sent: Wednesday, October 18, 2017 10:44 AM
To: Dennis Conklin 
mailto:dennis_conk...@goodyear.com>>
Cc: Paraview (paraview@paraview.org) 
mailto:paraview@paraview.org>>
Subject: [EXT] Re: [Paraview] How to test for empty block in multi-block dataset

 WARNING - External email; exercise caution.



Hi Dennis,
I think something like:
if multiblock.GetBlock(i) != None:
  ...
should work. You probably don't even need the "!=None" part.
Cheers,
Andy

On Wed, Oct 18, 2017 at 10:41 AM, Dennis Conklin 
mailto:dennis_conk...@goodyear.com>> wrote:
P.S.  I’m writing python inside a Programmable Filter

Thanks again
Dennis

___
Powered by 
www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at:

Re: [Paraview] [EXT] Re: How to test for empty block in multi-block dataset

2017-10-18 Thread Andy Bauer
Maybe try the following:

   if hasattr(block, "GetNumberOfCells") and block.GetNumberOfCells() >
0 and block.GetCellType(0)==12:

  process_block(block)

On Wed, Oct 18, 2017 at 1:05 PM, Dennis Conklin  wrote:

> Andy,
>
>
>
> GetCellType works fine when I have cells in the block, but in this recent
> case I had zero cells in the block after a Threshold filter,   my code is
> of the form:
>
>
>
> Def process_block(block):
>
> Print block.GetNumberOfCells()
>
>
>
>
>
>
>
>
>
> ###
>
>
> # main routine starts here
>
> output.CopyStructure(inputs[0].VTKObject)
>
> # if you ShallowCopy, then new variables created in input to filter
>
> output.DeepCopy(inputs[0].VTKObject)
>
>
>
> #
>
> # Loop over blocks in composite (Exodus) data set
>
> for block in output:
>
>
>
># VTK element types:
>
># 12 = VTK_HEXAHEDRON (Gdyr Hex)
>
>#  9 = VTK_QUAD  (Gdyr Membrane)
>
>#  3 = VTK_LINE  (Gdyr 3D Truss)
>
># since EXODUS requires single element type per block, test 1st
> element only
>
>if block.GetCellType(0)==12:
>
>   process_block(block)
>
>
>
> I think GetCellType is dying as there is no element(0)
>
> I need a way to test the block before calling anything to see if it is
> empty
>
>
>
> Thanks!
>
> Dennis
>
>
>
> *From:* Andy Bauer [mailto:andy.ba...@kitware.com]
> *Sent:* Wednesday, October 18, 2017 11:39 AM
> *To:* Dennis Conklin 
> *Cc:* Paraview (paraview@paraview.org) 
> *Subject:* Re: [EXT] Re: [Paraview] How to test for empty block in
> multi-block dataset
>
>
>
> Hi Dennis,
>
> Maybe the block isn't a vtkDataSet and thus wouldn't have the
> GetCellType() method. You could try a print statement after the for loop to
> see what each block is by doing something like:
>
> print block
>
>
>
> Could you share your full python code for the programmable filter? That
> may make it easier to track down.
>
>
>
> Best,
>
> Andy
>
>
>
> On Wed, Oct 18, 2017 at 11:01 AM, Dennis Conklin <
> dennis_conk...@goodyear.com> wrote:
>
> Andy,
>
>
>
> I’m not sure about the multiblock, my routines generally look like:
>
>
>
> For block in output:
>
>  If block.GetCellType(0)=12;
>
>process_block(block)
>
>
>
> would this be
>
>
>
> If input.GetBlock(i)
>
> And I might not have loaded all the blocks in the set, then I might have
> eliminated some loaded blocks with earlier operations – what is the i in
> GetBlock?  Is it block_number as displayed in Spreadsheet or block index as
> in:
>
>
>
> block_index = block.FieldData.GetArray(‘ElementBlockIds’) - 1
>
>
>
> Sorry for such a basic question, but I only know the stuff I have used
> previously.
>
>
>
> Dennis
>
>
>
> *From:* Andy Bauer [mailto:andy.ba...@kitware.com]
> *Sent:* Wednesday, October 18, 2017 10:44 AM
> *To:* Dennis Conklin 
> *Cc:* Paraview (paraview@paraview.org) 
> *Subject:* [EXT] Re: [Paraview] How to test for empty block in
> multi-block dataset
>
>
>
>  *WARNING - External email; exercise caution.*
>
>
>
> Hi Dennis,
>
> I think something like:
>
> if multiblock.GetBlock(i) != None:
>   ...
>
> should work. You probably don't even need the "!=None" part.
>
> Cheers,
>
> Andy
>
>
>
> On Wed, Oct 18, 2017 at 10:41 AM, Dennis Conklin <
> dennis_conk...@goodyear.com> wrote:
>
> P.S.  I’m writing python inside a Programmable Filter
>
>
>
> Thanks again
>
> Dennis
>
>
> ___
> Powered by www.kitware.com
> 
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
> 
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
> 
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
> 
>
> Follow this link to subs

Re: [Paraview] [EXT] Re: How to test for empty block in multi-block dataset

2017-10-18 Thread Dennis Conklin
Andy,

GetCellType works fine when I have cells in the block, but in this recent case 
I had zero cells in the block after a Threshold filter,   my code is of the 
form:

Def process_block(block):
Print block.GetNumberOfCells()




###
# main routine starts here
output.CopyStructure(inputs[0].VTKObject)
# if you ShallowCopy, then new variables created in input to filter
output.DeepCopy(inputs[0].VTKObject)

#
# Loop over blocks in composite (Exodus) data set
for block in output:

   # VTK element types:
   # 12 = VTK_HEXAHEDRON (Gdyr Hex)
   #  9 = VTK_QUAD  (Gdyr Membrane)
   #  3 = VTK_LINE  (Gdyr 3D Truss)
   # since EXODUS requires single element type per block, test 1st element 
only
   if block.GetCellType(0)==12:
  process_block(block)

I think GetCellType is dying as there is no element(0)
I need a way to test the block before calling anything to see if it is empty

Thanks!
Dennis

From: Andy Bauer [mailto:andy.ba...@kitware.com]
Sent: Wednesday, October 18, 2017 11:39 AM
To: Dennis Conklin 
Cc: Paraview (paraview@paraview.org) 
Subject: Re: [EXT] Re: [Paraview] How to test for empty block in multi-block 
dataset

Hi Dennis,
Maybe the block isn't a vtkDataSet and thus wouldn't have the GetCellType() 
method. You could try a print statement after the for loop to see what each 
block is by doing something like:
print block

Could you share your full python code for the programmable filter? That may 
make it easier to track down.

Best,
Andy

On Wed, Oct 18, 2017 at 11:01 AM, Dennis Conklin 
mailto:dennis_conk...@goodyear.com>> wrote:
Andy,

I’m not sure about the multiblock, my routines generally look like:

For block in output:
 If block.GetCellType(0)=12;
   process_block(block)

would this be

If input.GetBlock(i)
And I might not have loaded all the blocks in the set, then I might have 
eliminated some loaded blocks with earlier operations – what is the i in 
GetBlock?  Is it block_number as displayed in Spreadsheet or block index as in:

block_index = block.FieldData.GetArray(‘ElementBlockIds’) - 1

Sorry for such a basic question, but I only know the stuff I have used 
previously.

Dennis

From: Andy Bauer [mailto:andy.ba...@kitware.com]
Sent: Wednesday, October 18, 2017 10:44 AM
To: Dennis Conklin 
mailto:dennis_conk...@goodyear.com>>
Cc: Paraview (paraview@paraview.org) 
mailto:paraview@paraview.org>>
Subject: [EXT] Re: [Paraview] How to test for empty block in multi-block dataset

 WARNING - External email; exercise caution.



Hi Dennis,
I think something like:
if multiblock.GetBlock(i) != None:
  ...
should work. You probably don't even need the "!=None" part.
Cheers,
Andy

On Wed, Oct 18, 2017 at 10:41 AM, Dennis Conklin 
mailto:dennis_conk...@goodyear.com>> wrote:
P.S.  I’m writing python inside a Programmable Filter

Thanks again
Dennis

___
Powered by 
www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: 
http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview


___
Powered by www.kitware.com

Visit other Kitw

Re: [Paraview] [EXT] Re: How to test for empty block in multi-block dataset

2017-10-18 Thread Andy Bauer
Hi Dennis,

Maybe the block isn't a vtkDataSet and thus wouldn't have the GetCellType()
method. You could try a print statement after the for loop to see what each
block is by doing something like:
print block

Could you share your full python code for the programmable filter? That may
make it easier to track down.

Best,
Andy

On Wed, Oct 18, 2017 at 11:01 AM, Dennis Conklin <
dennis_conk...@goodyear.com> wrote:

> Andy,
>
>
>
> I’m not sure about the multiblock, my routines generally look like:
>
>
>
> For block in output:
>
>  If block.GetCellType(0)=12;
>
>process_block(block)
>
>
>
> would this be
>
>
>
> If input.GetBlock(i)
>
> And I might not have loaded all the blocks in the set, then I might have
> eliminated some loaded blocks with earlier operations – what is the i in
> GetBlock?  Is it block_number as displayed in Spreadsheet or block index as
> in:
>
>
>
> block_index = block.FieldData.GetArray(‘ElementBlockIds’) - 1
>
>
>
> Sorry for such a basic question, but I only know the stuff I have used
> previously.
>
>
>
> Dennis
>
>
>
> *From:* Andy Bauer [mailto:andy.ba...@kitware.com]
> *Sent:* Wednesday, October 18, 2017 10:44 AM
> *To:* Dennis Conklin 
> *Cc:* Paraview (paraview@paraview.org) 
> *Subject:* [EXT] Re: [Paraview] How to test for empty block in
> multi-block dataset
>
>
>
>  *WARNING - External email; exercise caution.*
>
>
>
> Hi Dennis,
>
> I think something like:
>
> if multiblock.GetBlock(i) != None:
>   ...
>
> should work. You probably don't even need the "!=None" part.
>
> Cheers,
>
> Andy
>
>
>
> On Wed, Oct 18, 2017 at 10:41 AM, Dennis Conklin <
> dennis_conk...@goodyear.com> wrote:
>
> P.S.  I’m writing python inside a Programmable Filter
>
>
>
> Thanks again
>
> Dennis
>
>
> ___
> Powered by www.kitware.com
> 
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
> 
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
> 
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
> 
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
> 
>
>
>
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview


Re: [Paraview] [EXT] Re: How to test for empty block in multi-block dataset

2017-10-18 Thread Dennis Conklin
Andy,

I’m not sure about the multiblock, my routines generally look like:

For block in output:
 If block.GetCellType(0)=12;
   process_block(block)

would this be

If input.GetBlock(i)
And I might not have loaded all the blocks in the set, then I might have 
eliminated some loaded blocks with earlier operations – what is the i in 
GetBlock?  Is it block_number as displayed in Spreadsheet or block index as in:

block_index = block.FieldData.GetArray(‘ElementBlockIds’) - 1

Sorry for such a basic question, but I only know the stuff I have used 
previously.

Dennis

From: Andy Bauer [mailto:andy.ba...@kitware.com]
Sent: Wednesday, October 18, 2017 10:44 AM
To: Dennis Conklin 
Cc: Paraview (paraview@paraview.org) 
Subject: [EXT] Re: [Paraview] How to test for empty block in multi-block dataset

 WARNING - External email; exercise caution.



Hi Dennis,
I think something like:
if multiblock.GetBlock(i) != None:
  ...
should work. You probably don't even need the "!=None" part.
Cheers,
Andy

On Wed, Oct 18, 2017 at 10:41 AM, Dennis Conklin 
mailto:dennis_conk...@goodyear.com>> wrote:
P.S.  I’m writing python inside a Programmable Filter

Thanks again
Dennis

___
Powered by 
www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: 
http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview