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!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Sketchup send action for paste..

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 4 Posters 580 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.
    • BurkhardB Offline
      Burkhard
      last edited by

      ...I can get.
      Is there an equivalent to paste in place? I can find nothing.

      [http://www.ia-plus.de(http://www.ia-plus.de)]

      1 Reply Last reply Reply Quote 0
      • A Offline
        Aerilius
        last edited by

        Sketchup.send_action("paste:") (only in the Windows version of SketchUp)

        1 Reply Last reply Reply Quote 0
        • BurkhardB Offline
          Burkhard
          last edited by

          Sorry Aerelius, I have the "paste" code but could not find "paste in place".
          (My english 😳 )

          [http://www.ia-plus.de(http://www.ia-plus.de)]

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

            There is no 'paste_in_place' send_action [there's probably an unsuppoorted numerical PC-only code somewhere??] 😞
            If you want to 'move' something from one context into another then you must first have it as a group/instance, then add an instance of it into the new context, respecting the relative transformations...

            If it's initially loose geometry and in the active_context then something like:
            gp=model.active_entities.add_group(model.selection.to_a)
            will work to make it a group, BUT if not SketchUp will Bugsplat !

            Let's assume we have a group referenced as 'gp'... to put a 'copy' of it into another 'context' use:
            gp2=another.entities.add_instance(gp.entities.parent, tr)
            Where 'tr' is the transformation of the 'another' container relative to the original...

            If you have two instances of the same group using gp2.make_unique will avoid issues if you change one but don't want to change the other...

            If you want to 'move' it between contexts [aka cut+paste_in_place] then after you create the new instance use gp.erase! to remove the original.

            If the selected object is a component instance ['ins'] then it's slightly different...
            ins2=another.entities.add_instance(ins.definition, tr)
            Again use ins.erase! if it's a 'move 'rather than a 'copy'...

            The transformation of a group/instance is got from tr=gp.transformation or tr=ins.transformation, to find the 'inverse' use tr.inverse! etc depending on the 'direction' of the transformation you are applying... Multiple transformations can be accumulative - using tr2*tr1*tr0 from inside...out.

            TIG

            1 Reply Last reply Reply Quote 0
            • dukejazzD Offline
              dukejazz
              last edited by

              I found this awhile back

              send_action code
              21939 Insert clipboard contents at original location.
              http://sketchucation.com/forums/viewtopic.php?f=180&t=23321&start=0

              thus this is a 'paste_in_place'; a send_action code for -pc only (7,1 - 8.m5 ...)
              Sketchup.send_action(21939)

              For the Mac I would like to know too?.

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

                BUT since there is no ability to change the active-context through the API then paste-in-place is pointless...
                If you Cut or Copy then Paste with send_action it's sine because the original selected object and the newly copied/cut then-pasted one are in the same context, and the user gets the copy on their cursor to place manually.
                But let's assume there were a seemingly usable Paste_In_Place send_action available through the API, how would it be of any use ?
                Say you are in the the model and want to Cut an object, open a Group and then do a Paste_In_Place on the object inside the Group.
                In the API you can Cut it.
                BUT you are now stuck as you can't open the Groups context.
                Paste_In_Paste will simple place the object back where it was, in the current context !!!

                There IS a way to replicate all of this 'in code'... BUT your Ruby_Cut and Ruby_Paste_In_Place into another 'container' custom code needs to make a group of the selected objects, then find that group's definition and then use container.entities.add_instance(defn, trans) on the other container's entities context, applying the container's transformation onto it [with a .inverse ? I write this 'off-the-cuff'], so that it's kept 'in_place'. Once that is done you explode that newly added group inside the container, then finally you erase the original group so the selection appears to have been cut and pasted_in_place into the other container... If you mimic a Ruby_Copy and Ruby_Paste_In_Place it's similar... except on completion you also explode the original group rather than erasing it, and in that way the selection appears to have been copied and pasted_in_place into the other container...

                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