Orphanize layers

Hello all,

I was looking for the way to move away all child layers from its parent layer. I didn’t find it, so I made a small script than can do that. You only have to type on the script the name of the parent layer.

I hope you can find it useful.
Orphanize Layers.js (702 Bytes)

I’d like to take the plunge into scripting for QCAD, mostly just to learn how it all works. I’m not much of a programmer but I’m hoping I can figure out a few basics. I thought I’d start with running this script to make sure I’m at least able to execute a script in the first place. It tried running this from within the QCAD GUI using the run script tool, and I also put it inside of the scripts folder, but I can’t seem to get it to work. What am I missing?

Did you set the parentLayerName variable in the script?

var parentLayerName = "a"; // name of parent layer

If parent layer name is not “a”, you should change it to correct one.

Alternatively, you can click (select) the top child layer, then shift-click the bottom child layer and choose Layer > Delete Layer(s).

dfriasb, that makes sense. I was thinking there would be a pop up while inside QCAD where I had to enter or choose the layer.

andrew, I think the script moves the child layers out of child status, rather than just deleting them. Either way I don’t have a direct need for the functionality, but I thought it looked like a reasonable script to try to figure out so I can learn some scripting.

Thanks both of you.

I was thinking there would be a pop up while inside QCAD where I had to enter or choose the layer.

That’s how it should be. But I’m sorry I’m not so good scripting; I just left this script for the mother layer name “a”, and I change it directly in the script when needed…

Well it’s a lot better than I could do! It gives me a good script to look at and try to reverse engineer and try to figure out what each line of code is doing. My programming knowledge is very basic so I kind of understand objects and methods but I haven’t spent a lot of time with creating and working with them.