1

I need to create NURBS surfaces for a project. For that i want to use the geomdl package. I installed it via conda and i tried it with the examples given here. It works with the 2d examples but not with the 3d examples. This is a Code for a B-Spline Curve:

from geomdl import BSpline
from geomdl import utilities
from geomdl.visualization import VisMPL

ctrlpts = [[5.0, 5.0, 0.0], [5.0, 10.0, 0.0], [10.0, 10.0, 5.0], [10.0, 5.0, 5.0], [5.0, 5.0, 5.0], [5.0, 10.0, 10.0], [10.0, 10.0, 10.0], [10.0, 5.0, 10.0], [5.0, 5.0, 15.0], [5.0, 10.0, 15.0], [10.0, 10.0, 15.0], [10.0, 5.0, 20.0], [5.0, 5.0, 20.0]]

# Create a B-Spline curve instance
curve = BSpline.Curve()

# Set up curve
curve.degree = 3
curve.ctrlpts = ctrlpts

# Auto-generate knot vector
curve.knotvector = utilities.generate_knot_vector(curve.degree, curve.ctrlpts_size)

# Set evaluation delta
curve.delta = 0.01

# Plot the control point polygon and the evaluated curve
curve.vis = VisMPL.VisCurve3D()
curve.render()

The visual outcome looks like this: No axes, no coordinates even if i tell the curve.render function to show them. I also tried to delete geomdl and reinstall it. Without success.

It should look like this

Progman
  • 16,827
  • 6
  • 33
  • 48
  • i have the same issue. did you ever get this resolved ? – Fady Megally May 22 '23 at 13:12
  • 1
    Unfortunately not. I installed the package at my work PC where it works just fine. Do you use Windows 11? That is the only real reason i could come up with (besides an error while downloading). Let me know if you find a solution! – ichverzweifel May 29 '23 at 15:12
  • No i am using linux. Debian distro. I insallted VTK and started using VisVTK instead of VisMPL and it worked. – Fady Megally May 30 '23 at 16:45

2 Answers2

1

Just use VisVTK module instead of VisMPL; it will work fine.No need to install it separately; it is part of the "geomdl" package.

Here is the modified code:

from geomdl import BSpline
from geomdl import utilities
from geomdl.visualization import VisVTK

ctrlpts = [[5.0, 5.0, 0.0], [5.0, 10.0, 0.0], [10.0, 10.0, 5.0], [10.0, 
5.0, 5.0], [5.0, 5.0, 5.0], [5.0, 10.0, 10.0], [10.0, 10.0, 10.0], [10.0, 
5.0, 10.0], [5.0, 5.0, 15.0], [5.0, 10.0, 15.0], [10.0, 10.0, 15.0], [10.0, 
5.0, 20.0], [5.0, 5.0, 20.0]]

# Create a B-Spline curve instance
curve = BSpline.Curve()

# Set up curve
curve.degree = 3
curve.ctrlpts = ctrlpts

# Auto-generate knot vector
curve.knotvector = utilities.generate_knot_vector(curve.degree, 
curve.ctrlpts_size)

# Set evaluation delta
curve.delta = 0.01

# Plot the control point polygon and the evaluated curve
curve.vis = VisVTK.VisCurve3D()
curve.render()

enter image description here

MI Alam
  • 417
  • 3
  • 9
0

I fixed it for me for surface plotting be replacing line 430 of VisMPL.py

# Start plotting of the surface and the control points grid
fig = plt.figure(figsize=self.vconf.figure_size, dpi=self.vconf.figure_dpi)
ax = Axes3D(fig)

with:

# Start plotting of the surface and the control points grid
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})

I didn't check the hole code, maybe you need to replace it somewhere else too. Note that the settings now do not work anymore. But this can surely be fixed.

Siltyx
  • 1
  • 1