vedo
vedo copied to clipboard
Problems creating KSpline using vtk=9.1.0
Dear @marcomusy, Hope this message finds you well. I am interested in being able to use the latest version of vedo (2023.4.3) in a virtual environment in which I also have installed another package (vmtk) that also requires vtk. The issue is that the latest version of vmtk that runs in python 3.9 has pinned the vtk package to the 9.1.0 version and I am getting some errors whilst trying to create KSplines in vedo as the import function is not able to import vedo.vtkclasses as vtk, and using the exception is importing vtkmodules.all as vtk, but when it tries to find within the imported vtk vtkmodules it can't find it. The error I am getting is:
kspl = vedo.KSpline(ordpts, continuity=0, tension=0, bias=0, closed=True)
File "D:\Applications\Miniconda\envs\mHpy39_v4\lib\site-packages\vedo\shapes.py", line 1190, in __init__
xspline = vtk.vtkmodules.vtkCommonComputationalGeometry.vtkKochanekSpline()
AttributeError: module 'vtkmodules.all' has no attribute 'vtkmodules'
Any ideas that could help me fix this would be appreciated! Thanks in advance, Juliana
Hi Juliana, thanks for reporting this, it looks very much like a bug :)
I'll fix it.. meanwhile you may wish to use Spline()?
Hi @marcomusy ,
Thanks for your fast reply.
I managed to find the right way into the vtk module by modifying the init of KSplines in vedo with:
xspline = vtk.vtkKochanekSpline()
rather than:
xspline = vtk.vtkmodules.vtkCommonComputationalGeometry.vtkKochanekSpline()
but I am afraid this is a temporary fix as this will not solve the connection between the modules.
Hopefully, this fix will give you more insights into the bug.
I will continue using this modified version but please let me know if you find a more appropriate way to fix it.
Thanks again.
best,
Juliana
Hi, that is bit strange .. I cannot reproduce the issue with vtk 9.1.0... this works for me:
from vedo import *
pts = [[0,0,0],[1,2,3], [3,4,2], [6,3,4]]
spline = KSpline(pts)
vpts = Points(pts, r=8, c='red5')
show(spline, vpts, axes=1)

vedo version : 2023.4.3.dev14 https://vedo.embl.es
vtk version : 9.1.0
numpy version : 1.21.6
python version : 3.9.13 (main, Aug 25 2022, 23:26:10) [GCC 11.2.0]
python interpreter: /home/musy/soft/anaconda3/bin/python
vedo installation : /home/musy/Projects/vedo
system : Linux 5.4.0-139-generic posix x86_64