How to grab the texture map of a surface

2»

Comments

  • V3DigitimesV3Digitimes Posts: 3,123

    I'm sorry I cannot help here. Maybe try to save your material as a depreciated material preset to see what is written in the dsa, it may give you an idea how it is set up.

  • Richard HaseltineRichard Haseltine Posts: 100,463
    edited July 2015
    WTH does this tell me? And can I use it somehow to find out more information?

    TypeError: Result of expression 'myShineStrMap.setTopCoatBumpStrength' [undefined] is not a function

    It means you tried to use a function "setTopCoatStrength" on myShineStrMap - something like

    myShineStrMap.setTopCoatBumpStrength( .1 );

    but there's no such function. If myShineStrMap is a material, use

    // get the propertyvar oSetTCStr = myShineStrMap.findPropertyByLabel( "Set Top Coat Strength" );// Assuming we go the propertyif ( oSetTCStr  ) {// Check that it's the right type to have a numeric valueif ( oSetTCStr.inherits( "DzNumericProperty" ) {// set the valueoSetTCStr .setValue( 0.1 );}}

    where Set Top Coat Strength is the label on the lsider you want.

    Post edited by Richard Haseltine on
  • rbtwhizrbtwhiz Posts: 2,249

     

    I saw there was an example script to get all the available properties, etc of a given node. http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/properties/node_properties/start

    I assume one can do the same thing for a material.

    I've just posted a Material Properties sample. Notice that both it and Node Properties have/use the same getElementProperties function (which in turn calls getGroupProperties).  This function can be used on any DzElement derived object; what changes is getting to the element to get the properties from.

    -Rob

  • evilded777evilded777 Posts: 2,464

    Thanks, Richard and Rob!

     

    I'll check out that new example.

    I had found most of what I needed by altering the script Rob gave elsewhere, but it wasn't quite what I was looking for.

    Feeling so noobish... but then my primary scripting language has always been vbScript and mostly web programming (its been years since I did any of that, though).

  • evilded777evilded777 Posts: 2,464

    Richard,

     

    can I include your load preset script as part of my script/product? With proper accreditation of course.

  • Richard HaseltineRichard Haseltine Posts: 100,463

    Yes, that's fine.

  • evilded777evilded777 Posts: 2,464

    Thanks, Richard!

    On to the next question.

    If I want to REMOVE an image map from a channel.... what would that expression be? I tired setMap(null), but struck out.

  • V3DigitimesV3Digitimes Posts: 3,123

    oProperty.setMap( "" );

    :)

  • evilded777evilded777 Posts: 2,464

    Thanks, V3Digitimes.  Very helpful.

  • evilded777evilded777 Posts: 2,464
    edited July 2015

    So... shouldn't this work:

     

    if iSpecMap != (""){

    blah blah

    }

    Because I have no clue what isMappable() is actually supposed to do...

    Post edited by evilded777 on
  • evilded777evilded777 Posts: 2,464

    And one would think

    if isMapped()

    run against a variable of which you can .getMapValue(), ought to work also.

    WTH am I missing?

     

  • Richard HaseltineRichard Haseltine Posts: 100,463

    Are you sure iSpecMap is a property and not just a string with a name? The inequality in the first post suggests the latter, in which case the isMapped, getMapValue etc. won't work on it. It is very important to do error checking - not just that you have something but, using .inherits( object name ), that it is the right kind of something (use inherits rather than isA as that is more fault-tolerant - for example, using isA( "DzSkeleton" ) would initally reliably find all figures, as distinct from a bone or other object type, but OptiTex dynamic clothing introduced a new figure type and now, in DS4, there are no more dzSkeleton objects as everything is a derivative so any script that uses isA( "DzSkeleton" ) will now fail to find any figures, while those that use inherits( "DzSkeleton" ) will continue to work).

  • evilded777evilded777 Posts: 2,464

    Richard,

     

    yes, that is really where I am falling down... this whole inheritance thing, and how to properly determine what I am looking at.

     

    I need to examine that carefully.

  • V3DigitimesV3Digitimes Posts: 3,123
    edited July 2015

    And one would think

    if isMapped()

    run against a variable of which you can .getMapValue(), ought to work also.

    WTH am I missing?

     

    From what I experimented - and rememeber- when I can ".getmap" of something, I have no error message when using "ismapped".

    What is the exact error message you have?

     

    Richard : incredible piece of information! So inherit is in general safer, and now I see why. I did not know and I don't used it a lot. I hope I won't get in trouble.

    Post edited by V3Digitimes on
  • evilded777evilded777 Posts: 2,464
    edited July 2015

    Obviously I don't understand the usage of isMapped().

    if ( oProperty.inherits( "DzNumericProperty" ) {	bMapped = oProperty.isMapped();	// Do stuff}

    In the above, the if statement checks to see if what I have is of the type DzNumericProperty; got that.

    What is bmapped = oProperty.isMapped() doing? I'm guessing we are setting bMapped to a boolean value depending on wether or not oProperty has an image map value. Is that correct? Because that does not seem to work for me.

    And just using the if part gets me a Parse Error.

    I mean... what I am doing works, but to be efficient, I really need to test is there is an image map in certain places and if not, look somewhere else for the image.

    Below if what I have so far. Its much improved thanks to Rob and Richard.  But... I really need that part about checking to see if a certain property of the material contains an image map, and I just can not figure that out.

    function setMaps(){	// get the number of selected Nodes	var iNode = Scene.getNumSelectedNodes();	for( i = 0; i < iNode; i++) {	var oNode = Scene.getSelectedNode( i );	if( ! oNode){		return;	}	if( oNode.inherits("DzBone") ){		oNode = oNode.getSkeleton();	}	var oObject = oNode.getObject();	// If we don't have an object	if( !oObject ){		// We're done... exit early		return;	}// Get the current shape for the object	var oShape = oObject.getCurrentShape();	// If we don't have a shape	if( !oShape ){		// We're done... exit early		return;	}	var iMat = oShape.getNumMaterials();		for( j = 0; j < iMat; j++){			mMaterial = oShape.getMaterial ( j);			oProperty = mMaterial.findProperty( "Bump Strength" );			iBMap = oProperty.getMapValue();			oProperty = mMaterial.findProperty( "Top Coat Bump");			oProperty.setMap( iBMap );			oProperty.setValue( 1.21 );							oProperty = mMaterial.findProperty( "Glossy Color" );			iSpecMap = oProperty.getMapValue();			oProperty = mMaterial.findProperty( "Glossiness" );			oProperty.setMap( iSpecMap );		}}	};setMaps();

     

    Post edited by evilded777 on
  • Richard HaseltineRichard Haseltine Posts: 100,463
    edited July 2015

    Yes, bMapped will be true if there's a map and false if not. So you'd want something like

    if ( oProperty.isMapped() ) {     iBMap = oProperty.getMapValue();     oProperty = mMaterial.findProperty( "Top Coat Bump" );     if ( oProperty.inherits( "DzNumericProperty" ) ) {          if ( oProperty.isMappable() ) {                oProperty.setMap( iBMap );           }     } }
    Post edited by Richard Haseltine on
  • evilded777evilded777 Posts: 2,464

    Awesome. Thanks, Richard.

     

    Got pretty much exactly what I wanted.

    If only there was a way to tell if an artist has put in a "place holder" image.

Sign In or Register to comment.