[Plugin] Memory Copy (xformclone.rb)

[Plugin] Memory Copy (xformclone.rb)

Postby plot-paris » Thu Jul 10, 2008 9:40 am



Download -
xformclone.rb


Memory Copy (or an alternative name that sounds more impressive ;) )

I think I came across this function years ago in Maya.

at the moment in SketchUp you can only create an array with one movement (move-copy/rotate-copy an object and specify the number of copies).
if you need to do more than one changes in position (like with a spiral staircase - rotate + move upwards) you have do do it manually and can't refer to the array function).

therefore it would be a great help, if you have a MemoryCopy function (for example shortcut Ctrl+Shift+C):

you move-copy an object, then do several modifications in position and scale withoud deselecting it. if you now hit the shortcut, SketchUp remembers all alterations that have been applied to it since the copying process and creates a second copy with all the alterations applied to it.

you can either press the shortcut repeatedly or type a number in the VCB to create multiple copies, all with the same changes...

xformclone.rb
4
Last edited by Rich O Brien on Sat Dec 08, 2012 12:15 am, edited 4 times in total.
Reason: Added Plugin to OP
User avatar
plot-paris 
 

Re: [REQ] Memory Copy

Postby remus » Thu Jul 10, 2008 9:51 am

This would be a very cool script, a definite enhancement of the current array tools in SU.
0

remus 
 

Re: [REQ] Memory Copy

Postby TIG » Thu Jul 10, 2008 4:30 pm

The Grow.rb script also does move, rotate, scale and copy...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [REQ] Memory Copy

Postby plot-paris » Thu Jul 10, 2008 5:56 pm

thanks, tig, for mentioning the grow.rb script.
the description sounds quite nice. unfortunately it causes a lot of bugsplats for me, but no geometry :?

and even if it worked... I would love to have a tool that blends in seemlessly in the SketchUp workflow, without the need of filling in information in a window...

I think the procedure, as described above, should be possible.
the tool simply has to remember all move- / rotation- / scaling-actions as long as an object remains selected.
if the "memory copy" command is executed it creates a copy and applies exactly the same alterations to it, only that it takes the last copy as the origin.
if the element is deselected beforehand, the script simply deletes it's memory cash.

so merely pressing a shortcut key executes the tool. you do not have to fill in anything, because the script gathered the information necessary while you were modeling! :ecstatic:
0
User avatar
plot-paris 
 

Re: [REQ] Memory Copy

Postby plot-paris » Thu Sep 11, 2008 12:28 pm

plot-paris wrote:if the element is deselected beforehand, the script simply deletes it's memory cash.

I just thought: is it perhaps possible for the script to retrieve the manipulation information from the native SketchUp history, like that it doesn't have to save any information itself. when activated it only has to check the history for continuous transformations of one selection (not interrupted by other operations), create a copy and apply 2x, 3x, 4x... the transformations...

(you see, I haven't given up on this idea. it is simply sooooo convenient and will speed up certain modelling processes (spiral staircases, hint, hint ;) ) immensly )
0
User avatar
plot-paris 
 

Re: [REQ] Memory Copy

Postby AdamB » Thu Sep 11, 2008 1:28 pm

Perhaps simpler still is to select 2 instances and the script subtracts the transforms to find the difference and just applies that repeatedly to Nx new instances.

Adam
0
Developer of LightUp Click for website
User avatar
AdamB 
LightUp Support
LightUp Support
 

Re: [REQ] Memory Copy

Postby kwistenbiebel » Thu Sep 11, 2008 1:55 pm

I support Plot Paris' request. This would indeed be a handy feature.
Don't know though what the easiest way for implementing a sequence of transformations would be.
0
Last edited by kwistenbiebel on Thu Sep 11, 2008 2:35 pm, edited 2 times in total.

kwistenbiebel 
 

Re: [REQ] Memory Copy

Postby AdamB » Thu Sep 11, 2008 2:24 pm

Had a quick go..and now I've got to go!

But basically it works just fine - put this code in a file in your plugins folder, select the first object, add another instance to the selection (this only works for Components) and right click and select "Play it again.."

So the only wrinkle is it tries to update the selection to the last 2 things it created so you can repeatedly right click but its screwing up.

Anyone want to point out my schoolboy error, feel free to ritually humiliate me. :-)

Code: Select all
def xformclone(num)
   first = Sketchup.active_model.selection[0]
   second = Sketchup.active_model.selection[1]
   
   if (num > 0) and (first.definition == second.definition)
      delta = second.transformation * (first.transformation.inverse)
      
      Sketchup.active_model.start_operation("xform & clone")

      ctm = second.transformation
      curr = second
      num.times do
         ctm = ctm * delta
         curr = curr.parent.entities.add_instance(first.definition, ctm)
         first = second
         second = curr
      end
      
      Sketchup.active_model.commit_operation
      
      Sketchup.active_model.selection.clear
      Sketchup.active_model.selection.add [first,second]
   end
end

UI.add_context_menu_handler do |menu|
   menu.add_separator
   menu.add_item("Play it again..") { xformclone(3)}
end
0
Developer of LightUp Click for website
User avatar
AdamB 
LightUp Support
LightUp Support
 

Re: [REQ] Memory Copy

Postby plot-paris » Thu Sep 11, 2008 5:15 pm

dear Adam,

I thank you so much for having a go with this script. I truely believe that this could be one of the most used functions throughout my daily modelling.

what I experienced with a first test:




I rotated a copy of the component arround axis A and moved it up vertically. when selecting the "Play it Again" function, it currently creates three copies.
in the first test it applied the vertical movement correctly. rotation however appeared to be applied arround the component's origin and not arround the actually used axis of rotation.

on other attempts it worked perfectly fine for two times, then reversed the copying direction, so that I suddenly had two components on top of each other.

but the general idea seems to be working - I am very excited!


the next step now would be (apart from finding the cause for the random direction of course) to make the "select one instance, then select another to indicate the direction"-process automatic.

what I mean is: you select a component. when you create a copy of it, the original component is automatically remembered as the first one. after you did some modifications to the copy you press the keyboardshortcut (therefore we need an entry in the "Tools- or Plugins- menue") and a copy is created.
repeated pressing of the shortcut key creates more copies...
I think that would be the fastest workflow imaginable.

another issue at the moment is, that the plugin doesn't seem to regard the order in which the changes have been applied.

for example, when have a component, 50cm from the origin. I now rotate it arround the origin horizontally (A), then I rotate it vertically arround it's centre (B).
if I now apply the plugin, it applies the rotation about it's centre (A) first, then does the other rotation (B)arround a pivot point that has been affected by the first alteration (A) as well - meaning that the center of rotation (B) has been rotated vertically arround the centre of the component.
thus the resulting overall movement is not as intended.

oh, dear. I hope that was understandable. :?

again, thank you so much for this first plugin. it really is a dream becoming true!
0
User avatar
plot-paris 
 

Re: [REQ] Memory Copy

Postby AdamB » Thu Sep 11, 2008 5:29 pm

Yes, clear as mud... :roll:

I should have explained it was just me banging out some code while I finished my after lunch espresso, not some finished thang. More a proof of concept. Mea culpa.

1. I'd left in a hardcoded '3' for the number of times to do the clone. It should be 1 (or perhaps read the VCB?)
2. The plugin wrongly relies on an ordering of the SketchUp Selection buffer. ie Selection is an unordered group of stuff you've hilighted, but this v0.000001 of the plugin was presuming the first thing in the Selection was the first thing you selected - which as you've discovered is not true - and nor should it be either I hasten to add.

So. I think I'll change it so you highlight an Instance, hover over another instance and right click - (ie an implicit second instance).

But but I've got things to do.. but I'll try to get to it soon.

Adam
0
Developer of LightUp Click for website
User avatar
AdamB 
LightUp Support
LightUp Support
 

Re: [REQ] Memory Copy

Postby plot-paris » Thu Sep 11, 2008 6:58 pm

oh, of course I understood it to be just a fist vague idea of the script. all the more reason to be impressed, that you are able to produce something like this during an after lunch expresso!

and of course, take your time. this plugin is nothing desperately needed (allthough it will be one of the most used ones... ;) )
0
User avatar
plot-paris 
 

Re: [REQ] Memory Copy

Postby AdamB » Thu Sep 11, 2008 7:55 pm

I decided to get it out the way. Here it is.

1. Create an instance of component
2. Duplicate and position a second instance
3. Right click on first instance and choose "Play it again.."
4. Now if you hover over any instance that is the same definition as your 'start' instance it will be highlighted.
5. Left button to create a new instance.
6. Type string of the form "123x" in the VCB to set the number of instances to create per left button click.
7. Click away from geometry to exit tool

Enjoy,
Adam
0
Developer of LightUp Click for website
User avatar
AdamB 
LightUp Support
LightUp Support
 

Re: [REQ] Memory Copy

Postby agrazdi » Fri Sep 12, 2008 12:58 am

WOW MARVELOUS

Thanks


agrazdi
0

agrazdi 
 

Re: [REQ] Memory Copy

Postby remus » Fri Sep 12, 2008 7:06 am

Cheers adam,

i have a feeling this is going to become one of those 'how did i ever do that before?' type plugins.
0

remus 
 

Re: [REQ] Memory Copy

Postby remus » Fri Sep 12, 2008 7:15 am

A quick demo for the non believers.
362 segments and about 4 clicks of the mouse :)
0

remus 
 

Re: [REQ] Memory Copy

Postby plot-paris » Fri Sep 12, 2008 7:42 am

this is marvellous! thanks a lot, Adam! :berserk:

however, I don't get the multiply function to work. tried everything; typing in the number with and without an x, before and after left clicking the second component. didn't get it to work :(
(I use Windows Vista)
0
User avatar
plot-paris 
 

Re: [REQ] Memory Copy

Postby AdamB » Fri Sep 12, 2008 8:34 am

Glad you like it.

Feel free to slap me here but you did press return after typing the "5x" or whatever, didn't you.

Adam
0
Developer of LightUp Click for website
User avatar
AdamB 
LightUp Support
LightUp Support
 

Re: [REQ] Memory Copy

Postby plot-paris » Fri Sep 12, 2008 9:19 am

I understand that you had to ask. :D
I did indeed (among every other method imaginable) hit enter after typing in Nx. just tried it here in the office (Windows XP) - works like a charm. may be a vista problem then.

some suggestions, observations:
would you mind changing the Nx to N* to go in line with the native SketchUp input?
and to assimilate the native workflow even more: is it possible to left-click the second component to be copied and then type in N*? because I love the way it works with the array function in SketchUp at the moment (that you can change the number of copies (or divisions for that matter...) repeatedly, simply by retyping 3*, 11*, 15*, 3*...).

an observation I made is that the order of modifications does still make no difference (of course not - that would only be possible if you applied the function directly after the copy-and-transform process).
that means that if you have more than one rotation process applied to the component-copy you may get results different from your intentions:



in this example I rotated the component arround axis A, then rotated it vertically around the outer corner. to get the desired result, the script had to repeat these steps in exactly the same order (rotate arround A 2x, 3x, 4x... the initial distance, then rotate 2x, 3x, 4x... arrount the outer corner).
the current version of the script however takes the overall changes in position/rotation which in this example results in the first rotation axis B being distorted - merged with the second rotation so to speak

now that I think about it - the result as we get it at the moment may be quite useful as well at some time.
maybe there is the need for two different versions:

- verion_1 works exactly like the current script (with the minor changes I suggested at the top of this post ;) ). it would make sense to have an entry within the "tools menue" to keep the context menue tidier. you can choose this function at every point of the modelling process, because it is history independent and retrieves every information from the selected geometry

- version_2 has to be applied directly after the copying/transformation process (like the array fuction only works directly after the copying process, because it retrieves it's information from the last action). therefore we need a shortcut for this function (and an entry in one of the menues).

I hope my thoughts are comprehensible.
have to start doing some office work now :D
0
Last edited by plot-paris on Thu Jan 22, 2009 7:07 pm, edited 2 times in total.
User avatar
plot-paris 
 

Re: [REQ] Memory Copy

Postby Matt666 » Fri Sep 12, 2008 10:26 am

:berserk: Excellent script !!!! Thank you !
- version_2 has to be applied directly after the copying/transformation process (like the array fuction only works directly after the copying process, because it retrieves it's information from the last action). therefore we need a shortcut for this function (and an entry in one of the menues).
Totally agree. That would be awesome !
0
Last edited by Matt666 on Fri Sep 12, 2008 12:07 pm, edited 2 times in total.
Frenglish at its best !
My scripts

Matt666 
 

Re: [REQ] Memory Copy

Postby Dave R » Fri Sep 12, 2008 10:58 am

Wow! Adam, this is another great plugin. Thank you.
0
Inspecting mirrors is a job I could easily see myself doing.

If you are the smartest person in the room, you are in the wrong room.
User avatar
Dave R 
Global Moderator
 

Re: [REQ] Memory Copy

Postby Matt666 » Tue Sep 23, 2008 8:27 am

A little update, for future improvements noticed above !!
;) :) :D
Good luck AdamB !! :mrgreen: :mrgreen: :ecstatic:

PS : And sorry for my incompetence... I don't have enough talent to modify your script :?
0
Frenglish at its best !
My scripts

Matt666 
 

Re: [REQ] Memory Copy

Postby free agent » Tue Sep 23, 2008 1:30 pm

awsome script, i can think of quite a few things to use this for. but i have a suggestion/request

1. could we also get a version where we can devide the action? so it fills in the instances between a move and rotation?

2. for tree branches this would be awsome if we could taper the size of instances or even have some kind of size randomizer on it.

but i think the first request is more important... thanx for the script
0
User avatar
free agent 
 

Re: [REQ] Memory Copy

Postby Daniel Bouchard » Wed Sep 24, 2008 4:09 am

Thanks Adam,

Wonderful script! :berserk:
0

Daniel Bouchard 
 

Re: [REQ] Memory Copy

Postby thomthom » Wed Sep 24, 2008 9:13 am

Yet another muscle to SU. :D
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [REQ] Memory Copy

Postby watkins » Wed Sep 24, 2008 11:08 pm

Dear Adam,

Trying out your script and enjoying the unexpected results.

Thank you for all your efforts.

Kind regards,
Bob
0

watkins 
 

Re: [REQ] Memory Copy

Postby mattjc » Sat Oct 11, 2008 11:58 am

Hi, this script is excellent.. trouble is i am having some trouble - when i key in the Nx in the VC box nothing happens - I noticed someone else had this trouble... i am running windows XP - can anyone help?!?!

Thanks
0

mattjc 
 

Re: [REQ] Memory Copy

Postby plot-paris » Thu Jan 22, 2009 7:08 pm

I just had the need to use this script, but it got lost on the way to the SU7 installation. so I looked for it again and re-read some posts on the way.
and I still think it would be cool to have a second version of the script that works slightly different, as I stated in this post above:

I understand that you had to ask. :D
I did indeed (among every other method imaginable) hit enter after typing in Nx. just tried it here in the office (Windows XP) - works like a charm. may be a vista problem then.

some suggestions, observations:
would you mind changing the Nx to N* to go in line with the native SketchUp input?
and to assimilate the native workflow even more: is it possible to left-click the second component to be copied and then type in N*? because I love the way it works with the array function in SketchUp at the moment (that you can change the number of copies (or divisions for that matter...) repeatedly, simply by retyping 3*, 11*, 15*, 3*...).

an observation I made is that the order of modifications does still make no difference (of course not - that would only be possible if you applied the function directly after the copy-and-transform process).
that means that if you have more than one rotation process applied to the component-copy you may get results different from your intentions:



in this example I rotated the component arround axis A, then rotated it vertically around the outer corner. to get the desired result, the script had to repeat these steps in exactly the same order (rotate arround A 2x, 3x, 4x... the initial distance, then rotate 2x, 3x, 4x... arrount the outer corner).
the current version of the script however takes the overall changes in position/rotation which in this example results in the first rotation axis B being distorted - merged with the second rotation so to speak

now that I think about it - the result as we get it at the moment may be quite useful as well at some time.
maybe there is the need for two different versions:

- verion_1 works exactly like the current script (with the minor changes I suggested at the top of this post ;) ). it would make sense to have an entry within the "tools menue" to keep the context menue tidier. you can choose this function at every point of the modelling process, because it is history independent and retrieves every information from the selected geometry

- version_2 has to be applied directly after the copying/transformation process (like the array fuction only works directly after the copying process, because it retrieves it's information from the last action). therefore we need a shortcut for this function (and an entry in one of the menues).

I hope my thoughts are comprehensible.
have to start doing some office work now :D


what do you think? wouldn't that be cool?
0
User avatar
plot-paris 
 

Re: [REQ] Memory Copy

Postby driven » Thu May 21, 2009 4:51 am

This is a very easy to use bit of kit, made the candy-stripe pole and used it for the animation as well.

very,very nice

thanks for posting....

kandistrpV22-poster.jpg


http://www.youtube.com/watch?v=R1DJ3oaplgM

???how do I add embedded youtube???
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Memory Copy (xformclone.rb)

Postby jason_maranto » Wed Feb 10, 2010 4:25 am

This is one of those functions I thought should be in Sketchup right from the beginning -- a really basic but totally useful function.

I'm one of the folks who can't get the array part of this script to work... I'll take a look at the script and see if I can't get to the bottom of it , but does anyone already know why?

Best,
Jason.
0
I create video tutorial series about several 2D & 3D graphics programs.
User avatar
jason_maranto 
 

Re: [Plugin] Memory Copy (xformclone.rb)

Postby plot-paris » Wed Feb 10, 2010 11:28 am

Jason, did you make sure to do everything in exactly the right order?

for the array function to work you have to select the first component, then right click > 'play it again'. then type in something like 5x (make sure to type in an axtual 'x' and not a *). and then click the second component...

I think this behavior could be optimized to better fit into the native SketchUp workflow, as I already explained in the third post of this page...
I still hope, that at some point someone will hear my pleading and will perfect the script :)
0
User avatar
plot-paris 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: jls006 and 8 guests

Visit our sponsors: