Page 1 of 1

Orphanize layers

Posted: Sun May 10, 2020 9:26 pm
by dfriasb
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.

Re: Orphanize layers

Posted: Fri Feb 19, 2021 1:04 am
by ryancousins
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?

Re: Orphanize layers

Posted: Fri Feb 19, 2021 9:26 am
by dfriasb
Did you set the parentLayerName variable in the script?

Code: Select all

var parentLayerName = "a"; // name of parent layer
If parent layer name is not "a", you should change it to correct one.

Re: Orphanize layers

Posted: Fri Feb 19, 2021 10:09 am
by andrew
Alternatively, you can click (select) the top child layer, then shift-click the bottom child layer and choose Layer > Delete Layer(s).

Re: Orphanize layers

Posted: Fri Feb 19, 2021 1:44 pm
by ryancousins
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.

Re: Orphanize layers

Posted: Fri Feb 19, 2021 2:50 pm
by dfriasb
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...

Re: Orphanize layers

Posted: Fri Feb 19, 2021 3:23 pm
by ryancousins
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.