Create a macro to fill an attribute ?

Hi everyone ! 


I wanted to know if it is possible to create a macro with CATIA that automatically fills an attribute. It should return the value A if the element is an assembly and P if it is a part.


Is somebody already do something like that ? If yes, witch command did you use ?


Thanks !