blank instances

I have some scenes where I instance a lot of different things and parent the instances to other things (like signs on buildings or something)

Going back through the scenes I'm changing some stuff and removing items I've decided not to have in the scene. Is there an easy way to find instances in the tree that no longer have the original object they were created from so I can remove them?

Comments

  • macleanmaclean Posts: 2,438

    When you delete the original object, the instances *should* be deleted as well. Is this not happening?

  • kaotkblisskaotkbliss Posts: 2,915
    edited March 2018

    Not that I've ever noticed. It always leaves an instance kinda like when you create a null object Only it's named "instance"...

    Post edited by kaotkbliss on
  • macleanmaclean Posts: 2,438

    Ummm... actually you're quite correct. I was talking nonsense. I remebered instances being deleted with the original, but I just double-checked, and they aren't. The reason I thought they were is that in my products, I always parent the instances to the original, so that if the user deletes it, they all go.

    So to go back to your original problem.... I can't think of any way to do it, other than going through them all manually in the scene pane, using the visibilty icon to check what they are. Also, it might be worth putting in a feature request for this.

  • Richard HaseltineRichard Haseltine Posts: 108,855
    edited March 2018

    I thought this would be easy to script, but (at least within a session) the target for an instance iss till defined even if the actual node has been deleted. I don't know if that's the correct result or not.

    Edit: it does work if the scene is saved and reloaded after the nodes are deleted so I will post it here - though it's a rough draft and will probably need more work to handle instance groups.  Run the script with nothing selected and it should select all and only the orphaned instances.

    // Find orphaned instances// (c) Richard Haseltine, March 2018// Get al the nodes in the scenevar nodes = Scene.getNodeList();// Go through them looking for instancesfor ( var n = 0 ; n < nodes.length ; n++ ) {	// skip to the next node if this is a non-instance nodes	if ( ! nodes[ n ].inherits( "DzInstanceNode" ) ) {		continue;	}	// check to see if the instance lacks a target	if ( nodes[ n ].getTarget() == null ) {		// select it if it does		nodes[ n ].select( true );	}}

     

    Post edited by Richard Haseltine on
  • SylvanSylvan Posts: 2,719
    Thanks Richard! I also struggle with the blank instances being all over the place.
  • kaotkblisskaotkbliss Posts: 2,915

    Thank you Richard! :)

    Originally I too parented instances to their original object, but then I moved them to attach them to the building they were "part of" in the scene. Then I decided to remove some of the greebles off the buildings which led to this situation.

  • Richard HaseltineRichard Haseltine Posts: 108,855

    jag11 pointed out the isInScene() function, which can be used to tell if an item still exists but has been removed from the scene. Rewriting to use that, this script seems to work whether or not the scene has been reloaded since the source item was deleted.

    // Find orphaned instances// (c) Richard Haseltine, March 2018// Get al the nodes in the scenevar nodes = Scene.getNodeList();// Go through them looking for instancesfor ( var n = 0 ; n < nodes.length ; n++ ) {	// skip to the next node if this is a non-instance nodes	if ( ! nodes[ n ].inherits( "DzInstanceNode" ) ) {		continue;	}	// check to see if the instance has a target	// and if the target is in the scene	if ( nodes[ n ].getTarget() && nodes[ n ].getTarget().isInScene() ) {		// skip to the next node it if it does		continue;	}	// If we get this far we have an instance with no target or 	// with a target that is not in the scene, so select it	nodes[ n ].select( true );}

     

Sign In or Register to comment.