Sketchup send action for paste..
-
...I can get.
Is there an equivalent to paste in place? I can find nothing. -
Sketchup.send_action("paste:")(only in the Windows version of SketchUp) -
Sorry Aerelius, I have the "paste" code but could not find "paste in place".
(My english
) -
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_uniquewill 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 useins.erase!if it's a 'move 'rather than a 'copy'...The transformation of a group/instance is got from
tr=gp.transformationortr=ins.transformation, to find the 'inverse' usetr.inverse!etc depending on the 'direction' of the transformation you are applying... Multiple transformations can be accumulative - usingtr2*tr1*tr0from inside...out. -
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=0thus 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?.
-
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...
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement