Getting label of layered image

I can't seem to get the label of a layered image... .label returning undefined..

 

	oMap = oProperty.getMapValue();
	if( oMap ){
		if( oMap.className() == "DzLayeredTexture" ){
			NumOfLayers = oMap.getNumLayers();
			for( var i = 0; i < NumOfLayers; i++){
				cLayer = oMap.getLayer(i);
				LayerLabel = cLayer.label;
				debug( String( %1 ).arg( LayerLabel ) );
			}
		}
	}

 

Comments

  • Is that the right class name? In the DS3 Scripting docs it's DzLayeredImage

  • Yes, I'm checking to see if the map is a layered texture.

    I'm able to get the imageFile, yOffset, xOffset, flip and other settings.., just not label.

  • Obviously that is a new class for DS 4 then, it isn't in DS3. Have you tried the for ( var n in cLayer ) { print ( n ); } trick to get a list of members? Though presumably there would be an error if label wasn't there at all.  (As an aside, why are you checking for equality rather than using inherits( "DzLayeredTexture" )?)

  • DraagonStormDraagonStorm Posts: 748
    edited December 2015

    In one script I create a layer and give it a specific name... Then I have scripts to move that specific layer's yOffset by different percentages of the height. So I need to loop thru the layers and check for that specific label name to move only that one.

    Correct... LayerLabel = cLayer.label is not causing an error... It's just returning undefined.

    Post edited by DraagonStorm on
  • Can you assign a label and recover it in the same script.

  • Wouldn't it be "LayerLabel = cLayer.getLabel()"?

  • Cayman said:

    Wouldn't it be "LayerLabel = cLayer.getLabel()"?

    No. That doesn't exsist.

  • Can you assign a label and recover it in the same script.

    Only before I actually save out the layered image. If I save it out, and then try to recover it I get the undefined.

  • Richard HaseltineRichard Haseltine Posts: 43,967
    edited December 2015

    label is a property of DzImageComponent, which DzImageLayer and DzImageMask inherit. They don't inherit from the object that supports getLabel() (DzEleemnt or DzBase, I think). But as I noted above, it does not appear that the DS 4 objects match the DS 3 scripting docs.

    Post edited by Richard Haseltine on
  • Can you assign a label and recover it in the same script.

    Only before I actually save out the layered image. If I save it out, and then try to recover it I get the undefined.

    Sounds like a bug then, or close enough to be worth reporting.

  • Sorry I take so long to reply... I'm not being notified of posts for some reason..............

    Opened Ticket: #206463 Daz Script: Can not get label of a layer in Layered Images

  • ChoholeChohole Posts: 28,080

    Sorry I take so long to reply... I'm not being notified of posts for some reason..............

    Opened Ticket: #206463 Daz Script: Can not get label of a layer in Layered Images

    Have you bookmarked the thread. 

  • SF-DesignSF-Design Posts: 916

    so has this been solved? still undefined here

  • MikeDMikeD Posts: 33

    The:

    cLayer = oMap.getLayer(i);

    returns an DzTextureLayer object which inherits properties and methods of DzTextureComponent object.

    You may use:

    cLayer.imageFile (for image of layer i)

    cLayer.color (for color object) or color.name (for color #Code)

    cLayer.getMask().imageFile (for mask image)

    Maybe you can solve the label problem with this!
     

  • MikeD said:

    The:

    cLayer = oMap.getLayer(i);

    returns an DzTextureLayer object which inherits properties and methods of DzTextureComponent object.

    You may use:

    cLayer.imageFile (for image of layer i)

    cLayer.color (for color object) or color.name (for color #Code)

    cLayer.getMask().imageFile (for mask image)

    Maybe you can solve the label problem with this!
     

    Thank you very much, I will try that if it solves that. 

  • SF-DesignSF-Design Posts: 916
    edited November 2017

    Hmm,
    I was not able to manage that, the problem is I need to search for a specific layer name , 2 layers could have the same image as source but different labels, but I only want to remove for instance layer labeld A1. 
    It returns the images used but then I do not know which layer is the correct one since the order varies when using removeLayer() that wants a layer number. 

    If they would fix that cLayer.label it was no problem :( 
    Well and I am no scripting pro so I might be doing something wrong too. I imagined that it was just a simple function to get the label of a layer and find it by label like it works for properties etc. too. 

    However, thanks again for your suggestion and help
     

    Post edited by SF-Design on
Sign In or Register to comment.