1
$\begingroup$

Currently,I have this code that checks to see if the active object has a particle system.

import bpy
if bpy.context.object.particle_systems:
    print("There is a psystem!")
else:
    print("No psystem!")

This works. How can I make it print true only if there is a particle system AND that particle system is a hair system?

$\endgroup$
  • 1
    $\begingroup$ That code checks for uv layers not particle systems. $\endgroup$ – Ray Mairlot Jun 21 '16 at 14:37
  • $\begingroup$ Edited the code $\endgroup$ – John Roper Jun 21 '16 at 15:04
2
$\begingroup$

Below gives a list of all hair particle systems on the context object.

import bpy
context = bpy.context
obj = context.active_object

hair_particle_systems = [ps for ps in obj.particle_systems 
                            if ps.settings.type == 'HAIR']
if len(hair_particle_systems):
    print("%s has %d HAIR particle systems" % 
             (obj.name, len(hair_particle_systems)))
$\endgroup$
  • $\begingroup$ Edited code, what I have works already. I just need to know how to make it search for particle systems and if particle system is hair. $\endgroup$ – John Roper Jun 21 '16 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.