How to apply a material to a part with API?

To apply a material to a part:

Manual operation method

  In a part document, click Edit Material (Standard toolbar) or Edit, Appearance, Material.

  1.   Set the properties in the Materials Editor PropertyManager
  2. Click .

The material is applied to the part, and the material name appears in the FeatureManager design tree next to Material

.Target needs, using API methods, to finish steps manually.

SolidworksApi macros