Home Coding, Scripting, Shaders

[Maxscript] Make layer from object name script not trimming properly

ngon master
Offline / Send Message
zachagreg ngon master
macroscript LayerFromName category:"Custom" <br>	tooltip:"LayerFromName"<br>	ButtonText: "LFN"<br>	<br>(	<br>	if selection.count != 0 do<br>	(<br>		for o in selection do<br>		(<br>			objName = trimleft o.name "o_"<br>			if (objLayer = LayerManager.getLayerFromName objName) == undefined then<br>			(<br>				objLayer = Layermanager.newLayerFromName objName<br>				objLayer.addNode o<br>			)<br>			else<br>			(<br>				objLayer.addNode o<br>			)<br>		)<br>	)<br>)
Hey all,

I've been using the above script in order to select all of the objects I need and then make layers from the name's of the object to remove the "o_" identifier we use for our project. Recently I've been using it to just organize my high and low poly objects quickly. I've noticed that even if the object doesn't have the prerequisite o_ it will still trimleft the first two characters of the name. I believe I am misunderstanding the trimleft command. Can someone tell me what I am doing wrong and possibly some advice on how to do it properly?


Replies

  • Tekoppar
    Offline / Send Message
    Tekoppar polycounter lvl 10
    Is that the exact code you're using? I tried it and it works like it should in Max 2017, it removes ALL leading "o" "_" characters from the string. Box001 = Box001, _Box001 = Box001, o_Box001 = Box001 and __oooo___Box001 = Box001.
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Yep, that's the exact code I'm using I will try to re-install it because I remember writing it like that because I wanted that functionality. Although lately in Max 2017 it's just been deleting the first two characters regardless and I have no clue how that could change.

    Edit: Okay just reinstalled the script and swapped out the button on my toolbar. It is now functioning properly. Any idea how that could happen? How functionality of a script would change?
  • Noors
    Offline / Send Message
    Noors greentooth
    I don't see how it could happen unless you've overwritten your macroscript at some point.
    When you evaluate a macroscript, it gets copied in some Max folder and is executed from there. Maybe you've evaluated an old version of your script and didn't reevaluate after changing it.


  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Thanks to both of you, I must've done that at some point probably testing something and forget that I compiled it.
Sign In or Register to comment.