-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select element on plotter and save it as it's own vtk file #51
Comments
Cell selection is currently possible - check out the You could pass a custom Otherwise, I'm not sure what you mean by selecting elements/holes... |
What kind of function would I need to create to do this? I simply want to be able to select a mesh from the plot and export it as it's own vtk file using the save function. |
Or more specifically selecting a vtk cell |
The goal is to try and get something similar to extract selection from ParaView. |
After making a selection with the plotter's Here's an example import pyvista as pv
from pyvista import examples
mesh = examples.download_dragon()
p = pv.Plotter(notebook=False)
p.add_mesh(mesh)
p.enable_cell_picking(mesh)
p.show() selection = p.picked_cells
selection.plot(color='white') # Save it
selection.save('my_selection.vtk') |
This works great! I am getting the option "Press P to pick a single cell under the mouse" Is this coming in the next release? |
Yes, a few new features with cell selection are coming in the next release! Along with many other point selection tools and widgets. |
Awesome! Final question... I mentioned above being able to select from a table. In ParaView there is the option to have a spreadsheet view side by side with the plot and be able to select the cells by their rows (see screenshot in email). from there I can apply the extract cellls filter. Is something like this possible in PyVista as well? |
In short, not really as PyVista isn't designed to be GUI application like ParaView. But if you know the cell IDs (the rows in the spreadsheet view) then you can use PyVista's Coming in the next release of PyVista is support for Unfortunately it is out of scope for us to deisgn any sort of interactive selection tool based on a table representation. |
Or if you are feeling really adventurous, you could make a plugin to PyVista using PyQt to show these tables and allow selections to callback to the extract filters. Making the GUI would be the hard part... all the extraction and PyVista stuff is already implemented |
Okay, I will give this a try. Thank you! |
On the lastest version of PyVista, the import pyvista as pv
from pyvista import examples
# Any mesh
mesh = examples.download_st_helens().warp_by_scalar()
# Make a table
point_table = pv.Table(mesh.point_arrays) Also, now you have a
I'd recommend starting there and then taking a look at the Qt Table Widget and this SO post about making Qt Tables from data frames. Then you'd want to display that widget in an app (maybe link it to PyVista's |
FYI... there are some custom Qt widgets implemented in VTK for tables but I'm not sure if they are available on the Python distribution: https://vtk.org/doc/nightly/html/classvtkQtTableView.html It might require a custom build of VTK |
I was wondering if it was possible to select elements on a plot interactively (ex.: a collection of holes) and save them as their own vtk file or perhaps print their table data?
Thank you!
The text was updated successfully, but these errors were encountered: