Skip to content
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

Append Geometry #46

Closed
laserman781 opened this issue Aug 12, 2019 · 2 comments
Closed

Append Geometry #46

laserman781 opened this issue Aug 12, 2019 · 2 comments
Labels
filtering General topics around filtering and usage of filters

Comments

@laserman781
Copy link

I would like to be able to append my meshes/combine them before I save them as a .vtk. I have multiple tubes and after I generate them I would prefer to have them all in one vtk file rather than having them all separate.

I have looked into the class pyvista.MultiBlock and append but I have not been able to apply it.

I have the tube data in a dictionary and I would have to loop through in order to add them as arguments combine them.

Thank you.

@banesullivan
Copy link
Member

banesullivan commented Aug 12, 2019

If you already have all of the meshes/tubes in a dictionary, then you should try using a MultiBlock dataset and its combine method to merge all of the meshes. Here's an example:

import pyvista as pv
my_tubes = {
    'tube a': pv.Cylinder(center=(1,1,1), direction=(1,0,0)),
    'tube b': pv.Cylinder(center=(0,1,1), direction=(1,1,0)),
    'tube c': pv.Cylinder(center=(1,1,0), direction=(0,0,1)),
}

blocks = pv.MultiBlock(my_tubes)
merged = blocks.combine()
merged # this is now a single unstructured grid containing all geometry

The last release of PyVista (version 0.21.4) also added a nifty new + operator for all mesh types that you could use, but I'd recommend the combine method since you already have a dictionary

@banesullivan banesullivan added the filtering General topics around filtering and usage of filters label Aug 12, 2019
@laserman781
Copy link
Author

Worked great thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filtering General topics around filtering and usage of filters
Projects
None yet
Development

No branches or pull requests

2 participants