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

    Unglue multiple component instances

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 474 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.
    • S Offline
      shannonnovus
      last edited by

      Greetings,

      I am trying to batch unglue components, but can't seem to find an easy way to do it.

      • When I select multiple instances, the "unglue" option is no longer available in the context menu.

      • I can't figure out how to modify the component definition (glue settings, etc) once the component has been created.

      • I don't see a way to "unglue" the component instances via the API.

      I've searched, but doesn't seem like this is a problem others have had before. The issue is that I've made a house component, set it to be glued long before I knew what a pain it would be, and now I have 400 of them in my model. I'm adding topography, so I need to move all of the houses up to sit on top of the topography, but it isn't letting me, of course, because they are glued to the ground (aka. Google Earth Snapshot).

      Any help on how to get out of this without changing each individually would be much appreciated, either using the GUI or writing a Ruby script to do it.

      With gratitude,
      Shannon

      1 Reply Last reply Reply Quote 0
      • S Offline
        shannonnovus
        last edited by

        Solved my own problem, after some trial and error in the Ruby console. Here it is.

        def unglue
        model=Sketchup.active_model
        selection=model.selection
        comps=selection.grep(Sketchup::ComponentInstance) {|c|
        glue = c.glued_to
        c.glued_to=nil unless glue==nil
        }
        end#def

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

          This code is not exhaustively tested, but it should give you enough ideas:

          model = Sketchup.active_model
          model.start_operation('Unglue', true)
          insts = model.selection.grep(Sketchup;;ComponentInstance)
          insts.each{|inst|
            inst.glued_to= nil
          }
          model.commit_operation
          
          

          One step undo-able...
          It un-glues all selected component-instances.

          TIG

          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