Select linked flat faces in python

in blender, there is the option to select linked flat faces, in edit mode. the shortcut is shift-control-alt-f.
I am trying to do this in a script. How do I code this function using python?

I just don’t know how to start going about it. :confused: any ideas welcome. please.

Take a look at BPyMesh.py - it has a function - that returns planer islands - it could be modified to select linked planer faces.

thanks ideasman, that did it. I didn’t even have to modify it - I just used it.

here’s my code in case your interested (probably not the most economical, but fine for this case.)

import BPyMesh, Blender
ob = Blender.Scene.getCurrent().getActiveObject()
me = Blender.Mesh.Get(ob.getData().name)
for i in BPyMesh.facesPlanerIslands(me):
_fsel = 0
_for f in i:
__if f.sel:
___fsel = 1
_if fsel:
__for f in i:
___f.sel = 1

looks fine. just add a break after you find the first selected face.