# How to call select_linked_pick from script?

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?

• 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 – Alperen Üretmen May 20 '17 at 18:40
• 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? – TryinToLearn May 20 '17 at 22:36

## 1 Answer

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...

• I'm glad that you found a solution, I think that will help me a lot also, thank you:) – Alperen Üretmen May 21 '17 at 20:29