Help with the trimleft/trimright function
I've taken my favourite script and tried to learn from it. It's probably is a bit complicated for a beginner but I really wanted to add a function to trim any leading and trailing whitespace characters and also add an option for Title case and Sentence case. I read the manual and all I can see is:
ToLower + ToUpper
Is there another way to achieve Title case and Sentence case?
Any code that I've modified has --------------#### 3dwannab code ###-------------- beside it.
The area that needs attention is:
--------------#### 3dwannab code ###--------------
( if trailing_leading = false then
for i in selection do i.name = trimleft trailing_leading
--------------#### 3dwannab code ###--------------
I'm completely suck at the minute and I wanted to chat with someone on here to help me figure out what I need to do. I've managed to get the presets working as they should. It's just the function that needs a look at.
Thanks
Comments
Success sort of
Thanks for that. I did see that in the maxscript help but I didn't get it to work, however I did this time but with unfavoured reselts.
I have three objects:
Teapot123 | Lamp123 | Chair123
I selected those objects and ran the script. All three were named to Teapot. I can see what this is doing. But it's not what I was after. It also does this when the box is unticked. trailing_leading is a boolean for the box that you tick. If off names are untouched and on the trailing and leading spaces are removed which is what I was hoping for.
I know for an experienced maxscripter this would be a piece of cake but for my 1 weeks knowledge of this launguage it's a different story.
...
Because you use only "Teapot123" and you need to do it like this
bga
Getting somewhere
Thank you.
This now works to trim unwanted spaces from left and right but when I run the script it instantly affects the names whereas I want it to toggle when I click/unclick the checkbox.
Further more it doesn't work when I type leading and trailing spaces in the upper left hand corner. And yes this is based on total commander. But obviously credit goes to 'AShim' which were his intentions from what I read over at http://www.scriptspot.com/3ds-max/scripts/rename-objects-extended
...
shorter version
bga
...
Are you tried this tool
http://www.scriptspot.com/3ds-max/scripts/interactive-universal-renamer
bga
...
Yes, I have and also Hyper renamer from TiM Scripts @ http://www.hyperent.com/Hyp-Maxscripts.php which I found to be great too.
I just wanted to use this script to learn as I like the fact you can save your settings to an INI file but I'll just have to cut my losses with this mod and try something easier to get started. Thanks for your help.
hi 3dwannab ...about
hi 3dwannab ...
about trimleft/trimright,
Has the problem resolved ?
I see you've understood now, right ?
if you researching some script, you can use print() or format() function and check the mxs listener.
it's useful to get information of any variable,
such as what is result of the variable ?
You can apply this to another variables
it's maybe out of topic but still closest to your case.
if you not familiar with print() and format(), see example:
run this script then check to mxs listener
Is pressing the F1 key ...
while the flashing cursor is on the variable the same where it takes to to maxs help file or is your method different.
I'm finding it a bit overwhelming at the minute, thanks for your help
...
If you want to assigne one unique name to selection you can try this
bga
Opps..
See the script attached. It'll be much clearer then. Basically when the box is ticked to trim trailing/leading then it does just that.
You're probably familiar with this script but I've changed the UI slightly.