AnsweredAssumed Answered

Determine type of entity in array from IRenderMaterials.GetEntities()?

Question asked by Josh Milam on Dec 21, 2020
Latest reply on Dec 22, 2020 by Artem Taturevych

If I use the GetEntities() method on an IRenderMaterials object, I am trying to figure out how I can determine the types of the objects that are in the array returned by GetEntities().

If I use the code (VBA) below:



Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2

Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc


Dim renderMaterials As Variant

renderMaterials = swDoc.Extension.GetRenderMaterials2(swDisplayStateOpts_e.swThisDisplayState, Nothing)


Dim material As SldWorks.IRenderMaterial
Set material = renderMaterials(0)


Dim entities As Variant

entities = material.GetEntities()


How do I determine the types of these entities (stored in the "entities" array in the code snippet above)?

For example some of the entities are features and I can set them to IFeature variables, or are bodies and I can set them to IBody2 variables, are components and set to IComponents2, etc....

My ultimate goal is to organize the appearances similar to the how they are presented in the Appearances Pane.