Answered
Hi,
I have a 3D model. When I click on the part it gets selected with different render mode. I want to get the name of the part from model tree as an alert...
Like... "You have clicked on 'BASE_$4' "
It should get on button click. It must give a popup as soon as i click on the part
Paste the following into a new text file, save with a .js extension, and load it into the Script field on your 3D annotation's Properties>3D tab.
.
.
.
// script begins on the line below this
runtime.overrideSelection = true;
var myMouseHandler = function( event ) {
if ( event.isMouseUp ) {
var myMesh = null;
if ( event.hits.length > 0 ) myMesh = event.hits[0].target;
if ( myMesh != null ) {
host.app.alert("You clicked on " + myMesh.name);
}
}
}
var mouseEventHandler = new MouseEventHandler();
mouseEventHandler.onMouseDown = false;
mouseEventHandler.onMouseMove = false;
mouseEventHandler.onMouseUp = true;
mouseEventHandler.onEvent = myMouseHandler;
runtime.addEventHandler( mouseEventHandler );
//end of script