Ambiguous layer names

Hi Chaps

I’m trying to SelectObjectsByLayer – however, when there are duplicate layer names in different layers, this becomes an issue, as the SelectObjectsByLayer call fails.

The McNeel recommendation is to use the full path of all layer names, separated by two semi-colons…

So, if I had a layer “A” with sub-layer “B”, and I wanted to work with sub-layer “B”, I would have to use the layer name “A::B”
Thus, if layer “Z” also had a sub-layer “B”, a call to use the layer would not fail (as opposed to the failure if only the ambiguous name of “B” was used)

This works fine, until the following scenario occurred…
Two layers:

  • A::b::C
  • B::C

If I want to use layer “B::C” (The second stand-alone layer) a call that uses this layer (selectobjectsbylayer, for example) fails.
This is as a result of the same reason previously described.
The layer name “B::C” is ambiguous.
However, in this case, there is no means to identify layer “B::C” in any other fashion, in order to make it more unique, or less ambiguous.

The call returns a NULL value in the case of an ambiguous layer name being supplied.
(But in the case of the example cited, there is no way to avoid the ambiguity in order to identify the layer)

Please advise how this can be done.

Kind regards

I’m not sure of the ambiguity here… Can you post a full script and a sample file that fails?


ObjectsByLayer("B::C",True) should select the objects on the second “C” layer in your list, whereas

ObjectsByLayer("A::B::C",True) should select the objects on the first “C” layer.

Also, to get objects on the “B” layer:

ObjectsByLayer("A::B",True) should get the objects on the first “B” layer, whereas

ObjectsByLayer("B",True) should get the objects on the second…


Hi Mitch

Thanks for the response.

I’ve gone deeper into my code, in order to create a summary script that should be able to replicate and demonstrate the problem.

Turns out I’m using “IsLayerChildOf” to determine layer validity… which works – but produces a false response when there are two layers with the same name, and both layers have the same child names too…

(I’m validating layers from the ends of the branches, backwards towards the root, rather then starting at the root…)

I need to reorganise the manner in which I test the layers – which should resolve the problem.

Thanks again



Yep, that would do it… I usually work from the parent end and generally, if you have no idea how deep layers are nested, you need to use recursion to make sure you get all the way up the branch to the last child layer level…