sketchucation logo sketchucation
    • 登入
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🔌 Smart Spline | Fluid way to handle splines for furniture design and complex structures. Download

    Automaticaly try to import files that aren't .sku

    已排程 已置頂 已鎖定 已移動 Developers' Forum
    33 貼文 7 Posters 33.1k 瀏覽 7 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • J 離線
      Jim
      最後由 編輯

      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 條回覆 最後回覆 回覆 引用 0
      • G 離線
        Gruff
        最後由 編輯

        [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 條回覆 最後回覆 回覆 引用 0
        • J 離線
          Jim
          最後由 編輯

          @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 條回覆 最後回覆 回覆 引用 0
          • J 離線
            Jim
            最後由 編輯

            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 條回覆 最後回覆 回覆 引用 0
            • G 離線
              Gruff
              最後由 編輯

              @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 條回覆 最後回覆 回覆 引用 0
              • J 離線
                Jim
                最後由 編輯

                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 條回覆 最後回覆 回覆 引用 0
                • E 離線
                  Eric_Erb
                  最後由 編輯

                  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 條回覆 最後回覆 回覆 引用 0
                  • G 離線
                    Gruff
                    最後由 編輯

                    @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 條回覆 最後回覆 回覆 引用 0
                    • A 離線
                      alexdobras
                      最後由 編輯

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

                      1 條回覆 最後回覆 回覆 引用 0
                      • TIGT 離線
                        TIG Moderator
                        最後由 編輯

                        @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 條回覆 最後回覆 回覆 引用 0
                        • Dan RathbunD 離線
                          Dan Rathbun
                          最後由 編輯

                          @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 條回覆 最後回覆 回覆 引用 0
                          • Dan RathbunD 離線
                            Dan Rathbun
                            最後由 編輯

                            @gruff said:

                            Can Ruby Scripts Accept a command line parameter on load?

                            Nope

                            @gruff said:

                            Does Sketchup have command line parameters itself that can load a Ruby Script?

                            sketchup.exe -RubyStartup script.rb

                            You many need paths:
                            Try adding the sketchup program path to the %PATH% var,
                            then change working dir to the plugins folder where the script is located.

                            I'm not here much anymore.

                            1 條回覆 最後回覆 回覆 引用 0
                            • TIGT 離線
                              TIG Moderator
                              最後由 編輯

                              @dan rathbun said:

                              @gruff said:

                              Can Ruby Scripts Accept a command line parameter on load?

                              Nope

                              @gruff said:

                              Does Sketchup have command line parameters itself that can load a Ruby Script?

                              sketchup.exe -RubyStartup script.rb
                              You many need paths:
                              Try adding the Sketchup program path to the %PATH% var,
                              then change working dir to the plugins folder where the script is located.

                              Not as they 'load' up but as an instance of them is started 'yes' - if you mean like MyTool.new(1,2,3) it's 'yes' just set the initialize method in the class to def initialize(arg0=0,arg1=,arg2=0) etc the =0 sets a default value for the arguments if they are not given.
                              Obviously methods take accept arguments a lot of the API does that... point.offset(vector, distance) where the Point3d method accepts one or two arguments...
                              If you want some code to run at startup of Sketchup then place it in a .rb script in Plugins that is auto-loaded and it will run - e.g. startupwithrubyconsole.rb containing the line require 'sketchup.rb';Sketchup.send_action("showRubyPanel:") will open the Ruby Console whenever Sketchup starts - pretty useless but just an example... or Sketchup.send_action("selectSelectionTool:") to change the default initial tool from the draw-line-tool to the select-tool...

                              TIG

                              1 條回覆 最後回覆 回覆 引用 0
                              • 1
                              • 2
                              • 2 / 2
                              • 第一個貼文
                                最後的貼文
                              Buy SketchPlus
                              Buy SUbD
                              Buy WrapR
                              Buy eBook
                              Buy Modelur
                              Buy Vertex Tools
                              Buy SketchCuisine
                              Buy FormFonts

                              Advertisement