Using the Display State Specific Material Visual Properties APIs

Version 2

    The macro examples here are for VBA, VB.NET and C#. The examples demonstrate how to change the color at the assembly or part level in an assembly for specific display states, or a part document itself for specific display states, independent of configurations. (The pre-existing APIs like IModelDocExtension::MaterialPropertyValues, IComponent2::MaterialPropertyValues etc. were configuration specific.) The macros demonstrate the usage of getting and setting the IDisplayStateSetting properties (create the interface using IModelDocExtension::GetDisplayStateSetting and then populate the properties of that interface) and IAppearanceSetting interfaces with IModelDocExtension::DisplayStateSpecMaterialPropertyValues. There are some key things to note in the macro examples: 1) How to use the root component for part documents because the IDisplayStateSetting::Entities requires a component and 2) How to properly set the IDisplayStateSetting::PartLevel property to target the assembly level or the part level of an assembly to apply the material properties. (The IAppearanceSetting interface corresponds to the same returned material visual properties array from the configuration specific APIs, except that they are display state specific now). The example macro works with the SolidWorks shipped sample documents, usb_flash_drive1.sldasm and usb_cover1.sldprt.