sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Removing the group after group.to_component

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 2 Posters 267 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.
    • honoluludesktopH Offline
      honoluludesktop
      last edited by

      The following:
      my_def = definitions.add "My Selection" my_inst = @master_group.to_component new_inst = my_def.entities.add_instance(my_inst.definition,my_inst.transformation) my_inst.erase! repeat = false #make true for repeat insert model.place_component my_def, repeat

      creates a component from a group. I was unable to find a method that would keep the component, without the group. Do I have to break up the group into its entities by temp_entities = @master_group.explode, then create a instance of them by looping through the array, by my_inst.entities.add_... for each entity?

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        ? group.to_component does not preserve the original group.

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

        1 Reply Last reply Reply Quote 0
        • honoluludesktopH Offline
          honoluludesktop
          last edited by

          It doesn't? hmmm.....OK, I'll take a better look at my code to see where I made the group.

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            I just converts the group.

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

            1 Reply Last reply Reply Quote 0
            • honoluludesktopH Offline
              honoluludesktop
              last edited by

              Turns out that although my original code appeared to work, it did not properly create my_component. I have corrected the code as noted below:

              ` my_instance = @master_group.to_component

              new_instance = entities.add_instance(my_instance.definition,my_instance.transformation)
              my_definition = new_instance.definition

              my_definition.name = my_file_name
              my_instance.erase! #although not part of problem,
              new_instance.erase! #ended up with stray instances.
              repeat = false
              model.place_component my_definition, repeat`

              tt, thanks for helping to point me in the right direction.

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                Stray instance? From to_component?
                This should not be - something else must be going on.

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

                1 Reply Last reply Reply Quote 0
                • honoluludesktopH Offline
                  honoluludesktop
                  last edited by

                  Right again:

                  my_instance = @master_group.to_component my_definition = my_instance.definition my_definition.name = my_file_name my_instance.erase! repeat = false model.place_component my_definition, repeat

                  Can I just say that I must have been sleep deprived. 😳

                  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