Skip to content

Can I pick cells in mesh using mouse? How to? #751

Answered by marcomusy
ZiguoAtGitHub asked this question in Q&A
Discussion options

You must be logged in to vote

you can use a callback function, eg

from vedo import *

def callb(evt):
    msh = evt.actor
    if not msh:
        return
    pt = evt.picked3d
    idcell = msh.closest_point(pt, return_cell_id=True)
    msh.cellcolors[idcell] = [255,0,0,255] # red, opaque
    
m = Mesh(dataurl + "290.vtk")
m.decimate().smooth().compute_normals()
m.compute_quality().cmap("Blues", on="cells")

plt = Plotter()
plt.add_callback("mouse click", callb)
plt.show(m, m.labels("cellid"))
plt.close()

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@ZiguoAtGitHub
Comment options

Answer selected by ZiguoAtGitHub
Comment options

You must be logged in to vote
1 reply
@marcomusy
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@marcomusy
Comment options

@ZiguoAtGitHub
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants