Any way to load then select

I'd like to automate something in the script I am working on.

I've learnt how to load a model in script.

What I would like to do is after the model is loaded that it is selected. It would need to add to the current selections too.

Is there a way to do this, I've dug high and low, but to no avail.

Many thanks.

Comments

  • What I do is use Scene.getNodeList() to get a list of waht's in the scene, and store it, then load my item, get a second copy of Scene.getNodeList() and run backwards through that until I find the item that isn't in the old list.

  • Ahh that's clever thank for the tip smiley

  • Widdershins StudioWiddershins Studio Posts: 539
    edited November 2015

    Tried this but it does not produce unique identifiers...

    So say I have these duplicates in my scene pane:

    item
    item (2)
    item (3)
    item (4)

     

    Because the base name was item...

       All I get out of it is item for each one.

    So say I loaded another duplicate there's no way for me to isolate it.

    Post edited by Widdershins Studio on
  • Don't look at the names or labels, compare the actual items (well, their pointers but since this is a script they look the same).

  • I haven't tested this, just wrote  it from memory, but the general idea should be right

    // get list of items before loadvar temp = Scene.getNodeList;// Make a list excluding bones, to save timevar olds = [];for ( var n = 0 ; n < temp.length ; n++ ) {	if ( ! temp[ n ].inherits( "DzBone" ) ) {		olds.push( temp[ n ] );	}}// Load your item(s)// get list of items after loadvar temp = Scene.getNodeList;// Make a list excluding bones, to save timevar news  = [];for ( var n = 0 ; n < temp.length ; n++ ) {	if ( ! temp[ n ].inherits( "DzBone" ) ) {		news.push( temp[ n ] );	}}var m;var newItems = [];// Check the new list against the oldfor ( n = 0; n < news.length ; n++ ) {	// m is the index, subtract one as it is zero based (one item means there is olds[ 0 ])	m = olds.length - 1;	while ( m >= 0 ) {		// if we find a match between old items and new, quit the checking		if ( news[ n ] == olds[ m ] ) {			break;		}		// If theer wasn't a match decrease m		m--;	}	// If the item is unique m will be -1 since the loop will not have stopped early	if ( m == -1 ) {		newItems.push( news[ n ] );	}}

     

  • Thanks, I couldn't get push to work but it gave me some ideas smiley

Sign In or Register to comment.