Yes, but now ALL objects in Shaded mode will use their render materials… You’ve basically now just turned your Shaded mode into Rendered mode…
To get individual objects to always use their render material, regardless of what display mode (view) they’re in, you need to select the object(s) and run
SetObjectDisplayMode and then select the “Rendered” mode in the command line.
That being said, yes, this can be done through code, but it can get pretty tricky because it’s a “view-based” not just object-based.
IMO, since you’re writing the code yourself… Here’s what I would do/try…
Override the object’s display attributes in the
SC_OBJECTDISPLAYATTRS conduit channel…and then when executing in that channel, set
m_pDisplayAttrs->m_pMaterial equal to the material you want. Rhino will then use that material when drawing the object in the future draw channels. Note: This requires that you be able to identify your object somehow… which can be done using the channel attribute’s object member
if ( m_pChannelAttrs->m_pObject == YOUR_OBJECT)
m_pDisplayAttrs->m_pMaterial = YOUR_MATERIAL;
Note however, that
m_pMaterial is a
CDisplayPipelineMaterial which consists of two materials (front face and back face), which are really just
ON_Material derivatives. If you do not want the back face material used…then just set the front face material and nothing else (
m_pDisplayAttrs->m_pMaterial->m_FrontMaterial = YOUR_MATERIAL)
If I get time today, I will look at the example you posted and tweak it to do what I think you want… But, if you manage to get this working please let me know so that I’m not doing anything unnecessary.