• Login
sketchucation logo sketchucation
  • Login
Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

Create group

Scheduled Pinned Locked Moved Developers' Forum
4 Posts 3 Posters 281 Views 3 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.
  • P Offline
    Pauline01
    last edited by 18 Jan 2010, 08:42

    hello,

    I create an entitie with a plugin but i don't arrive create a group with each point of my entitie...

    
    
    require 'sketchup.rb'
    
    def add_etiquette
    
      # Get "handles" to our model and the Entities collection it contains.
      model = Sketchup.active_model
      entities = model.entities
    
      # Create a series of "points", each a 3-item array containing x, y, and z.
      pt1 = [0, 0, 0]
      pt2 = [30, 0, 0]
      pt3 = [30, 0, 17]
      pt4 = [0, 0, 17]
      
      # Call methods on the Entities collection to draw stuff.
      new_face = entities.add_face pt1, pt2, pt3, pt4
    
      
      ##here i want create a group of "new_face"(in sketchup it's a selection right click and make group). 
      ##How do in ruby?                                                                                    
    
    
    end
    
    #Menu
    if (not file_loaded?("zEtiquette_config.rb"))
     
        tool_menu = UI.menu "Tools"
    	tool_menu.add_item("Create zone item") {
       add_etiquette
     }
         
    	$VSX = Vsx.new
    
      file_loaded("zEtiquette_config.rb")
    end
    
    
    
    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 18 Jan 2010, 08:52

      Create the group before you create the face.

      
        # Get "handles" to our model and the Entities collection it contains.
        model = Sketchup.active_model
        entities = model.entities
      
        # Create a series of "points", each a 3-item array containing x, y, and z.
        pt1 = [0, 0, 0]
        pt2 = [30, 0, 0]
        pt3 = [30, 0, 17]
        pt4 = [0, 0, 17]
       
        # Create group to contain entities
        group = entities.add_group
      
        # Call methods on the Group's entitites collection to draw stuff.
        new_face = group.entities.add_face(pt1, pt2, pt3, pt4)
      
      

      It's a bit different from when you model in SU where you first draw your entities, then group. When you write ruby scripts, it's best to create the group first, then add the entities inside that group.

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • R Offline
        remus
        last edited by 18 Jan 2010, 08:56

        something like this should do it:
        group = entities.add_group group.entities.add_face(pt1,pt2,pt3,pt4)

        Basically all your doing is creating a group then adding your face to the list of entities contained within the group. Because of this you can remove the entities.add_face in your original code.

        http://remusrendering.wordpress.com/

        1 Reply Last reply Reply Quote 0
        • P Offline
          Pauline01
          last edited by 18 Jan 2010, 09:01

          oh, ok.... it's simple. thx guys

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

          Advertisement