[Closed] Rename a layer – how?
Hey Guys!
I’m trying to figure out how to rename a layer. What I’ve got now is:
CurrentLayer = LayerManager.getLayer 1
CurrentLayer.setname = "MyNewLayerName"
In the docs it says that setname is a method of the LayerProperties interface – but my usage isn’t working correctly. I guess I don’t understand the difference between a “property” and a “method” – and in this case, there aren’t any handy examples to grab syntax from. Here’s the quote from the docs:
[left]<boolean>setname <string>name
[/left]
[left]Sets the name of the layer to the given name. Returns true on success.
[/left]
[left]Note:
[/left]
[left]Layer names must be unique, which is why a method is used to set the layer name.
[/left]
If anyone can help me out here I’ll be really grateful.
-Ben
Will add examples.
As you said, it is a METHOD. You are assigning it as if it was a property.
CurrentLayer.setname "MyNewLayerName"
and not CurrentLayer.setname = “MyNewLayerName”. Methods are functions. Function calls need arguments, not assignments with ‘=’.
Anywhere you read “method”, you can think “function”. A function is code that performs some work or action and can accept arguments (parameters) to be used within that code.
Properties on the other hand store values, so you can read and write them (if writing is allowed). To write, you use the = symbol to assign the result of the right-hand side of the assignment to the property on the left-hand side. The property can contain any Max value including a Number, a Map, a Material, a Controller, a scene node and so on, depending on what type it was exposed as.
Thanks a lot Bobo. I knew that the key to getting it right lay in understanding the term, method. Now that I understand that, I’ll probably be able to get lots of other stuff right as well. I really appreciate all of your examples in the docs, and it’ll be great to have even more of them in the next version.