code: def rigid_particles(self, rigid_id=None):
          
          for particle in self.particles():
              if rigid_id is not None:
                  if particle.rigid_id == rigid_id:
                      yield particle
              else:
                  if particle.rigid_id is not None:
                      yield particle
docs: Generate all particles in rigid bodies.
  
          If a rigid_id is specified, then this function will only yield particles
          with a matching rigid_id.
  
          Parameters
          ----------
          rigid_id : int, optional
              Include only particles with this rigid body ID
  
          Yields
          ------
          mb.Compound
              The next particle with a rigid_id that is not None, or the next
              particle with a matching rigid_id if specified