sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Moving all components to origin

    Scheduled Pinned Locked Moved Extensions & Applications Discussions
    extensions
    11 Posts 4 Posters 2.0k 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.
    • D Offline
      Dennis_n
      last edited by

      I have 176 topo map TILES produced in other soft in OBJ format.
      I got to import it into SU. They all have common 0,0,0 origin. I got to manually import them one by one and manually move imported component origin into the common origin.

      A pain in a XXX.

      Is there any way to automate this process? (I'll have to perform this in the future on many models (()
      Dennis

      1 Reply Last reply Reply Quote 0
      • sdmitchS Offline
        sdmitch
        last edited by

        @dennis_n said:

        Is there any way to automate this process? (I'll have to perform this in the future on many models (()
        Dennis

        Probably if you would list the manual steps you are using to accomplish the result you want along with some screen shots of the before and after.

        Nothing is worthless, it can always be used as a bad example.

        http://sdmitch.blogspot.com/

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

          1 Press import
          2. Pick file
          3. Pick 0,0,0 as insertion point
          4. repeat 176 times


          QQ Photo20170202150111.jpg

          1 Reply Last reply Reply Quote 0
          • sdmitchS Offline
            sdmitch
            last edited by

            Is this the 'before' or 'after'?

            Could you post a couple of .obj files?

            Nothing is worthless, it can always be used as a bad example.

            http://sdmitch.blogspot.com/

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

              you could install a trial version of 3DS Max and run a 'batch import' script from scriptspot.com. and attach all the patches into one object. Or just have patience,- it's a 3-4 hours job +-

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

                How about something like this ?
                Select all of the 'containers' to be moved to the model's origin...

                Sketchup.active_model.selection.each{|e|
                  pt=e.transformation.origin
                  ve=pt.vector_to(ORIGIN)
                  tr=Geom;;Transformation.translation(ve)
                  e.transform!(tr)
                }
                

                ???

                TIG

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

                  Error: #<NameError: uninitialized constant Transformation>
                  <main>:3:in block in <main>' <main>:in each'
                  <main>:in `<main>'

                  Ruby is a foreign language to me (. It gave me an error.

                  Positioning to origin is a half task. another task is to import multiple files (instead of 1 by 1)

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

                    Sorry my typo.
                    I've corrected the code - please retry...

                    TIG

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

                      Woo hooo!!! it works!!!

                      2 more questions then:

                      1. how do I make a button out of it?
                      2. How to import a few hundred (DAE) objects simultaneously?
                      1 Reply Last reply Reply Quote 0
                      • TIGT Offline
                        TIG Moderator
                        last edited by

                        1. Make file, encoded as UTF8, named say AAA.rb - containing the following lines.
                          ` module Dennis_n

                        cmd=UI::Command.new("AAA"){
                        XXX
                        }
                        cmd.tooltip='AAA...'
                        cmd.status_bar_text='AAA...'
                        cmd.small_icon=File.join(File.dirname(FILE), 'AAA-16x16.png')
                        cmd.large_icon=File.join(File.dirname(FILE), 'AAA-24x24.png')
                        toolbar=UI::Toolbar.new('AAA')
                        toolbar.add_item(cmd)
                        toolbar.restore if toolbar.get_last_state.abs==1

                        end`

                        The images used for the buttons are expected to be in the same folder as the RB file.
                        Here they are expected to be 16 and 24 px square.
                        Replace the AAA text with whatever name you want...
                        Add the lines of 'code' inside the command's { } replacing XXX...


                        1. Much more complicated... But it already exists !
                          See this... http://sketchucation.com/pluginstore?pln=import_from_folder
                          Usage: http://sketchucation.com/forums/viewtopic.php?p=331966#p331966

                        You run it from the Ruby Console - but of course a toolbar is possible using the above method...

                        TIG

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

                          1. I feel ashamed, making a button is over my head. However, just pasting the script in to the command line, works.

                          2. Import does bring the files in. The script doesn't place the imported DAEs into the model. It just loads them into the memory. I can see them in my component menu but not in the moles. (during manual placement - I got to click to place the DAE in. With the script -there is no click to place it.) How to do?

                          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