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

    [Plugin] Memory Copy (xformclone.rb)

    Scheduled Pinned Locked Moved Plugins
    42 Posts 24 Posters 54.8k Views 24 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.
    • TIGT Offline
      TIG Moderator
      last edited by

      The Grow.rb script also does move, rotate, scale and copy...

      TIG

      1 Reply Last reply Reply Quote 0
      • plot-parisP Offline
        plot-paris
        last edited by

        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! 😍

        1 Reply Last reply Reply Quote 0
        • plot-parisP Offline
          plot-paris
          last edited by

          @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 )

          1 Reply Last reply Reply Quote 0
          • AdamBA Offline
            AdamB
            last edited by

            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

            Developer of LightUp Click for website

            1 Reply Last reply Reply Quote 0
            • AdamBA Offline
              AdamB
              last edited by

              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 
              

              Developer of LightUp Click for website

              1 Reply Last reply Reply Quote 0
              • K Offline
                kwistenbiebel
                last edited by

                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.

                1 Reply Last reply Reply Quote 0
                • plot-parisP Offline
                  plot-paris
                  last edited by

                  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:

                  http://img256.imageshack.us/img256/517/memorycopyht6.jpg

                  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!

                  1 Reply Last reply Reply Quote 0
                  • AdamBA Offline
                    AdamB
                    last edited by

                    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.

                    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

                    Developer of LightUp Click for website

                    1 Reply Last reply Reply Quote 0
                    • plot-parisP Offline
                      plot-paris
                      last edited by

                      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... πŸ˜‰ )

                      1 Reply Last reply Reply Quote 0
                      • AdamBA Offline
                        AdamB
                        last edited by

                        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


                        Stick it in your plugins folder

                        Developer of LightUp Click for website

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

                          WOW MARVELOUS

                          Thanks

                          agrazdi

                          1 Reply Last reply Reply Quote 0
                          • R Offline
                            remus
                            last edited by

                            Cheers adam,

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

                            http://remusrendering.wordpress.com/

                            1 Reply Last reply Reply Quote 0
                            • R Offline
                              remus
                              last edited by

                              A quick demo for the non believers.
                              362 segments and about 4 clicks of the mouse πŸ˜„

                              http://farm4.static.flickr.com/3053/2850475960_fce2e892d6_o.jpg

                              http://remusrendering.wordpress.com/

                              1 Reply Last reply Reply Quote 0
                              • plot-parisP Offline
                                plot-paris
                                last edited by

                                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)

                                1 Reply Last reply Reply Quote 0
                                • AdamBA Offline
                                  AdamB
                                  last edited by

                                  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

                                  Developer of LightUp Click for website

                                  1 Reply Last reply Reply Quote 0
                                  • Dave RD Offline
                                    Dave R
                                    last edited by

                                    Wow! Adam, this is another great plugin. Thank you.

                                    Etaoin Shrdlu

                                    %

                                    (THERE'S NO PLACE LIKE)

                                    G28 X0.0 Y0.0 Z0.0

                                    M30

                                    %

                                    1 Reply Last reply Reply Quote 0
                                    • M Offline
                                      Matt666
                                      last edited by

                                      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 !

                                      Frenglish at its best !
                                      My scripts

                                      1 Reply Last reply Reply Quote 0
                                      • M Offline
                                        Matt666
                                        last edited by

                                        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 πŸ˜•

                                        Frenglish at its best !
                                        My scripts

                                        1 Reply Last reply Reply Quote 0
                                        • free agentF Offline
                                          free agent
                                          last edited by

                                          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

                                          http:i167.photobucket.comalbumsu143FreeAgent84bug.gif

                                          1 Reply Last reply Reply Quote 0
                                          • D Offline
                                            Daniel Bouchard
                                            last edited by

                                            Thanks Adam,

                                            Wonderful script!

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 1 / 3
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement