@@ -185,18 +185,22 @@ def dpf_mesh_to_vtk_op(mesh, nodes=None, as_linear=True):
185
185
celltypes_pv = mesh_to_pyvista .outputs .cell_types ()
186
186
if VTK9 :
187
187
grid = pv .UnstructuredGrid (cells_pv , celltypes_pv , nodes_pv )
188
- # setattr(grid, "_dpf_cache_op", [cells_pv, celltypes_pv, nodes_pv])
189
- pv .set_new_attribute (
190
- obj = grid , name = "_dpf_cache_op" , value = [cells_pv , celltypes_pv , nodes_pv ]
191
- )
188
+ if hasattr (pv , "set_new_attribute" ): # For pyvista >=0.46.0
189
+ pv .set_new_attribute (
190
+ obj = grid , name = "_dpf_cache_op" , value = [cells_pv , celltypes_pv , nodes_pv ]
191
+ )
192
+ else : # For pyvista <0.46.0 # pragma: nocover
193
+ setattr (grid , "_dpf_cache_op" , [cells_pv , celltypes_pv , nodes_pv ])
192
194
return grid
193
195
else :
194
196
offsets_pv = mesh_to_pyvista .outputs .offsets ()
195
197
grid = pv .UnstructuredGrid (offsets_pv , cells_pv , celltypes_pv , nodes_pv )
196
- # setattr(grid, "_dpf_cache_op", [cells_pv, celltypes_pv, nodes_pv, offsets_pv])
197
- pv .set_new_attribute (
198
- obj = grid , name = "_dpf_cache_op" , value = [cells_pv , celltypes_pv , nodes_pv , offsets_pv ]
199
- )
198
+ if hasattr (pv , "set_new_attribute" ): # For pyvista >=0.46.0
199
+ pv .set_new_attribute (
200
+ obj = grid , name = "_dpf_cache_op" , value = [cells_pv , celltypes_pv , nodes_pv , offsets_pv ]
201
+ )
202
+ else : # For pyvista <0.46.0 # pragma: nocover
203
+ setattr (grid , "_dpf_cache_op" , [cells_pv , celltypes_pv , nodes_pv , offsets_pv ])
200
204
return grid
201
205
202
206
@@ -356,11 +360,12 @@ def compute_offset():
356
360
357
361
# Quick fix required to hold onto the data as PyVista does not make a copy.
358
362
# All of those now return DPFArrays
359
- # setattr(grid, "_dpf_cache", [node_coordinates, coordinates_field])
360
- pv .set_new_attribute (
361
- obj = grid , name = "_dpf_cache" , value = [node_coordinates , coordinates_field ]
362
- )
363
-
363
+ if hasattr (pv , "set_new_attribute" ): # For pyvista >=0.46.0
364
+ pv .set_new_attribute (
365
+ obj = grid , name = "_dpf_cache_op" , value = [node_coordinates , coordinates_field ]
366
+ )
367
+ else : # For pyvista <0.46.0 # pragma: nocover
368
+ setattr (grid , "_dpf_cache_op" , [node_coordinates , coordinates_field ])
364
369
return grid
365
370
366
371
# might be computed when checking for VTK quadratic bug
0 commit comments