Macro to change color of part or assembly

Hi,

I don't know where to start.. I've tried something using chat GPT but it's just not working ever..

When we put part or assembly in obsolete in PDM we change the color to a dark orange. Not just a face, the whole thing. And them we change the state In PDM as obsolete. We do the same with assembly ( change the color the same as individual part) applying it only at top level letting know the user the assembly is obsolete (not necessarely the part in the assembly). We as well lunch an application in the add in tab to get the latest obsolete information from our ERP system.

Goal: create a macro that auto change to a custom color if the macro is use in a part file or an assembly file and then launch the ERP update add in.   Any ideas? Using solidworks 2024 sp5

Thanks