Skip to main content
4 of 6
code generated by AI
Markus von Broady
  • 37.7k
  • 3
  • 32
  • 102

How do I Iterate over vertices to perform operation on them and connected verts

AI Icon Warning, Potential AI generated content⚠️

This post is suspected to have been generated with the help of an artificial intelligence, chat bot, or other language model tools without proper attribution.

There is reason to believe this post was not written by a human due to its structure, and grammatical construction, and has been marked by our community.
Current AI chat bots are a language models, that means they are like a parrot, they can mimic human language well, but they are built to write seemingly logical, seemingly factual grammatically valid text, rather than actually be correct, like a human would.
The veracity of the following content cannot be ascertained. See the Concerns regarding AI generated content.

enter image description here

In my object I have a number of those kind of objects that represent road intersections.

  1. I want a way to iterate through the vertices and find all intersections (any vertex that has 3 or more other vertices connected to it. All these vertices will go into "Intersections" vertex group.

Solution for Part 1:

import bpy

# Assuming you have your object selected in the scene
obj = bpy.context.active_object

# Create an empty vertex group to store intersections
intersections_group ="Intersections")

# Iterate through all vertices
for vert in
    connected_verts = []
    for edge in
        if vert.index in edge.vertices:
    connected_verts = set(connected_verts)

#Check if the vertex is an intersection (3 or more connected vertices)
if len(connected_verts) >= 3:
    intersections_group.add([vert.index], 1.0, 'REPLACE')
  1. Out of each Intersection, I want to separate each possible set of 3 vertices, in this example - I want it to end up with those in the picture below and then be able to perform an operation on each of those, or put each one into its own vertex group. enter image description here
  • 390
  • 2
  • 8