Group by Layer

Group by Layer

Postby JQL » Thu Aug 11, 2022 2:54 pm

Hi there,

I haven't posted regularly here for a long time, but I've started following the forum again and I will try posting more again.

I think I have used a plugin in the past that would group objects by layer but I might be imagining things. Has anyone got any idea if such a plugin exists?

Thanks in advance!
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: Group by Layer

Postby Box » Thu Aug 11, 2022 3:07 pm

What is this strange thing you refer to, Layer, never head of it.
1
User avatar
Box 
 

Re: Group by Layer

Postby Rich O Brien » Thu Aug 11, 2022 3:15 pm

If you right click the tag/layer in tag/layer panel and choose...



...then group that selection
1
User avatar
Rich O Brien 
Administrator
 

Re: Group by Layer

Postby Rich O Brien » Thu Aug 11, 2022 3:16 pm

Box wrote:What is this strange thing you refer to, Layer, never head of it.


Just locking his poor spelling before he edits :P
2
User avatar
Rich O Brien 
Administrator
 

Re: Group by Layer

Postby JQL » Thu Aug 11, 2022 3:26 pm

Box wrote:What is this strange thing you refer to, Layer, never head of it.


My head always heads layers but I head it's tags now, you head right!
Thanks Box! :D

So Group by Tag anyone?
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: Group by Layer

Postby Box » Thu Aug 11, 2022 3:28 pm

Bloody autocorrect.
0
User avatar
Box 
 

Re: Group by Layer

Postby Box » Thu Aug 11, 2022 3:30 pm

Rich O Brien wrote:
Just locking his poor spelling before he edits :P

You write a thousand eloquent posts, do they call you box the eloquent...
You shag one sheep!
0
User avatar
Box 
 

Re: Group by Layer

Postby Rich O Brien » Thu Aug 11, 2022 3:33 pm

JQL wrote:So Group by Tag anyone?


What's wrong with the vanilla approach?

Box wrote:You shag one sheep!

They call you Kiwi
1
Last edited by Rich O Brien on Thu Aug 11, 2022 3:33 pm, edited 2 times in total.
Reason: Edited without reason on 11/08/2022
User avatar
Rich O Brien 
Administrator
 

Re: Group by Layer

Postby JQL » Thu Aug 11, 2022 3:34 pm

Rich O Brien wrote:If you right click the tag/layer in tag/layer panel and choose...



...then group that selection


That's pretty cool, I was using selection toys.

However, too many right-clicks, I think I would rather keep things unorganized.

a bit too much right clicks, I can handle as it is.gif
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: Group by Layer

Postby Rich O Brien » Thu Aug 11, 2022 3:35 pm

I'm pretty sure TIG wrote a snippet for this at one point. I'll try find it
0
User avatar
Rich O Brien 
Administrator
 

Re: Group by Layer

Postby JQL » Thu Aug 11, 2022 3:37 pm

You're too cool! Thanks!
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: Group by Layer

Postby Rich O Brien » Thu Aug 11, 2022 3:43 pm

Or set this...



...then click the chevron to expose details...



...then install and test if TIG's description suggests it may do what you need.
0
User avatar
Rich O Brien 
Administrator
 

Re: Group by Layer

Postby Rich O Brien » Thu Aug 11, 2022 3:48 pm

I knew he posted a snippet once...

viewtopic.php?p=427644#p427644

...fails in 2022 though. Maybe he'll see this thread and chime in.
0
User avatar
Rich O Brien 
Administrator
 

Re: Group by Layer

Postby JQL » Thu Aug 11, 2022 3:50 pm

I think the objective of that one is to have edges and faces sent to layer0. That is aimed at fixing most errors caused by having raw geometry in that layer.

In my case I really don't want to loose the layer of raw geometry unless it becomes grouped by layer first and the group is given that same layer.

So, what I want to do is exactly what you showed on your image: go through each layer, select objects and group them; if possible change the group from Layer0 into the selected layer; and then I can send all raw geometry into Layer0 as it has already been grouped and the group is in the correct layer.

I'm going to read better what each of those Layer plugins does.

@Box, just replace each of the "layer" above by "tag" and you get the point.

@Rich, I was replying to your previous post. I will see what you posted now.
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: Group by Layer

Postby JQL » Thu Aug 11, 2022 3:59 pm

Rich O Brien wrote:I knew he posted a snippet once...

viewtopic.php?p=427644#p427644

...fails in 2022 though. Maybe he'll see this thread and chime in.


The description he has in the snippet post is exactly what I need.

Bummer!

It would be very cool if he would chime in indeed.
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: Group by Layer

Postby Rich O Brien » Thu Aug 11, 2022 4:57 pm

I was wrong. It does work...

Code: Select all
m=Sketchup.active_model;a=m.active_entities;s=[];m.start_operation("!");a.to_a.each{|e|s<<e if e.layer==m.layers[0]};g=a.add_group(s);g.name=m.layers[0].name;g.layer=nil;(g.entities.each{|i|i.layer=nil})unless s.empty?;m.layers.to_a[1..-1].each{|l|s=[];a.to_a.each{|e|s<<e if e.layer==l};next if s.empty?;g=a.add_group(s);g.name=l.name;g.layer=l;g.entities.each{|i|i.layer=nil};};m.commit_operation;


You need to have a group selected that is on Layer0 it then iterates through the model groups things to layer
0
User avatar
Rich O Brien 
Administrator
 

Re: Group by Layer

Postby JQL » Thu Aug 11, 2022 5:06 pm

It must be a group? I will try it then. Just paste this in the console, right?
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: Group by Layer

Postby Rich O Brien » Thu Aug 11, 2022 5:20 pm

It seems so. I'm not 100% on what needs to be selected but it seems to rename the selected group and then do some magic.

Try on sample first
0
User avatar
Rich O Brien 
Administrator
 

Re: Group by Layer

Postby JQL » Thu Aug 11, 2022 5:59 pm

Too late, I've tried it in the model directly and it's taking a lot of time. I don't know if I should just shut it down, try it in a sample, and then leave it on the whole night. It might finish right now, or it might take a week... who knows?
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: Group by Layer

Postby JQL » Thu Aug 11, 2022 10:47 pm

So I made a simple model and tested the snippet without selecting anything. It works flawlessly.

I don't think it iterates inside groups. Only tried on loose geometry, but I'm going to try That.

EDIT: What it does seems to be doing is grouping all groups in the model into a new group called Layer0. It doesn't act inside those groups. This is cool and a way to control the scope.

Geometry to be affected by the snippet should be in root of the model.

EDIT2: Groups that are tagged already, get their objects inside grouped and stripped from tags. This happens even if they have no tags. All other groups are grouped together in a group called Layer0
0
User avatar
JQL 
Premium Member
Premium Member
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Extensions & Applications Discussions

Who is online

Users browsing this forum: ezyuzin and 2 guests