[vtkusers] ValueError: method requires a VTK object
    Lise Angell 
    lise.angell at gmail.com
       
    Tue Oct 18 08:29:00 EDT 2005
    
    
  
I'm building a vtkUnstructuredGrid from values read from a binary file.
When I want to insert info about the element topology in the grid, I
get the following error:
Traceback (most recent call last):
  File "readxdr.py", line 606, in ?
    u_grid = mount_vtk_structures(grid, fields)
  File "readxdr.py", line 462, in mount_vtk_structures
    vtk_u_grid.InsertNextCell(vtk_cell_type, pt_list)
ValueError: method requires a VTK object
I have read the vtk-list postings concerning this (and the FAQ), but I
don't have two conflicting vtk versions, so I don't see why I should
get this error...
I'm running python2.3 (got some problems compiling VTK with python2.4
because of gcc4.0 on Tiger) and VTK from CVS (from Oct.11 2005) on OSX
Tiger (iBookG4).
Hope someone can help me...
Regards,
Lise
Code snippet:
#------------------------------------------------------------------------------------------------------
       nsd = grid.nsd; nno = grid.nno; nel = grid.nel   # grid: GridFE class
	
       # allocate VTK structures
	vtk_u_grid = vtk.vtkUnstructuredGrid()
	pts = vtk.vtkPoints()
	pts.SetNumberOfPoints(nno)
	data = vtk.vtkDoubleArray()
	data.SetNumberOfValues(nno)
	
       for i in range (0,nno):
              x = grid.coords[i]
		s = [... get value from file...]
		data.SetValue(i,s)				# put field value in VTK object
		pts.SetPoint(i,x)				# put points in VTK object
	
	vtk_u_grid.Allocate(nel, 0)
	vtk_u_grid.SetPoints(pts)
	vtk_u_grid.GetPointData().SetScalars(data)
	
	# tell the VTK grid structure about the element topology
	
	for e in range (1, nel):
		< getting cell type (int) and point list (array of ints)>
		vtk_u_grid.InsertNextCell(vtk_cell_type, pt_list)
#------------------------------------------------------------------------------------------------------
--
"Je forme une entreprise qui n'eut jamais d'exemple,
et dont l'exécution n'aura point d'imitateur."  J-J Rousseau
    
    
More information about the vtkusers
mailing list