Highlighting the current context element

We received a request from a customer who wanted to highlight the current context element, i.e. the element where the cursor is currently in. As we already highlight elements when you hover over menu items, it took little effort to make this functionality available in the API. Here is the script that you can use:

var highlightNode;
Editor.addEventListener("xmlContextChange", function(evt)
{
  if (highlightNode)
    highlightNode.unhighlight(); highlightNode = evt.newNode;
  if (!highlightNode)
    return;
   
  if (highlightNode.getNodeType() == 2)
    highlightNode = highlightNode.getOwnerElement();
  else if (highlightNode.getNodeType() != 1)
    highlightNode = highlightNode.getParentNode();
 
  highlightNode.highlight();
});

There are 2 new methods on XML nodes: highlight and unhighlight. And there is a previously unexposed event xmlContextChange, which has 2 event properties: newNode and oldNode.

Modified: January 15th 2009
By: Sjoerd Visscher

bestonlinecasinos
anonymous user
September 7th 2010
Nope, the Revit API does not provide any methods to updated the ribbon or refresh the user interface in any way, as far as I know. Revit seems to assume that it can take care of that internally. I have also not heard of any similar issues in the past. Is this all in Revit 2010? Have you tried it in 2011?
http://www.casinobigben.com
HTML will be shown as HTML code. Linebreaks and links starting with http:// are automatically resolved.