Here is the final script in action:
Like most things, first I figured out how I could make a system that did this, then I created a maxscript so other people could operate it and I didn't have to perform the setup each time.
So what needs to be done?
You want to take the width of the text (textWidth) and scale it by a number such that it equals the width of the target object (targetWidth)
You can do this by:
targetWidth/textWidth = scaleFactor
finds the mutiple needed to get the textWidth to be the same value as the targetWidth
textWidth * scaleFactor
makes the textWidth the same value as the targetWidth by multiplying by the scaleFactor
makes the textWidth the same value as the targetWidth by multiplying by the scaleFactor
So how can we perform this in 3dsMax?
First we need the width of the targetWidth. After a quick Google, I found you can get the boundary box width of an object through an Expose Transform tool. Although you could also use the width value of the rectangle, this method means you could apply it to a different shape easily if need be.
Now we need the textWidth. Again I can use an Expose Transform.
So if I have for example, text that was 200 wide that needed to fit within a space that is 100 wide, we would get:
100/200 = 0.5
targetWidth/textWidth = scaleFactor
We can check this. If we take 200 and multiply by 0.5 we get 100 which is correct.
As I don't necessarily want to affect the scale of the text, the scale factor would also work with the size parameter, as it is merely a multiple of what needs to be applied.
This is the final maxscript I created for the function.
Finally add a simple UI and you have a nice little script:





No comments:
Post a Comment