Answer the question
In order to leave comments, you need to log in
How to merge objects in Blender using Python?
Problem: objects are not merged (Warning: Active object is not a selected mesh)
There is a large map with a huge number of objects on it.
It was necessary to merge objects that have the same beginning of the name
{"name", "name 1", (...),"name N"} -> "name"
Doing this by hand is quite long and dreary, so I decided to take the opportunity to write for python script blender.
Through trial and error, two methods were created:
import collections, time
def selector(): # выделяет объекты, названия которых начинаются одинаково
c = collections.Counter([x.name.split()[0] for x in C.scene.objects])
_nr = [x for x in dict(c) if dict(c)[x] > 1]
del c
for nr in _nr:
bpy.ops.object.select_all(action='DESELECT')
print("Selecting all", nr)
for obj in C.scene.objects:
if not obj.name.startswith(nr): continue
bpy.data.objects[obj.name].select = True
print("Selected", obj.name)
joiner()
def joiner(): # должен объединять объекты
bpy.ops.object.join()
time.sleep(.5)
bpy.ops.object.select_all(action='DESELECT')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question