sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Find Group name

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 2 Posters 268 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      hermannausowl
      last edited by

      How can I find the name of the active group by program?

      http://www.momo-moebel.de/fileadmin/service/Szene.tiff

      Wir planen Ihre Büroeinrichtung mit SketchUp. http://www.momo-moebel.de

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        I assume you mean that you are editing a group and need to find its name...
        Try:

        def context()
        model=Sketchup.active_model
        context=model.active_entities.parent
        if context==model
          return "MODEL; "+model.title
        elsif context.group?
          return "GROUP; "+context.instances[0].name
        elsif ! context.image?
          return "COMPO; "+context.name
        end
        end
        

        This method 'context' returns the model name OR the group name OR if it's a component name of the definition... [you can't easily get an instance's name while you are inside it as you are editing the definition itself]...

        TIG

        1 Reply Last reply Reply Quote 0
        • H Offline
          hermannausowl
          last edited by

          Thanks for the quick reply.
          With a method I want to open the doors and needed to know whether it is the left or right door.

          Wir planen Ihre Büroeinrichtung mit SketchUp. http://www.momo-moebel.de

          1 Reply Last reply Reply Quote 0
          • H Offline
            hermannausowl
            last edited by

            How do I find the name of the selected door?

            Wir planen Ihre Büroeinrichtung mit SketchUp. http://www.momo-moebel.de

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              You give barely enough background information 😒

              name=Sketchup.active_model.selection[0].name if Sketchup.active_model.selection[0].respond_to?(:name)
              returns the name of a selected entity if it has a name method...

              or

              ` Sketchup.active_model.selection.each{|e|
              if e.respond_to?(:name)
              name=e.name

              do something with name ?

              end
              }`

              There are many scenarios... 😕

              TIG

              1 Reply Last reply Reply Quote 0
              • H Offline
                hermannausowl
                last edited by

                I find a way.

                     # {Ecken von ausgewaehlten Elementen ermitteln()
                      #
                      def ecken_ermitteln
                
                        model         = Sketchup.active_model
                        entities      = model.active_entities
                        auswahl       = model.selection  
                        context       = auswahl.first       
                        MoMo;;g_name  = context.name                       
                        MoMo;;teile   = entities.add_group auswahl
                        model.selection.add(MoMo;;teile)
                        auswahl       = model.selection
                     
                        e             = auswahl.at(0)
                        bounds_a      = e.bounds 
                        MoMo;;x_mass  = bounds_a.width
                        MoMo;;y_mass  = bounds_a.height 
                        MoMo;;z_mass  = bounds_a.depth
                        MoMo;;i_li    = bounds_a.corner(2)[0] if MoMo;;tuer_c_o_li == 0
                        MoMo;;i_re    = bounds_a.corner(3)[0] if MoMo;;tuer_c_o_re == 0
                
                        # corner(n) = 
                        # 0 = [0, 0, 0] (left front bottom)
                        # 1 = [1, 0, 0] (right front bottom)
                        # 2 = [0, 1, 0] (left back bottom)
                        # 3 = [1, 1, 0] (right back bottom)
                        # 4 = [0, 0, 1] (left front top)
                        # 5 = [1, 0, 1] (right front top)
                        # 6 = [0, 1, 1] (left back top)
                        # 7 = [1, 1, 1] (right back top)
                
                      end
                
                      # {S-Tuer oeffnen/schliessen()
                      #
                      def schiebetuer_open_close_li_gen
                        model     = Sketchup.active_model    
                        entities  = model.active_entities        
                        status    = ecken_ermitteln           # siehe oben
                        if MoMo;;g_name == 'Schiebetuer_li'
                          x2  =  MoMo;;x_mass / 3 * 2
                          x1  =  x2 if MoMo;;tuer_c_o_li == 0   
                          x1  = -x2 if MoMo;;tuer_c_o_li == 1            
                          a1  =   0 if MoMo;;tuer_c_o_li == 0
                          a2  =   1 if MoMo;;tuer_c_o_li == 1        
                          t1  = Geom;;Transformation.translation [x1,0,0]       
                          entities.transform_entities t1, MoMo;;teile    
                          MoMo;;tuer_c_o_li = 1 if a1 == 0           
                          MoMo;;tuer_c_o_li = 0 if a2 == 1   
                        else
                          UI.messagebox 'Es wurde eine falsche Tuer ausgewaehlt.'
                        end         
                        status        = MoMo;;teile.explode         
                      end 
                      def schiebetuer_open_close_re_gen
                        model         = Sketchup.active_model
                        entities      = model.active_entities    
                        status        = ecken_ermitteln           # siehe oben
                        if MoMo;;g_name == 'Schiebetuer_re'        
                          x2  = MoMo;;x_mass / 3 * 2
                          x1  = -x2 if MoMo;;tuer_c_o_re == 0   
                          x1  =  x2 if MoMo;;tuer_c_o_re == 1         
                          a1  =   0 if MoMo;;tuer_c_o_re == 0
                          a2  =   1 if MoMo;;tuer_c_o_re == 1        
                          t1  = Geom;;Transformation.translation [x1,0,0]      
                          entities.transform_entities t1, MoMo;;teile    
                          MoMo;;tuer_c_o_re = 1 if a1 == 0           
                          MoMo;;tuer_c_o_re = 0 if a2 == 1   
                        else
                          UI.messagebox 'Es wurde eine falsche Tuer ausgewaehlt.'
                        end               
                        status        = MoMo;;teile.explode         
                      end   
                

                Wir planen Ihre Büroeinrichtung mit SketchUp. http://www.momo-moebel.de

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement