Cam K
Cam K

Reputation: 127

PyVista TypeError: SetSpacing argument

I previously ran the following with no issues.

grid=pv.UniformGrid()
grid.points=np.array([x_surf,y_surf,z_surf]).transpose()

Today, I ran it and received the following. I have already tried reinstalling the package.

Traceback (most recent call last):

  File "C:\Users\camramez\Documents\Meshing\gen_terrain.py", line 28, in <module>
    grid.points=np.array([x_surf,y_surf,z_surf]).transpose()

  File "C:\ProgramData\Anaconda3\envs\mesh\lib\site-packages\pyvista\core\grid.py", line 470, in points
    self._from_specs((nx,ny,nz), (dx,dy,dz), (ox,oy,oz))

  File "C:\ProgramData\Anaconda3\envs\mesh\lib\site-packages\pyvista\core\grid.py", line 435, in _from_specs
    self.SetSpacing(xs, ys, zs)

TypeError: SetSpacing argument %Id: %V

The SetSpacing function on its own works fine. I have done the following as a quick fix, which works, but it does not technically solve the error.

try:
    grid.points=np.array([x_surf,y_surf,z_surf]).transpose()
except:
    1

Upvotes: 1

Views: 142

Answers (1)

Alex Kaszynski
Alex Kaszynski

Reputation: 1996

Looks like this issue has been raised and answered on GitHub: https://github.com/pyvista/pyvista/issues/713

I'm posting the link here for reference just in case someone comes by this on SO and the most helpful response from @banesullivan, another maintainer/author:

SO my recommendation to you, @lifehappenstoyou (great username!), is to switch to using the StructuredGrid class unless you have a compelling reason to use the UnifromGrid class (the only thing I can think of is volume rendering support, in which cases we have work-arounds)

Upvotes: 1

Related Questions