1
$\begingroup$

I want to call select_linked_pick from my script so that it behaves as if you had pressed L with the cursor hovering over part of a mesh. Problem is when I try to call it from script it doesn't appear that anything happens.

def execute(self, context):
    bpy.ops.mesh.select_linked_pick()

There is no output in the console, what am I doing wrong here?

$\endgroup$
2
  • $\begingroup$ I am using this to linked select : bpy.ops.mesh.select_linked_pick(deselect=False, delimit={'SEAM'}, index=vertex.index) . Index value depends on that: if it is a vertex : just index of it. if it is an edge: total vertex number + index of edge. if it is a face: total vertex number + total edge number + index of face $\endgroup$ Commented May 20, 2017 at 18:40
  • $\begingroup$ Thanks for the reply, still don't understand though; Running your code as is returns an error: name 'vertex' is undefined. How do I find the index of the vertex under the cursor? $\endgroup$ Commented May 20, 2017 at 22:36

1 Answer 1

2
$\begingroup$

Managed to solve this issue by simply using different operators to get the same result:

    loc = event.mouse_region_x, event.mouse_region_y

    bpy.ops.view3d.select(location=loc)
    bpy.ops.mesh.select_linked()

Found from this answer by CoDEmanX.

Seemed a lot simpler in the end than trying to retrieve the right indexes for everything to use select_linked_pick...

$\endgroup$
2
  • 1
    $\begingroup$ I'm glad that you found a solution, I think that will help me a lot also, thank you:) $\endgroup$ Commented May 21, 2017 at 20:29
  • $\begingroup$ +1, and just remember that in order to have event, you need to create an invoke wrapper and e.g. assign the event or a part of it to a object var(s) which will then be passed as self to execute (seems simple if you know it, but I spent an hour trying to figure it out :) $\endgroup$
    – user213769
    Commented Dec 26, 2023 at 17:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .