Display Schematic Models
-
I'm trying to do a code to create a schematic design A , B , C to keep each type in layers which for the final process , I can display each schematic model at the same position by switching on button. For example , if I select Scheme-B , the model of A and C are invisible.Only Scheme-B display.
What I can't do is to " Display All Schemes by ranging left to right " I wonder if there's a way to move group of schematic models to show all ?.
def create_scheme_A model = Sketchup.active_model sel = model.selection entities = model.active_entities edge_layer = model.layers.add("Pattern-A") face_layer = model.layers.add("Glass-A") group_layer = model.layers.add("Aluminium-A") sel.each{|e| e.layer = edge_layer if e.is_a? Sketchup;;Edge e.layer = face_layer if e.is_a? Sketchup;;Face e.layer = group_layer if e.is_a? Sketchup;;Group } group1 = entities.add_group(sel) # Add a layer layer = Sketchup.active_model.layers.add "Scheme-A" # Put the face on the Scheme-A layer newlayer = group1.layer = layer # entity $entityA = group1.layer # Hide the layer. layer.visible = false group2=group1.copy l = Sketchup.active_model.layers.add("Original-A") newlayer = group2.layer = l l.visible = true if group2.explode instances=[]; entities.each{|e|instances.push(e) if e.typename=="Group"} group_layer.visible = false model = Sketchup.active_model layers = model.layers layers.add "Original-A" activelayer = model.active_layer = layers[1] layer = model.active_layer end end def create_scheme_B model = Sketchup.active_model sel = model.selection entities = model.active_entities edge_layer = model.layers.add("Pattern-B") face_layer = model.layers.add("Glass-B") group_layer = model.layers.add("Aluminium-B") sel.each{|e| e.layer = edge_layer if e.is_a? Sketchup;;Edge e.layer = face_layer if e.is_a? Sketchup;;Face e.layer = group_layer if e.is_a? Sketchup;;Group } group1 = entities.add_group(sel) # Add a layer layer = Sketchup.active_model.layers.add "Scheme-B" # Put the face on the Scheme-A layer newlayer = group1.layer = layer # entity $entityB = group1.layer # Hide the layer. layer.visible = false group2=group1.copy l = Sketchup.active_model.layers.add("Original-B") newlayer = group2.layer = l l.visible = true if group2.explode instances=[]; entities.each{|e|instances.push(e) if e.typename=="Group"} group_layer.visible = false model = Sketchup.active_model layers = model.layers layers.add "Original-B" activelayer = model.active_layer = layers[1] layer = model.active_layer end end def create_scheme_C model = Sketchup.active_model sel = model.selection entities = model.active_entities edge_layer = model.layers.add("Pattern-C") face_layer = model.layers.add("Glass-C") group_layer = model.layers.add("Aluminium-C") sel.each{|e| e.layer = edge_layer if e.is_a? Sketchup;;Edge e.layer = face_layer if e.is_a? Sketchup;;Face e.layer = group_layer if e.is_a? Sketchup;;Group } group1 = entities.add_group(sel) # Add a layer layer = Sketchup.active_model.layers.add "Scheme-C" # Put the face on the Scheme-A layer newlayer = group1.layer = layer # entity $entityC = group1.layer # Hide the layer. layer.visible = true if group1 instances=[]; entities.each{|e|instances.push(e) if e.typename=="Group"} group_layer.visible = false model = Sketchup.active_model layers = model.layers layers.add "Scheme-C" activelayer = model.active_layer = layers[1] layer = model.active_layer end end def scheme_A_active model = Sketchup.active_model layers = model.layers layer_pattern_A = layers.add("Pattern-A") layer_glass_A = layers.add("Glass-A") layer_aluminium_A = layers.add("Aluminium-A") layer_scheme_A = layers.add("Scheme-A") # Open the layer. layer_pattern_A.visible = true layer_glass_A.visible = true layer_aluminium_A.visible = true layer_scheme_A.visible = true layer_pattern_B = layers.add("Pattern-B") layer_glass_B = layers.add("Glass-B") layer_aluminium_B = layers.add("Aluminium-B") layer_scheme_B = layers.add("Scheme-B") # Hide the layer. layer_pattern_B.visible = false layer_glass_B.visible = false layer_aluminium_B.visible = false layer_scheme_B.visible = false layer_pattern_C = layers.add("Pattern-C") layer_glass_C = layers.add("Glass-C") layer_aluminium_C = layers.add("Aluminium-C") layer_scheme_C = layers.add("Scheme-C") layer_pattern_C.visible = false layer_glass_C.visible = false layer_aluminium_C.visible = false layer_scheme_C .visible = false end def scheme_B_active model = Sketchup.active_model layers = model.layers layer_pattern_A = layers.add("Pattern-A") layer_glass_A = layers.add("Glass-A") layer_aluminium_A = layers.add("Aluminium-A") layer_scheme_A = layers.add("Scheme-A") # Hide the layer. layer_pattern_A.visible = false layer_glass_A.visible = false layer_aluminium_A.visible = false layer_scheme_A.visible = layer_pattern_B = layers.add("Pattern-B") layer_glass_B = layers.add("Glass-B") layer_aluminium_B = layers.add("Aluminium-B") layer_scheme_B = layers.add("Scheme-B") # Open the layer. layer_pattern_B.visible = true layer_glass_B.visible = true layer_aluminium_B.visible = true layer_scheme_B.visible = true layer_pattern_C = layers.add("Pattern-C") layer_glass_C = layers.add("Glass-C") layer_aluminium_C = layers.add("Aluminium-C") layer_scheme_C = layers.add("Scheme-C") layer_pattern_C.visible = false layer_glass_C.visible = false layer_aluminium_C.visible = false layer_scheme_C .visible = false end def scheme_C_active model = Sketchup.active_model layers = model.layers layer_pattern_A = layers.add("Pattern-A") layer_glass_A = layers.add("Glass-A") layer_aluminium_A = layers.add("Aluminium-A") layer_scheme_A = layers.add("Scheme-A") # Hide the layer. layer_pattern_A.visible = false layer_glass_A.visible = false layer_aluminium_A.visible = false layer_scheme_A.visible = false layer_scheme_B = layers.add("Scheme-B") layer_pattern_B = layers.add("Pattern-B") layer_glass_B = layers.add("Glass-B") layer_aluminium_B = layers.add("Aluminium-B") # Hide the layer. layer_scheme_B.visible = false layer_pattern_B.visible = false layer_glass_B.visible = false layer_aluminium_B.visible = false # Open the layer. layer_pattern_C = layers.add("Pattern-C") layer_glass_C = layers.add("Glass-C") layer_aluminium_C = layers.add("Aluminium-C") layer_scheme_C = layers.add("Scheme-C") layer_pattern_C.visible = true layer_glass_C.visible = true layer_aluminium_C.visible = true layer_scheme_C.visible = true end
-
This can be done without Ruby code, using component for each scheme, and then a scene page for each scheme (with only IT's layer ON,) and then an additional ALL scene page that has only the ALL layer ON, which has duplicate instances ranged from left to right.
Be sure "Scene Tabs" are checked ON, in the "View" menu. (So you can switch between schemes easily.)
-
Thanks Dan ! , I never realized about this method. My supervisor wants me to switch schemes for " DESIGN COMPARE " at the same position to open and hide layers , then show all schemes by coding. The layers now are overlapped.If I can't do at the end I will do only Switch One by One.
Youtube Video
Advertisement