View Full Version : addAttr float precision
08-14-2012, 07:01 PM
I'm surprised I haven't been able to find this anywhere. How do I change the precision of a float attribute that I am adding? By default it is only precise to one decimal place, but for this attribute I need it to be two or three decimals.
08-14-2012, 07:10 PM
Hmmm...never tried with addAttr command.
With other mel stuff I have just added the precision I needed in the base value.
float $test = 1.0000000
Maybe try that with the default value.
08-14-2012, 08:34 PM
you don't change precision. type precision is dictated by the computers processor. If you add a float attribute your precision is bound and unchangeable, the only thing you can do is round or print values at a different precision. If you want a numeric attribute that is MORE precise than a float, use a double, but a float should be more than enough for most applications (and a float still has about 13 places of precision (or thereabouts iirc))
I'm not sure why you think in this case your float is only precise to 1 decimal place, that's probably just a rounding error during printing (as MEL assumes most people don't care about displayed precision).
08-14-2012, 09:21 PM
I haven't given enough information to properly describe my question. I'm looking for precision in the channel box, specifically when scrubbing the value. I am able to type in 0.998, of course, but when I scrub I only get precision to the tenths of a unit: .1, .2, .3, .4, etc. I am hoping for the ability to scrub hundredths of a unit, so .01, .02, .03, .04.
08-14-2012, 10:08 PM
ah! well that's completely different... I think you just hold down CTRL or ALT when scrubbing for smaller increments don't you?
08-14-2012, 10:37 PM
That does the trick (holding Ctrl). I thought there was some flag I had to set or something during the addAttr. Maybe there still is one I can set. This definitely gets the job done though. Thanks!
08-14-2012, 10:37 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.