Orphanize layers

Please contact a Moderator to submit *Only Finished Scrips/Plug-in's here (include relevant tutorials).

Moderators: andrew, Husky, J-J

Post Reply
User avatar
dfriasb
Senior Member
Posts: 117
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Orphanize layers

Post by dfriasb » Sun May 10, 2020 9:26 pm

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.
Attachments
Orphanize Layers.js
(702 Bytes) Downloaded 173 times
David Frías Barranco | architect
[email protected] | davidfriasarquitecto.es

User avatar
ryancousins
Full Member
Posts: 60
Joined: Thu Mar 19, 2020 3:47 am
Location: Kalamazoo, Michigan USA

Re: Orphanize layers

Post by ryancousins » Fri Feb 19, 2021 1:04 am

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?

User avatar
dfriasb
Senior Member
Posts: 117
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Re: Orphanize layers

Post by dfriasb » Fri Feb 19, 2021 9:26 am

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.
David Frías Barranco | architect
[email protected] | davidfriasarquitecto.es

User avatar
andrew
Site Admin
Posts: 7413
Joined: Fri Mar 30, 2007 6:07 am

Re: Orphanize layers

Post by andrew » Fri Feb 19, 2021 10:09 am

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

User avatar
ryancousins
Full Member
Posts: 60
Joined: Thu Mar 19, 2020 3:47 am
Location: Kalamazoo, Michigan USA

Re: Orphanize layers

Post by ryancousins » Fri Feb 19, 2021 1:44 pm

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.

User avatar
dfriasb
Senior Member
Posts: 117
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Re: Orphanize layers

Post by dfriasb » Fri Feb 19, 2021 2:50 pm

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...
David Frías Barranco | architect
[email protected] | davidfriasarquitecto.es

User avatar
ryancousins
Full Member
Posts: 60
Joined: Thu Mar 19, 2020 3:47 am
Location: Kalamazoo, Michigan USA

Re: Orphanize layers

Post by ryancousins » Fri Feb 19, 2021 3:23 pm

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.

Post Reply

Return to “Finished 'Ready to go' Scripts/Plug-in's”