Hey everyone I am looking for a quick way to take an existing object and specify its dimensions. For example if I have a box of a random size, I would like to select it, open some sort of menu, and type of 5x5x5 to make it a 5 unit by 5 unit x 5 unit box.
What's the best way to go about doing somthing like that?
Replies
Apply it to your mesh and think of it like the Photoshop transform box
Save script in startup folder to make it start with max. (not essential)
Customize UI
Toolbars
rt Tools
Drag onto UI.
http://www.robertfletcher.org/public_files/Scripts/rt_redim.ms
updated: Added Preserve Proportions checkbox, made Undoable
Would also be neat if it allowed you to enter dimensions other than the current unit scale (so I could enter in inches and it would automatically convert it).
Right now it just works on the last item in your selection, might be nice if it worked on all selected objects and treated them as a group.
Another nice feature would be to transfer the dimension of one object to another some how, or save the dimensions so you could use them later.
Shouldnt be difficult. Max handles all this internally. I dont know why it doesnt work allready actually, its probably because im using spinners. Most input fields in max support unit conversion. Eg. your working in CM and type in 6' (6 foot) into a field it will convert it on the fly to 182.88cm
Be specific on the exact behavior your looking for. Working on a group of objects isnt a problem. Scaling as a group may be trickier. It should be doable to apply a scale factor to the whole selection and snap to grid dimensions
not a problem.
Now i just need to get time to do it all
I really would like to encourage you and other that are interested to have a look at the script(s) that are posted in this thread. Read them at least once and you will notice its not a impossible thing to understand.
Once you get dirty yourself its all about googling for reference snippets or asking around here but it will give you such a different picture of what is possible workflow wise. Whenever something bugs me in Max or a work flow I usually end up writing a small script that enables me to do tedious tasks in just matter of clicks.
Plus it gets more creative folks writing tools and understanding what makes things tick.
Update wise, I've added a function to resize an object to the nearest whole grid units. and also to position it at the nearest grid position. basically you can take any object and conform it to the grid in 2 clicks. I haven't effected the objects Pivot. Could you guys give it a go and make a suggestion on how you would like the pivot to be placed.
The conform and position buttons work across your entire selection.
http://www.robertfletcher.org/public_files/Scripts/rt_redim.ms
I wrote a script this morning that snaps an object to the nearest grid point and it took me quite awhile to do because I kept getting a syntax error that turned out to be a single character.
Right now i'm trying to just learn how to use 3dsmax, but I assure you I'm also dabbling in script along side working on my project. It just takes time.
So I wont turn down an offer if someone awesome like r_fletch_r drops by
Belive me I'll be looking at the script and using it as an example for others. I'm already modifying little bits of it to suit my needs and learning a ton in the process.
That said, I completely agree with you, its best to use these generosity scripts as a foundation to kick start your own scripting education and not as a crutch.
@r_fletch_r
I used really poor wording when talking about modifying the selection as a group.
Features:
Specifically, I would just like it to loop through each object in the array and make each one the specified dimensions.
It would also be really useful if this tool could get the distance between two selected polygons and then align a pre-specified object to the center of those polygons and scale it (either uniformly or along a single axis) so that the top and bottom, left and right, front or back, of the bounds of that object are flush with the two polygons.
An example of using this feature would be making a pillar and then specifying it as as the source mesh. Then selecting the "floor" and "roof" of a room. If the tool is run with this input it would then move the pillar to the center of the floor and roof polygons and re-size it so it fit perfectly in between them.
It might also be useful if there was an option to have it make instances of the objects instead of just moving them. So it would leave the original pillar in place and instead create an instance of the pillar and move/re-size it.
Just a thought, might be a way to implement that in a more open ended/useful way.
Bugs:
Conform to grid will make the object dimension 0 if its size is half a grid unit smaller than the current grid size. So if I have a box that 254 244 254 and my grid size is 512 that box will be resized to zero. When the box is esactly have the current gridsize I get odd results where one dimension sometimes goes up and another sometimes goes to 0.
Hitting the "position on grid" button on an object that is off grid results in some odd behavior. If I hit the button multiple times the object will keeping going back and forth between one position and another (neither of which are actually on grid).
If you make a change that works well post it!
I broke it though, hehe. But it might not matter for what most ppl would use it for.
I rotated the object while resizing it, with the xform on, and it got all jacked. Then I rotated it back flat, and it was somewhat working as far as conforming to the grid in x,y, but z was broke. Then all of a sudden it reformed again, but the spinner values went to 9999.999.
I know from experience that doing local to world space Rotation math / vice versa can be a pain in the ass though.... : \ I can't seem to wrap my head around it yet. Some people said it took them years.
Lol, that's just the only customization I have made so far, just playing around. I am looking into writing a few more things. Just playing around. Kudos to MattLichy for helping me with that.
Update.
*You can type any measurement into the fields now and it will convert them to generic units. so typing 1m, 20cm, 6'12" and so on will all work.
*Setting the size,conforming and positioning work across the entire selection
*Zero scale bug fixed, if the closest grid point is 0 then the grid width is used instead.
*Copy and paste added. copy takes dimensions from 1st object in selection. paste applies to entire selection on a per node basis
The changes I made start on line 117 (of the version you posted prior to you update)
By the way, where is your update? I tried re-downloading the file and its the same?
http://www.robertfletcher.org/public_files/Scripts/rt_redim_2.ms
FEATURE: I REALLY liked having the spinners and being able to drag the values around. If there were some way to have those back it would be really nice.
BUG: If I enter "12ft" it gives me a runtime error and the entire thing stops working.
BUG: If I enter 12cm, it works, but the if I try to conform it to the grid its off by a decimal amount and then I have to hit "conform to grid" again to get whole number values.
If you have any idea about a good way to to have the current grid size displayed and updated in real time let me know. Even if you don't want to include it in the final script I would really like to have it on my end so I can see what grid i'm working on.
Thanks so much for all your help so far, this thing is really shaping up nicely
I removed the spinners so generic input could happen. Might be able to do both.
Updating the the Grid display per tick isnt going to add any major overhead.
I typed in 00 into the width. Maybe don't allow for ppl to type that in.
Also, if I sit and click conform to grid and position back and forth, AFTER the object has been rotated, the object hops around the grid, and starts moving further and further away. I think partially because the pivot gets separated from the mesh?
Spinners next to the width/depth/height editText boxes would be helpful
Ah, okay, it just seamed like it might be bad. The UI flickers a little, but its not big deal. I will just leave it as is then. Thanks
Changes:
*Rewrote Entire UI/ resizing function, much cleaner/modular now, more error checking, no UI flicker.
*Local rotation should no longer cause problems neither should scale.
*Everything works on entire selection.
thanks
I could modify it to update your value in the window in addition to setting the grid size, but that's a less robust solution if I ever use another tool or anything else that modifies the grid size in the future. So I just figured it would be good to watch for a change an then update if one occurs.
If you think its a bad idea though I could just have my gridsize script update your spinner value instead.
Updated
*All undos should work, Im not too happy with the work around but it works. it could get slow if your working with hundreds of objects(at once).
*Added Realtime update of gridsize as suggested by mattLichy also changed Gridsize spinner use floats rather than integers.
Download
So the big question, hows it working for you? I hope its looking usefull, i have no idea if ill ever use it myself :poly142:
http://dl.dropbox.com/u/2997790/rt_redim_3_jocoseMod.ms
You can search for --jocose to see all my changes
Oh, just saw your post. Its working great! I have been using it constantly while building my environment. Really good for blocking everything out, been helping to keep me organized with all the different sized assets I'm making.
Thanks so much for all your help. Sorry I can't directly contribute more, trying to balance learning macscript with getting some art done
Actually the snap i wrote snaps the lower corner of the object to the nearest grid point. Yours uses the pivot yeah?
I figured a corner would make it easier to fit meshes together
I was planning to expand upon this and let the user pick a corner to snap or the pivot point. so basically a 5 button grid 1 for each corner and the pivot
If you do end up implementing the grid of buttons that would be better
I have noticed several times that the position values given for an object are not perfectly on grid when I use your button, and if I use the button several times on some assets they jump around each time I use the tool.
You should be able to re-create this by making a box and then trying to run the tool on it, and press it over and over again.
Basically when I put something on grid I expect that it will be using whole numbers for its position provided its pivot is at its center.
Doing it with a TM and a lot of verts would be pretty slow though.
Im getting kind of addicted to transformation Matrixs. They seem to make so many things easier