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

    Save As Plugin

    Scheduled Pinned Locked Moved Plugins
    5 Posts 3 Posters 290 Views 3 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.
    • R Offline
      rossthompson
      last edited by

      Hi,

      I was wandering if anyone can help me - I am looking for a ruby script to perform the following:

      1. Open a fresh window of SketchUp (leaving all the currently open windows as they are)

      2. Save the newly opened blank model to the desktop as 'temp.skp'

      Is this possible with the API?

      I know it only takes a few seconds to do these actions manually, but I am required to do this so often a script would be very valuable.

      Thanks

      Ross

      1 Reply Last reply Reply Quote 0
      • G Offline
        GWD
        last edited by

        mac of pc?

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

          PC

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

            The hardware shouldn't matter, but whether it's the Windows or OS X version of SketchUp.

            The OS X version can open multiple documents in the same SketchUp application, whereas in the Windows version you have to launch a new instance of the application. This new instance then doesn't know whether you opened it or whether it is supposed to be the temp.skp.

            Let me suggest a different perspective on the problem: You want a new SketchUp model, based on a template and saved on your desktop. Basically we copy your template to the desktop and open it.

            module Ross
              def self.new_file_on_desktop
                template = File.expand_path(Sketchup.template)
                home = ENV["HOME"] || ENV["USERPROFILE"] || ENV["HOME"]
                home = File.expand_path(home)
                target = File.join(home, "Desktop", "temp.skp")
                #FileUtils.cp(template, target)
                system("copy #{template.inspect} #{target.inspect}")
                UI.openURL(target) if File.exists?(target)
              end
              UI.menu("File").add_item("New file on desktop"){ Ross.new_file_on_desktop }
            end
            
            1 Reply Last reply Reply Quote 0
            • R Offline
              rossthompson
              last edited by

              Aerilius thanks very much for this - that is a clever approach.

              I have tried running the module you have written. However it opens command prompt with an error message "The system cannot find the file specified. 0 file(s) copied".

              I have tried debugging through the ruby console (see attachment) and the script correctly identifies my custom template file and the path to my desktop.

              However line 8 returns 'false' when trying to copy the file.

              I don't understand why this would be the case.

              Do you have any ideas?

              Thanks

              Ross


              Ruby Console.jpg

              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