sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Automaticaly try to import files that aren't .sku

    Scheduled Pinned Locked Moved Developers' Forum
    33 Posts 7 Posters 32.0k Views 7 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.
    • E Offline
      Eric_Erb
      last edited by

      Thanks Gruff. I've been out sick for a couple days, but I'm going to try this right now. Thanks again

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

        Okay, Here is the final product.

        I added a couple more comment line constants for the template file that control.

        Seconds until file deleted 2 - 30
        Show Launcher Dialog true/false

        The Attached Zip file contains three files.
        All three need to be placed in your PlugIns Folder.

        1. RubyScriptlauncher.exe
        2. Auto_Import_dwg.txt (Sample template file)
        3. File Type Diagram.jpg (Setting up 'File Type')

        Since I did not use any fancy controls you should not need an installation setup program for RubyScriptLauncher.exe

        RE: setting up the 'File Type' for DWG or other CAD files.
        If you have AutoCad or other applications that use DWG then it could become problimatical.

        Have Fun,


        Zipped Sources

        Resistance is .... Character Forming. Grin

        1 Reply Last reply Reply Quote 0
        • E Offline
          Eric_Erb
          last edited by

          Anybody get this to work?

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

            @eric_erb said:

            Anybody get this to work?

            Well obviously I have. ๐Ÿ˜„

            What are you having trouble with? Do you get any errors?

            Resistance is .... Character Forming. Grin

            1 Reply Last reply Reply Quote 0
            • E Offline
              Eric_Erb
              last edited by

              I sent you a couple PMs. The first problem I'm having it that I can't set my dwg files to open with your .exe. I can set them to open with anything else but when I select yours it ignores it and stays with whatever program was selected before. The second problem is when I drop a .dwg file on your .exe I get this error...

              http://rapidsetbuildings.com/Images/oops.jpg

              I'm sure I'm doing something wrong

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by

                Can't use a .bat file and environmental variables (which a ruby can check for the existence of on SU startup?)

                Here's a .bat

                
                set LSU=%1
                "c;\Program Files\Google\Google Sketchup 7.1\sketchup.exe"
                
                

                And from Ruby once SU is running:

                
                ENV['LSU']=> "C;\Documents and Settings\Jim\My Documents\drawing\100.dxf"
                
                

                Can you set the file association using a .bat? I would guess so using the reg command. However, I would not recommend changing a user's file association for a .dxf.

                Hi

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

                  Eric,

                  Sorry about that my PM'er is apparently not working.

                  Re-thought the whole issue. Perhaps I tried to make it too non-specific.
                  Delete the executable and the template file.

                  Attached is a one trick pony sort of program in a Zipped file.
                  Unzip it and put it in your plugins folder. Make a shortcut to it on your desktop.

                  Run the program and drag-drop a DWG or DXF file anywhere on the program's dialog.

                  Sketchup will be launched and your DWG / DXF file should be loaded.
                  (This program will not work by file association at all.)

                  I hard coded the creation of the ruby file inside the executable.
                  The delay time to file deletion in the dialog is necessary as the Ruby Script file it creates has to be destroyed, otherwise the script would try to import the same file everytime you started SketchUp.

                  The delay is user definable because you may need to load some very large Autocad files and it wouldn't do to have the Ruby file deleted while it is still trying to import.

                  The program will remember your last delay time between sessions.


                  New Program to import DWG or DXF

                  Resistance is .... Character Forming. Grin

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

                    Jim could you expand on what you are saying some?

                    Are you saying the a Windows Environment variable can be read by ruby in sketchup?
                    If so can it be set to nil when the ruby script is done importing the DWG?

                    I guess I envision something like the following pseudo-code

                    
                    If EnvVar != nil then
                      import EnvVar
                      set EnvVar = nil
                    end if
                    
                    

                    That would be a better idea than creating and destroying a hard coded script file as my program currently does.

                    Resistance is .... Character Forming. Grin

                    1 Reply Last reply Reply Quote 0
                    • E Offline
                      Eric_Erb
                      last edited by

                      Thanks again Gruff... it worked without a hitch. It's a bit of a work around but it works and that's the important thing. I might try to figure out how to launch it during startup and just have it appear down in the notification area of the windows toolbar so I can drag and drop files to it there instead of just keeping a your small window on screen all the time.

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        Jim
                        last edited by

                        Yes, the environment variables are stored in a hash named ENV. Just type ENV in the Ruby Console:

                        
                        ENV # View the entire hash
                        ENV["TheKey"] # returns a value
                        ENV["TheKey'] = nil # setting a value
                        
                        

                        I was thinking the ruby could live permenent;y in the Plugins foder, and just check for the existence of and env variable. If it is set, do to import (perhaps using a messagebox to confirm.) after everything finishes loading.

                        @gruff said:

                        Jim could you expand on what you are saying some?

                        Are you saying the a Windows Environment variable can be read by ruby in sketchup?
                        If so can it be set to nil when the ruby script is done importing the DWG?

                        I guess I envision something like the following pseudo-code

                        
                        > If EnvVar != nil then
                        >   import EnvVar
                        >   set EnvVar = nil
                        > end if
                        > 
                        

                        That would be a better idea than creating and destroying a hard coded script file as my program currently does.

                        Hi

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

                          [quote="Jim"]

                          
                          ENV # View the entire hash
                          ENV["TheKey"] # returns a value
                          ENV["TheKey'] = nil # setting a value
                          
                          

                          Cool Beans Jim. ๐Ÿ˜Ž

                          Of course it doesn't solve requiring my app to be running all the time. I suppose I could make it so it always stays on top but that could get to be annoying.

                          Dropping the DWG file on the taskbar icon doesn't Drop the file. Instead it make the application you dropped on the active application (So you have to drop a second time)

                          Can a web form detect a DragDrop event? If so perhaps a small always running web form would a better route? At least you could then import Acad files while SketchUp was running.

                          Don't know diddly about web apps so I am out of my element there.

                          Resistance is .... Character Forming. Grin

                          1 Reply Last reply Reply Quote 0
                          • J Offline
                            Jim
                            last edited by

                            @gruff said:

                            Can a web form detect a DragDrop event? If so perhaps a small always running web form would a better route? At least you could then import Acad files while SketchUp was running.

                            Great thought, and I'd bet the file path would then be accessible in the dialog and then could passed to Ruby, but I don't know enough about it to even test it.

                            update: dropping a file onto a dialog does indeed trigger some event. In my test case a Ruby file was dropped on a webdialog, and i was then presented the opportunity to save the file. I'm not sure if/how that could be trapped in JavaScript.

                            Dropping a text file displayed the file in the dialog.

                            up-update - couldn't be as simple as an ondrop function?

                            Hi

                            1 Reply Last reply Reply Quote 0
                            • J Offline
                              Jim
                              last edited by

                              Here's an example for using the ondrop. I do not know how to get the dropped file name.

                              (I really wish this Ruby syntax would work:)

                              
                              @dropper_dlg = UI;;WebDialog.new
                              @dropper_dlg.set_html(DATA.read)
                              @dropper_dlg.add_action_callback("drop") { |d, a|
                                puts "drop;#{a.inspect}"
                              }
                              @dropper_dlg.show
                              
                              __END__
                              <html>
                                <head>
                                  <script>
                                    function drop() {
                                      window.location="skp;drop";
                                    }
                                    function cancelEvent() {
                                      window.event.returnValue = false;
                                    }
                                  </script>
                                </head>
                                <body ondragenter="cancelEvent()" ondragover="cancelEvent()" type=text ondrop="drop();">
                                  Hi There
                                </body>
                              </html>
                              
                              

                              Hi

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

                                @jim said:

                                I do not know how to get the dropped file name.

                                In Windows Forms programming the event returns a variable of type DataObject. The DataObject has (Among other things.) a Files collection property

                                
                                -- VB Code--
                                Private Sub OnDragDrop(Data as DataObject, _
                                                       Effect as Long, _
                                                       Button as integer, _
                                                       X as single, _
                                                       Y as single
                                
                                  If Data.Files.Count = 1 then
                                    sDroppedFileName = Data.Files(1)
                                  end if
                                
                                End Sub
                                
                                

                                Perhaps there is a similar structure in Java?

                                Resistance is .... Character Forming. Grin

                                1 Reply Last reply Reply Quote 0
                                • J Offline
                                  Jim
                                  last edited by

                                  My guess is that it is in this dataTransfer object referenced on this page:

                                  http://msdn.microsoft.com/en-us/library/ms536929%28VS.85%29.aspx

                                  But I haven't had a chance to try it.

                                  Hi

                                  1 Reply Last reply Reply Quote 0
                                  • E Offline
                                    Eric_Erb
                                    last edited by

                                    Yeah... I'm going to stay out of this conversation and just try to follow along as best I can. How do you guys think in script? I think my brain was completely maxed out after I added about 50% of AS3 to it, so HTML CSS PHP and AS3. I just don't seem to be retaining ruby like I did the others. Maybe I'm just getting old.

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

                                      @eric_erb said:

                                      How do you guys think in script? I just don't seem to be retaining ruby like I did the others.

                                      Not to worry Eric. The old adage "If you don't use it you lose it." applies big time to coding. I write VB Code for a living so I have to keep up on some things.

                                      It is not a mystery to me that Ruby is hard to remember. I put it down to the strict case sensitivity and the lack of a comprehensive Integrated development environment.

                                      Resistance is .... Character Forming. Grin

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

                                        what about a DWG/DXF export plugin for SU free ???

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

                                          @alexdobras said:

                                          what about a DWG/DXF export plugin for SU free ???

                                          There is a separate dwg/dxf exporter available for v7 Free - search here for links.
                                          It's not available for v8 but you can have v7 and v8 Free on your PC at the same time.
                                          There is a dwf exporter under development for v8 Free here too - advance-search for 'honoluludesktop' the author...

                                          TIG

                                          1 Reply Last reply Reply Quote 0
                                          • Dan RathbunD Offline
                                            Dan Rathbun
                                            last edited by

                                            @Gruff: There's no reason why you can't use VBS for your IE side webdialog code. Using Javascript is NOT a requirement for Sketchup Ruby. It doesn't care what what scripting language is running in the browser.

                                            I'm not here much anymore.

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

                                            Advertisement