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
Moderators: andrew, Husky, J-J
- dfriasb
- Senior Member
- Posts: 119
- Joined: Thu Mar 10, 2016 1:08 pm
- Location: Calafell, Tarragona, Spain
Orphanize layers
- Attachments
-
- Orphanize Layers.js
- (702 Bytes) Downloaded 1531 times
- ryancousins
- Premier Member
- Posts: 367
- Joined: Thu Mar 19, 2020 3:47 am
- Location: Michigan, USA
Re: Orphanize layers
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?
- dfriasb
- Senior Member
- Posts: 119
- Joined: Thu Mar 10, 2016 1:08 pm
- Location: Calafell, Tarragona, Spain
Re: Orphanize layers
Did you set the parentLayerName variable in the script?
If parent layer name is not "a", you should change it to correct one.
Code: Select all
var parentLayerName = "a"; // name of parent layer
Re: Orphanize layers
Alternatively, you can click (select) the top child layer, then shift-click the bottom child layer and choose Layer > Delete Layer(s).
- ryancousins
- Premier Member
- Posts: 367
- Joined: Thu Mar 19, 2020 3:47 am
- Location: Michigan, USA
Re: Orphanize layers
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.
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.
- dfriasb
- Senior Member
- Posts: 119
- Joined: Thu Mar 10, 2016 1:08 pm
- Location: Calafell, Tarragona, Spain
Re: Orphanize layers
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...I was thinking there would be a pop up while inside QCAD where I had to enter or choose the layer.
- ryancousins
- Premier Member
- Posts: 367
- Joined: Thu Mar 19, 2020 3:47 am
- Location: Michigan, USA
Re: Orphanize layers
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.