How Can I change functional execution between part and drawing in Macro

I have a macro to read/modify properties from part,assembly and drawing.

It works fine now. I wanted to add few codes to read the material from part.

Here is the portion of the code

sMatName = swModel.GetMaterialPropertyName2("Default", sMatDB)

My question is: How can I add a condition to this function, so that it works only with part

If I run this with drawing or assembly, it shouldn't give me an error.

Can someone please help me to make this work.?

Thanks,

JOHN

SolidworksApi macros