Effective Selection of Edge loops code review
I am working on a script that takes a cylinder, creates a solidify modifier, performs a few extrusions and bevels certain edge loops.
I am pretty sure how I am selecting the loops is super inefficient and seeking some guidance on how to properly do things. Especially when the vertex count goes into the 100000s things start to become very slow.
I have attached some questioning methods that I wrote.
def get_outer_verts_z(inner_group, round_value = 4): Will get a numpy array of all the vertices that form the outer part of the mesh, inner_group is a collection of the solidify modifiers Output Vertex Group which forms the inside of my mesh
def get_inner_group_indices(): Gets the inside vertices of my mesh based on the Output Vertex Group of the solidify modifier
def select_edge_at_z_by_group(edge_z, indices_to_consider, is_inner_group, append_selection = False, index_rounding = 4): This will perform an edge loop selection of all the edges that contain vertices at the given edge_z value. The is_inner_group will determine which vertices to check, inside or outside of the mesh
Although this code works and performs all the things that I need things are quire slow, and when I alter the mesh I have to rerun get_inner_group_indices() to get a fresh copy of the verts if I need to select new edges.
What is the optimum way to work with edges of a mesh or how can I improve my code for better workflow here. I also included a rounding factor as I have found that not all the verts have the exact Z position, some are off my a fraction and won't be selected. Is this a known issue when working with these coordinates?
Also, is this an effective way to get my mesh data to be refreshed
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.mode_set(mode='EDIT')
1
5 comments
Clu from MWM
2
Effective Selection of Edge loops code review
CG Python Academy (Free)
skool.com/cgpython
3D artists learning Blender Python.
Leaderboard (30-day)
Powered by