Help: Script that copy's names from one child layer to another

You cannot change the name of layer to a name that already exists. What you can do is move all objects and then remove the old layer, for example. Would that work for you?

Following our conversation in PM: here are two alternative actions for the script:
One that moves only curves on the XY plane:
layers-Peter-semicolon-lookup-specific-onlycurves-no-delete.py (2.8 KB)

And one that moves everything and then deletes the layer:
layers-Peter-semicolon-lookup-specific-everything-delete.py (2.7 KB)

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Thinking based on the script provided so far, that I could make a variable out of the layer_parts?

        layer_parts = layer.split("::")
NewName = layer_parts[2]

[edit]

Seem to have gotten it!! Only strange thing is the script forgets the “always” every now and then, and have to choose “always” again

            layer_parts = new_layer.split("::")
        new_name = layer_parts[2]
        print(new_name)
        rs.RenameLayer(layer, new_name)

As long as the layer is not in the same sublayer you can right? At least I believe i’ve got it almost working now :blush:

That’s correct. In reality the layer name is just the whole path to the layer at hand, including all parents, connected with :: . This means that even if just one parent is different, then the layer name is really different. It’s very good to hear that you are making progress! It’s hard to define exactly the whole behaviour, but as you are now on a good path, it should be possible for you to exactly define all remaining details.

Thanks, kind regards,

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Yeah going good, Now I just need to put this in to search for the part of the layer, instead of the split/bits part:

layer_2d = "1;pietjepuk;23-23x223-L50;metaal;1;[BLOCK]"
layer_3d = "09;pietjepuk;23-23x223-L50;metaal;6;"

layer_2d_kort = layer_2d.strip('1;' '1;[BLOCK]')

print layer_2d_kort

Which prints out

pietjepuk;23-23x223-L50;metaal

I think I infer from the PM that you mean this change (the attributes part matched till the second-last bit)

Peter_layer_Fixer_1.2.py (2.7 KB)

Yes! :slight_smile: perfect, working great!

Thank you so much! I’m glad we worked it out, together even in the end, I’m getting the hang of python scripting style already.

Hi Peter. I’m reviewing this bug, which was filed a while back based on your request. I can see that you already have the script to do what you need, but I wanted to check with you to see if there are other improvements we can bring to Make2D in V6. Have you tried the new Make2D? Does it solve some of your issues, or do you have suggestions to make it work better in your workflow?