<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=Blender_Scripting</id>
	<title>Blender Scripting - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=Blender_Scripting"/>
	<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=Blender_Scripting&amp;action=history"/>
	<updated>2026-05-06T19:39:34Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Wikizone</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=Blender_Scripting&amp;diff=24068&amp;oldid=prev</id>
		<title>37.49.72.8 am 18. September 2019 um 17:18 Uhr</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=Blender_Scripting&amp;diff=24068&amp;oldid=prev"/>
		<updated>2019-09-18T17:18:25Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 18. September 2019, 17:18 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Zeile 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Merge Materials ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Merge Materials ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; https://blender.stackexchange.com/questions/75790/how-to-merge-around-300-duplicate-materials&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following script extends from the already linked answer in that it removes any double-materials and assigns the &amp;#039;correct&amp;#039; materials to the faces respectively. However, you&amp;#039;ll need to understand that a few assumptions are made here:&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following script extends from the already linked answer in that it removes any double-materials and assigns the &amp;#039;correct&amp;#039; materials to the faces respectively. However, you&amp;#039;ll need to understand that a few assumptions are made here:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>37.49.72.8</name></author>
	</entry>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=Blender_Scripting&amp;diff=24067&amp;oldid=prev</id>
		<title>37.49.72.8: Die Seite wurde neu angelegt: „== Merge Materials ==  &lt;pre&gt; The following script extends from the already linked answer in that it removes any double-materials and assigns the &#039;correct&#039; mate…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=Blender_Scripting&amp;diff=24067&amp;oldid=prev"/>
		<updated>2019-09-18T17:18:05Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „== Merge Materials ==  &amp;lt;pre&amp;gt; The following script extends from the already linked answer in that it removes any double-materials and assigns the &amp;#039;correct&amp;#039; mate…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Merge Materials ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The following script extends from the already linked answer in that it removes any double-materials and assigns the &amp;#039;correct&amp;#039; materials to the faces respectively. However, you&amp;#039;ll need to understand that a few assumptions are made here:&lt;br /&gt;
&lt;br /&gt;
your original material is named something&lt;br /&gt;
the duplicates are named something.045, something.046 and so on&lt;br /&gt;
they are REALLY duplicates&lt;br /&gt;
you&amp;#039;ve saved your scene before you run this :)&lt;br /&gt;
the active object in your scene is the mesh object you want to clean&lt;br /&gt;
Copy the following Python code to a text editor within your file and run it:&lt;br /&gt;
&lt;br /&gt;
import bpy&lt;br /&gt;
&lt;br /&gt;
# only search on own object materials&lt;br /&gt;
mat_list = [x.material.name for x in bpy.context.object.material_slots]&lt;br /&gt;
remove_slots = []&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# the following only works in object mode&lt;br /&gt;
bpy.ops.object.mode_set(mode=&amp;#039;OBJECT&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
for s in bpy.context.object.material_slots:&lt;br /&gt;
    if s.material.name[-3:].isnumeric():&lt;br /&gt;
        # the last 3 characters are numbers&lt;br /&gt;
        # that indicates it might be a duplicate of another material&lt;br /&gt;
        # but this is pure guesswork, so expect errors to happen!&lt;br /&gt;
        if s.material.name[:-4] in mat_list:&lt;br /&gt;
&lt;br /&gt;
            # there is a material without the numeric extension so use it&lt;br /&gt;
            # this again is just guessing that we&amp;#039;re having identical node trees here&lt;br /&gt;
&lt;br /&gt;
            # get the material index of the &amp;#039;clean&amp;#039; material&lt;br /&gt;
            index_clean = mat_list.index(s.material.name[:-4])&lt;br /&gt;
            index_wrong = mat_list.index(s.material.name)&lt;br /&gt;
            print(index_wrong, index_clean)&lt;br /&gt;
&lt;br /&gt;
            # get the faces which are assigned to the &amp;#039;wrong&amp;#039; material&lt;br /&gt;
            faces = [x for x in bpy.context.object.data.polygons if x.material_index == index_wrong]&lt;br /&gt;
&lt;br /&gt;
            for f in faces:&lt;br /&gt;
                f.material_index = index_clean&lt;br /&gt;
&lt;br /&gt;
            remove_slots.append(s.name)&lt;br /&gt;
&lt;br /&gt;
# now remove all empty material slots:&lt;br /&gt;
for s in remove_slots:&lt;br /&gt;
&lt;br /&gt;
    if s in [x.name for x in bpy.context.object.material_slots]:&lt;br /&gt;
        print(&amp;#039;removing slot %s&amp;#039; % s)&lt;br /&gt;
        bpy.context.object.active_material_index = [x.material.name for x in bpy.context.object.material_slots].index(s)&lt;br /&gt;
        bpy.ops.object.material_slot_remove()&lt;br /&gt;
It should turn this:&lt;br /&gt;
&lt;br /&gt;
start&lt;br /&gt;
&lt;br /&gt;
into this:&lt;br /&gt;
&lt;br /&gt;
finish&lt;br /&gt;
&lt;br /&gt;
share&lt;br /&gt;
improve this answer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>37.49.72.8</name></author>
	</entry>
</feed>