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

    [solved] "movin" group into another group (in ruby)

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 4 Posters 515 Views 4 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.
    • artmusicstudioA Offline
      artmusicstudio
      last edited by artmusicstudio

      hi,
      after hours of trying and searching i have to ask:

      when i have 2 different groups at level 1 in the drawing,

      how can i

      a. "move = insert" group 1 INTO group 2

      b. insert them both into a GROUP 3

      i tried everything i found , but no chance..

      probably i just need a snall kick to understand the syntax, how the structure is and how elements can be transfered.

      thanx

      stan

      1 Reply Last reply Reply Quote 0
      • mitcorbM Offline
        mitcorb
        last edited by

        select the group you wish to insert
        control x
        open the receiving group
        Menu>Edit>Paste in Place
        Option to explode the inserted or not your choice
        Move stuff about within the group as you wish
        Close receiving group
        While still highlighted repeat the above steps.

        I take the slow, deliberate approach in my aimless wandering.

        1 Reply Last reply Reply Quote 0
        • artmusicstudioA Offline
          artmusicstudio
          last edited by

          hi mitcorb,
          very kind from you, but i know the solution in skp itself,
          what i need is a solution in ruby, i just cannot get the group entities into another group..

          but thanx a lot !!!!
          stan

          1 Reply Last reply Reply Quote 0
          • mitcorbM Offline
            mitcorb
            last edited by

            ooops I didn't see the request
            My apologies 😳

            I take the slow, deliberate approach in my aimless wandering.

            1 Reply Last reply Reply Quote 0
            • C Offline
              CAUL
              last edited by

              I think this works:

              ` def self.add(g0, g1)
              g0.entities.add_instance(g1.entities.parent, g1.transformation * g0.transformation.inverse)
              g1.erase!
              end

              def self.insert(ng, g0, g1)
              ng.entities.add_instance(g0.entities.parent, g0.transformation)
              ng.entities.add_instance(g1.entities.parent, g1.transformation)
              g0.erase!
              g1.erase!
              end`

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                You also need to check the group level for attribute dictionaries and materials, and apply (or copy) them to the new copied instances.

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • artmusicstudioA Offline
                  artmusicstudio
                  last edited by

                  hi,
                  thanx! work like a dream,
                  as soon as i found out, that a

                  ng - group must be created before calling the method, then it moves both groups into it.
                  fantastic!

                  THANK YOU !!!!!
                  stan

                  result:

                  
                          g0 = @group_floors #COMES FROM ANOTHER METHOD
                  	g1 = @facade_group #COMES FROM ANOTHER METHOD
                  	ng = model.entities.add_group
                  	self.insert(ng, g0, g1)
                  
                  
                  ##***************************************************************************
                  def self.insert(ng, g0, g1)
                  ##***************************************************************************
                  ng.entities.add_instance(g0.entities.parent, g0.transformation)
                  ng.entities.add_instance(g1.entities.parent, g1.transformation)
                  g0.erase!
                  g1.erase! 
                  #ng.name = "master house group created"
                  count = 1
                  entities3 = ng.entities
                  entities3.each { |entity|
                  if entity.is_a?(Sketchup;;Group)
                  entity.explode if count == 1 #SO GROUPS ELEMENTS ARE AGAIN AT LEVEL 1, as needed
                  count =  count + 1
                  end	
                  		}
                  end
                  
                  
                  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