• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Change from Group to Component - Name Inheritance

Scheduled Pinned Locked Moved SketchUp Discussions
sketchup
6 Posts 2 Posters 340 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.
  • B Offline
    beginner
    last edited by 27 May 2012, 19:05

    Dear All,
    Is it possible to change a Group to Component and 'force' the Component to inherit the name from the Group?
    Regards

    Regards, SU 'beginner'

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 27 May 2012, 19:56

      It would have to be a script.
      When you change a group to a component the group's name is ignored and not even passed to the new-component's instance that now replaces the group.
      The new component definition's name matches the original group definition's name which will be something like "Group#1"...
      This "one-liner" will make any selected group[s] into components and use each group's name for the new component definition's name [instead of using its group-definition name] always provided that it's not "" [blank]... It also makes the new component-instance's name the same as the original group's name [again, always provided that it's not "" [blank]]...

      m=Sketchup.active_model;m.start_operation("g2c");m.selection.each{|e|next unless e.is_a?(Sketchup;;Group);n=e.name;i=e.to_component;i.name=n;i.definition.name=n unless n.empty?};m.commit_operation
      

      copy/paste it into the Ruby Console + <enter>... It's one step undo-able...

      TIG

      1 Reply Last reply Reply Quote 0
      • B Offline
        beginner
        last edited by 27 May 2012, 20:07

        Hi TIG,
        Tried and it doesn't work. The Ruby Console accepts the script (adds TRUE) but the change is 'wiping out' the name as usual.
        Regards

        Regards, SU 'beginner'

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 27 May 2012, 20:16

          @beginner said:

          Hi TIG,
          Tried and it doesn't work. The Ruby Console accepts the script (adds TRUE) but the change is 'wiping out' the name as usual.
          Regards
          I beg to differ.
          I have tested it and it DOES work.
          Preselect some things to convert...
          Then run the code...
          If you have an 'unnamed' group it will make a new component named say "Group#1" because by default it uses the group's definition name, the instance that replaces the original group is also unnamed [""].
          If you have a 'named' group = "xxx"; it WILL make a new component definition named "xxx", the instance that replaces the original group is also named "xxx".
          If you have more that one group that shares the name "xxx", then the new component definitions are renamed in turn - "xxx", "xxx#1", "xxx#2" etc - because definitions must have a unique name...
          Are you preselecting groups and pasting the whole of the code ???
          It SHOULD work...

          TIG

          1 Reply Last reply Reply Quote 0
          • B Offline
            beginner
            last edited by 27 May 2012, 20:36

            Hi TIG,
            My apologies...
            Now, I figured out the 'steps'...
            I didn't expect the the script would convert the Groups for me - hundreds of them in one go !!!
            1. Select the Group or Groups
            2. 'Paste' the Script and 'ENTER'

            • Don't change/convert the Group manually as I tried ! - it would change any selected Groups to the Component ... automatically !
              Amazing...
              TIG, Thank you

            Regards, SU 'beginner'

            1 Reply Last reply Reply Quote 0
            • T Offline
              TIG Moderator
              last edited by 27 May 2012, 20:56

              No probs...
              Glad it works for you...............
              😉

              TIG

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

              Advertisement