Page MenuHome

Particles data library is only reporting the material slot of selected objects
Closed, ArchivedPublic

Description

Open a new file and make a couple objects, give them a few particle systems each. Make and assign a few unique materials to each new particle system's material (under the render menu of the particle system tab) to a different material. Now check out the datablocks menu of the outliner and view particles. Notice that the material slot of each system will only be populated with materials from the active object (regardless of which particle system you are viewing). Is this supposed to be this way? Because when querying bpy.data.particles (which stores each particle system's settings into what I thought was a library) when you access each of these setting's material slots "bpy.data.particles[0].material_slot" they'll only be populated with materials from the active object and not the ones they belong to.

Also if you run the below code. Notice that only the material slots belonging to an active object will print. It's clear that one space for each of the total particle settings stored in bpy.data.particles is being printed, but only the material slot data from the active object is being used to supply the material slot names.

import bpy

for settings in bpy.data.particles:
    print( settings.material_slot)

Event Timeline

sicutunum raised the priority of this task from to 90.
sicutunum updated the task description. (Show Details)
sicutunum edited a custom field.
sicutunum added a subscriber: sicutunum.

Ok after taking a break and coming back to this. I realize that settings.material actually produces the material slot integer value and that settings.material_slot may more or less be cosmetic for the particle panel display. I feel like we're in a weird meta area now... I could accept this as default behaviour but I'm not sure if this is what the devs intended. Hopefuly someone more informed than me will chime in.

Bastien Montagne (mont29) changed the task status from Unknown Status to Archived.Dec 21 2015, 5:03 PM
Bastien Montagne (mont29) claimed this task.

Well… Thing is, particle system do not reference a material, as you pointed out yourself, but merely an index in their object's matslots. This is probably ugly weak design, but not really a bug in itself. And this obviously makes it totally impossible from raw data PoV to actually return correct material, since a same particlesettings can be used with several objects…

Yeah I agree... I wouldn't go so far as to say it's bad design. Sometimes there's just a lot of stuff to juggle. I agree this can be closed though. I brought this up because I was working on something and having trouble pinning down each par system's material and realized the most consistent way to do this is to cross check each object's material slots with settings.material.