Select_circle function in Edit Mode via Python

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
runaway
Posts: 0
Joined: Mon Jul 19, 2010 10:29 am

Select_circle function in Edit Mode via Python

Post by runaway » Fri Sep 13, 2013 6:04 pm

Hello to all,

I am trying to use python for the repetitive task of selecting only certain vertices to form a face.

Given is an mesh-object that consists of vertices only and does not have edges or faces. Now its about selecting a certain area and filling it. (Due to the structure of the points the area within each circle_select will always contain 4 values.)

Here my code:

Code: Select all

import bpy

#select object as active and change toggle to editmode
bpy.context.scene.objects.active = bpy.data.objects['mymesh']
bpy.ops.object.mode_set(mode='EDIT')
#(working)

# deselect all
bpy.ops.mesh.select_all(action='DESELECT')
#(working)

# change to top view
bpy.ops.view3d.viewnumpad(type='TOP')
#(not working. Console says poll() [..] context incorrect...)

# circle select (C) with radius 1 around coordinates(x,y) and make face
bpy.ops.mask.select_circle.func(x=1,y=1,radius=1)
bpy.ops.mask.edge_face_add()
#(not working. Console says poll() [..] wrong context...)

The documentation on the commands has a lot of details and stuff but I could not find the slightest hint on how to get the command to actually work (not meant to be ungrateful or anything). At least it doesnt add up to me why there are codes like pby[..]select_circle.func() provided, if they don't actually work when applied as stated. I didn't find the missing link in this..

Help is very much appreciated, thank you for your answers.
Have a nice day


PS. Point Cloud to Mesh plugin isnt helping in this case, not even by filling all spaces and then deleting those which are not supposed to be filled, etc etc.

CoDEmanX
Posts: 0
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Post by CoDEmanX » Sun Sep 15, 2013 12:00 am

the operator requires the view 3d as context, but if you run from text editor or pyconsole, it's either of these.

put your code inside of the main function of the operator template, then hit spacebar over view 3d, find your op and run it.

Note that i suggest you look into bmesh module, as it makes it way easier to create geometry - as you don't need to change the selection.
I'm sitting, waiting, wishing, building Blender in superstition...

runaway
Posts: 0
Joined: Mon Jul 19, 2010 10:29 am

Post by runaway » Wed Sep 18, 2013 8:01 pm

CoDEmanX wrote:the operator requires the view 3d as context, but if you run from text editor or pyconsole, it's either of these.

put your code inside of the main function of the operator template, then hit spacebar over view 3d, find your op and run it.

Note that i suggest you look into bmesh module, as it makes it way easier to create geometry - as you don't need to change the selection.

Thanks for your answer! How do I set the context to view 3d?
And which main function do you mean? I've only got the code that I posted above..

CoDEmanX
Posts: 0
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Post by CoDEmanX » Sat Sep 21, 2013 10:03 pm

I'm sitting, waiting, wishing, building Blender in superstition...

Post Reply