# RuledSurfaceFilter using vtkmodules

**URL:** https://discourse.paraview.org/t/ruledsurfacefilter-using-vtkmodules/7773
**Category:** Development
**Tags:** python
**Created:** [August 5, 2021, 6:11pm UTC](https://discourse.paraview.org/t/ruledsurfacefilter-using-vtkmodules/7773 "2021-08-05T18:11:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jared\_Blanchard](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jared_blanchard/32/7174_2.png) [@Jared\_Blanchard](https://discourse.paraview.org/u/Jared_Blanchard)
#### Post date: [August 5, 2021, 6:11pm UTC](https://discourse.paraview.org/t/ruledsurfacefilter-using-vtkmodules/7773/1 "2021-08-05T18:11:06Z")

</div>

I’ve gotten stuck trying to use the RuledSurfaceFilter inside one of my python plugins.

I have been writing standalone code using `import vtk` based on this example:  
[RuledSurfaceFilter.py](https://discourse.paraview.org/uploads/short-url/tlhVWmvY6gXdjTKwznCK7OdjWSi.py) (2.5 KB). This works great.

Now, I’m trying to create a python plugin that does something similar. However, since I’m using vtkmodules, I don’t have access to all the same classes that come with vtk, but when I try to `import vtk`, paraview crashes. For example, I have an array of `vtkPolyLineSource()` created inside my class like this

```auto
    def compute_orbits(self):
        self.orbits = []
        y0 = self.initial_conditions()
        for i in range(self.N):
            self.orbits.append(vtkPolyLineSource())

            y, t = self.integrate(y0[i]) # integrates an ODE with initial conditions y0[i]
            n = y.shape[1]
            self.orbits[i].SetNumberOfPoints(n)

            for j in range(n):
                self.orbits[i].SetPoint(j,y[0,j],y[1,j],y[2,j])

            self.orbits[i].Update()

```

Later, I try to create a `vtkRuledSurfaceFilter()` object like this

```auto
self.surface = vtkRuledSurfaceFilter()
for i in range(len(self.orbits)):
    self.surface.SetInputData(self.orbits[i].GetOutput())

```

But when I try to generate an output in the `RequestData` function, I get nothing

```auto
output = vtkMultiBlockDataSet.GetData(outInfo, 0)
output.SetBlock(0,self.surface.GetOutput())

```

Any tips here for working with `vtkPolyLineSource()` instead of `vtkPolyLine()`?

I’m running Paraview 5.8.0 on Ubuntu 20.04

---

<div class="post-metadata">

### Author: ![Jared\_Blanchard](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jared_blanchard/32/7174_2.png) [@Jared\_Blanchard](https://discourse.paraview.org/u/Jared_Blanchard)
#### Post date: [August 11, 2021, 12:39am UTC](https://discourse.paraview.org/t/ruledsurfacefilter-using-vtkmodules/7773/2 "2021-08-11T00:39:40Z")

</div>

I got something working, although it’s a bit unwieldy.

```auto
    def compute_orbits(self):
        self.surface = vtkRuledSurfaceFilter()

        points = vtkPoints()
        lines = vtkCellArray()

        self.orbits = []
        y0 = self.initial_conditions()
        
        Ntot = 0
        for i in range(self.N):
            self.orbits.append(vtkPolyLineSource())
            line = vtkPolyLine()

            y, t = self.integrate(y0[i])
            n = y.shape[1]

            self.orbits[i].SetNumberOfPoints(n)
            line.GetPointIds().SetNumberOfIds(n)

            for j in range(n):
                self.orbits[i].SetPoint(j,y[0,j],y[1,j],y[2,j])
                points.InsertPoint(Ntot,y[0,j],y[1,j],y[2,j])

                line.GetPointIds().SetId(j,Ntot)

                Ntot += 1

            self.orbits[i].Update()

        polydata = vtkPolyData()
        polydata.SetPoints(points)
        polydata.SetLines(lines)
        self.surface.SetInputData(polydata)
        self.surface.SetResolution(n, n)
        self.surface.Update()

```

I compute trajectories for each initial condition and put them into two different objects: `self.orbits`, which is an array of `vtkPolyLineSource()` and `self.surface`, which is a `vtkRuledSurfaceFilter()’.

in the `RequestData` function I add the filter to the output like this.

```auto
def RequestData(self, request, inInfo, outInfo):
        from vtkmodules.vtkCommonDataModel import vtkMultiBlockDataSet
        output = vtkMultiBlockDataSet.GetData(outInfo, 0)
        output.SetBlock(0,self.surface.GetOutput())

```
