[Plugin] Memory Copy (xformclone.rb)
-
thanks, tig, for mentioning the grow.rb script.
the description sounds quite nice. unfortunately it causes a lot of bugsplats for me, but no geometryand 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!
-
@plot-paris said:
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 )
-
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
-
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.
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
-
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. -
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!
-
Yes, clear as mud...
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.
- 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?)
- 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
-
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... )
-
I decided to get it out the way. Here it is.
- Create an instance of component
- Duplicate and position a second instance
- Right click on first instance and choose "Play it again.."
- Now if you hover over any instance that is the same definition as your 'start' instance it will be highlighted.
- Left button to create a new instance.
- Type string of the form "123x" in the VCB to set the number of instances to create per left button click.
- Click away from geometry to exit tool
Enjoy,
Adam
-
WOW MARVELOUS
Thanks
agrazdi
-
Cheers adam,
i have a feeling this is going to become one of those 'how did i ever do that before?' type plugins.
-
A quick demo for the non believers.
362 segments and about 4 clicks of the mouse -
this is marvellous! thanks a lot, Adam!
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) -
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
-
Wow! Adam, this is another great plugin. Thank you.
-
Excellent script !!!! Thank you !
@unknownuser said:
- 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 !
- 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).
-
A little update, for future improvements noticed above !!
Good luck AdamB !!PS : And sorry for my incompetence... I don't have enough talent to modify your script
-
awsome script, i can think of quite a few things to use this for. but i have a suggestion/request
-
could we also get a version where we can devide the action? so it fills in the instances between a move and rotation?
-
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
-
-
Thanks Adam,
Wonderful script!
-
Yet another muscle to SU.
Advertisement