Put groups within groups to layers
-
Hi all,
when i'm exporting a SU file to 3ds Max it splits the file according to the layer structure.
But it always uses the layer of each group, eg. i have a layer "Level1" with serveral groups. But these groups contain subgroups- and these subgroups are still an layer0 -> and therefor put to "Layer0" in 3Ds.
Is there a way to put all nested groups to one specific layer?
(All geometry is still on layer0)
Thanks in advance..
Niko
-
Do you want to specify the layer or just move all subgroups to the layer of the the top group?
If it is the later then
mod = Sketchup.active_model ent = mod.active_entities sel = mod.selection sel.each{|ga| if ga.class==Sketchup;;Group ga.entities.each{|gb| if gb.class==Sketchup;;Group gb.layer=ga.layer gb.entities.each{|gc| if gc.class==Sketchup;;Group gc.layer=ga.layer gc.entities.each{|gd| if gd.class==Sketchup;;Group gd.layer=ga.layer end } end } end } end }
will handle groups nested up to 4 deep.
-
Hey,
sorry for my late reply- i was really busy with a project and therefor needed to take a break not seeing my computer for a while afterwards.
Forum was down for maintenance on sunday- and wow, a complete makeover!
Back to topic, thanks for your help!
But i could not get it to work- how is it meant to be handled?
I made a *.rb file with notepad but it gave me some error message when loaded.
Pasting it into the ruby console did't work as i can paste one line only..
I feel like i missed something as i think i remember that i had pasted some lines somewhere some time before.. but i don't know.
??
And, is it possible to extend the number of groups by adding lines in the same pattern like you did:
if ga.class==Sketchup::Group
ga.entities.each{|gb|
if gb.class==Sketchup::Groupand so on?
And relating number of brackets for sure.
-
Sorry for the late reply but I have been away all week. The code, as presented, was created and executed in Ruby Web Console. To make it a stand-alone plugin you would need to "wrap" it in a module and def like this.
module G2L def g2l mod = Sketchup.active_model ent = mod.active_entities sel = mod.selection sel.each{|ga| if ga.class==Sketchup;;Group ga.entities.each{|gb| if gb.class==Sketchup;;Group gb.layer=ga.layer gb.entities.each{|gc| if gc.class==Sketchup;;Group gc.layer=ga.layer gc.entities.each{|gd| if gd.class==Sketchup;;Group gd.layer=ga.layer end } end } end } end } end end
Place a copy in the Plugins folder so that it gets loaded when Skethsup starts. Then in the Ruby Console enter G2L.g2l to execute it.
Yes, you can add as many as you need.
Advertisement