I'd like to thank two people for this post: Kerry Brown, an ADN member in Australia and regular contributor to TheSwamp, pointed me to a response he'd received from a member of the DevTech team in India, Sreekar Devatha. So thanks to both Kerry and Sreekar for providing the material for this post.
The problem was to highlight the nested entity returned by the Editor.GetNestedEntity() method. Sreekar's solution was to create a sub-entity path through the nested block structure, and use that to highlight the entity in question. To create the sub-entity path he retrieved the containers of the nested entity, then reversed them and added the entity's ObjectId to the end of the list. This served as input to the constructor of the FullSubentityPath object, which could then be used in the call to Highlight() on the root container entity.
Here's the C# code:
public class MySelectionCmds
static public void HighlightNestedEntity()
Document doc =
Editor ed = doc.Editor;
PromptNestedEntityResult rs =
ed.GetNestedEntity("\nSelect nested entity: ");
if (rs.Status == PromptStatus.OK)
ObjectId objIds = rs.GetContainers();
ObjectId ensel = rs.ObjectId;
int len = objIds.Length;
// Reverse the "containers" list
ObjectId revIds = new ObjectId[len + 1];
for (int i = 0; i < len; i++)
ObjectId id =
(ObjectId)objIds.GetValue(len - i - 1);
// Now add the selected entity to the end
// Retrieve the sub-entity path for this entity
SubentityId subEnt =
new SubentityId(SubentityType.Null, 0);
FullSubentityPath path =
new FullSubentityPath(revIds, subEnt);
Transaction tr =
// Open the outermost container...
ObjectId id = (ObjectId)revIds.GetValue(0);
Entity ent =
// ... and highlight the nested entity
Create a nested block and run the HLNESTED command to see the code in action. You'll need to REGEN at the end for the highlighting to disappear (you would typically use ent.Unhighlight(path, false) to do this programmatically).