Home Technical Talk

Mel question about specific command.

polycount sponsor
Offline / Send Message
malcolm polycount sponsor
Hello again, so I'm trying to force set a specific value into the UV toolkit. I want to run a line of script that sets Map Size to 2048
I set the value there with history turned on in the script editor, but it only captures this command.

uvTkTexelDensityChangeCB;

When I paste that command in I can't figure out what the arguments are, or if it even has any. Anyone know how I could figure this out. If the user sets this field to 0 it will cause an error in my script so I just want to force it to any other number than zero as my script runs.


Replies

  • bitinn
    Offline / Send Message
    bitinn polycounter lvl 6
    My bet: try to find the actual built-in script responsible for this, if not, learn the core API from other existing implementation?

    https://www.moddb.com/downloads/maya-mel-texel-density-td-script
  • throttlekitty
    [maya install path]\scripts\others\uvTkBuildTransformOptions.mel

    When you run across things like that, there's two ways to hunt it down. The first is the mel command "whatIs uvTkTexelDensityChangeCB". This usually returns the full path to the appropriate file.

    I've run into cases where it doesn't really know. So I do  a command line search while in [maya install path]\scripts\
    findstr /n /s /c:"uvTkTexelDensityChangeCB" *.*

    Ultimately, I'm of no help here, I can't think offhand how to put values into a text box via scripting. I'll try again in the morning unless someone smarter has that answer.

    But that script does contain a command for doing the command directly too, in case that's what you'd rather do. "texSetTexelDensity 7.5 512" for example.
  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    Yeah I just need to pre populate that value to avoid a script error, the texSetTexelDensity I actually want to be dynamic, so setting that explicitly doesn't help in that case.
  • throttlekitty
    malcolm said:
    Yeah I just need to pre populate that value to avoid a script error, the texSetTexelDensity I actually want to be dynamic, so setting that explicitly doesn't help in that case.
    Here you go.

    $TDValue = 8.5
    $TDMapValue = 512
    floatField -e -v $TDValue uvTkTexelDensityField;
    uvTkSaveToogleFloatValue("uvTkTexelDensity");
    intField -e -v $TDMapValue uvTkTexelDensityMapSizeField;
    optionVar -iv polyUVTexelDensityMapSize $TDMapValue;
  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    That's awesome, this was the magic line I was looking for to get my script working. Thank you very much for that. I just need to explicitly set the value of this one float field before my script runs to avoid it causing an error if someone accidentally has 0 set in that field. You da maaaaan.
    floatField -e -v 5.12 uvTkTexelDensityField;


  • throttlekitty
    malcolm said:
    That's awesome, this was the magic line I was looking for to get my script working. Thank you very much for that. I just need to explicitly set the value of this one float field before my script runs to avoid it causing an error if someone accidentally has 0 set in that field. You da maaaaan.
    floatField -e -v 5.12 uvTkTexelDensityField;


    uvTkSaveToogleFloatValue("uvTkTexelDensity");

    Just a heads up that this sets the option back into the preference file, there's a chance that if you don't do both, the value could get reset mid-session. (i think)
  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    I'm force setting it with each run of my script before my script executes so there should be no problem in this case.
  • Leksey
    Offline / Send Message
    Leksey polycounter lvl 6
    Try this one:
    texSetTexelDensity 142 1024;
Sign In or Register to comment.