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!
    🔌 Easy Offset | Offset selected faces in SketchUp in positive and negative offsets. Download

    SU Ruby + XML

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

      I'm looking for a solution to parse XML files. I read that normal Ruby, since 1.8.0 comes with REXML. But that's not available in the SU Ruby.
      I managed to find Ruby 1.8.0 Build 10 - hoping to be able to pick out only the REXML files, but it's an installation file. I'm not sure what ahppens if install a different ruby package. Will it affect SU?

      Is there some other XML solutions you lot have used?

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 條回覆 最後回覆 回覆 引用 0
      • N 離線
        NewOne
        最後由 編輯

        @thomthom said:

        I'm looking for a solution to parse XML files. I read that normal Ruby, since 1.8.0 comes with REXML. But that's not available in the SU Ruby.
        I managed to find Ruby 1.8.0 Build 10 - hoping to be able to pick out only the REXML files, but it's an installation file. I'm not sure what ahppens if install a different ruby package. Will it affect SU?

        Is there some other XML solutions you lot have used?

        Try to find which files are added after you install REXML, then copy that files in SU, paying attention how you include in ruby files (adequate paths)! See how I did with Ruby MySql http://forums.sketchucation.com/viewtopic.php?f=180&t=19719#p163327

        1 條回覆 最後回覆 回覆 引用 0
        • J 離線
          Jim
          最後由 編輯

          I packaged rexml up in a custom svg plugin for someone here...

          let me find it.

          Not sure if it is helpful, but here it is. http://forums.sketchucation.com/viewtopic.php?f=180&t=13475

          Hi

          1 條回覆 最後回覆 回覆 引用 0
          • thomthomT 離線
            thomthom
            最後由 編輯

            I noticed there was reports on Sandbox tools not working with the SVG plugin. Is that due any of the files in that package?

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 條回覆 最後回覆 回覆 引用 0
            • J 離線
              Jim
              最後由 編輯

              Ah yes, there is a file from the Ruby Language named set.rb that conflicts with SketchUp. Forgot about that..

              Hi

              1 條回覆 最後回覆 回覆 引用 0
              • thomthomT 離線
                thomthom
                最後由 編輯

                Something that conflicts with the SU Set class?

                Is it needed by REXML?

                Thomas Thomassen — SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 條回覆 最後回覆 回覆 引用 0
                • tbdT 離線
                  tbd
                  最後由 編輯

                  I would not go with REXML as is the slowest parser - see http://www.rubyinside.com/ruby-xml-performance-benchmarks-1641.html

                  "Note that the parsing time is in seconds and the Y-axis is logarithmic. Yes, Hpricot took over a minute, and REXML took over two minutes, while Nokogiri and libxml-ruby came in at a few seconds each"

                  SketchUp Ruby Consultant | Podium 1.x developer
                  http://plugins.ro

                  1 條回覆 最後回覆 回覆 引用 0
                  • thomthomT 離線
                    thomthom
                    最後由 編輯

                    Ah. That's interesting. I hoped to find something like that, but didn't when I was searching around.
                    So either Nokogiri or Hpricot. Anyone had any experience with them? Will they work with SU's stripped down Ruby 1.8.0?

                    Thomas Thomassen — SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 條回覆 最後回覆 回覆 引用 0
                    • S 離線
                      sacch
                      最後由 編輯

                      I am also looking for a solution to parse XML using SU ruby. I am writing a gas kinetics open source code which requires visualization of molecular structure and some energy related surfaces. It will be great if someone here can share more information on their experiences such as if anyone has tried but failed, or if there is any possible solution.

                      1 條回覆 最後回覆 回覆 引用 0
                      • thomthomT 離線
                        thomthom
                        最後由 編輯

                        Anyone got any idea if I can use nokogiri with SU? http://nokogiri.rubyforge.org/nokogiri/
                        Says either 1.8 or 1.9 - but the install is a linux sudo command - can't find any way to download the package manually...

                        Thomas Thomassen — SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 條回覆 最後回覆 回覆 引用 0
                        • tbdT 離線
                          tbd
                          最後由 編輯

                          RubyForge - Page not found

                          favicon

                          (rubyforge.org)

                          1. download the .gem
                          2. rename to .gz or open it with Total Commander
                          3. have a look inside

                          or

                          gem install nokogiri if you have Ruby installed with Gems support

                          or

                          git clone git://github.com/tenderlove/nokogiri.git

                          SketchUp Ruby Consultant | Podium 1.x developer
                          http://plugins.ro

                          1 條回覆 最後回覆 回覆 引用 0
                          • thomthomT 離線
                            thomthom
                            最後由 編輯

                            @unknownuser said:

                            gem install nokogiri if you have Ruby installed with Gems support

                            I had Ruby installed so I entered the command into a console.

                            
                            C;\Users\Thomas>gem install nokogiri
                            Successfully installed nokogiri-1.3.3-x86-mswin32
                            1 gem installed
                            Installing ri documentation for nokogiri-1.3.3-x86-mswin32...
                            Updating ri class cache with 2176 classes...
                            Installing RDoc documentation for nokogiri-1.3.3-x86-mswin32...
                            
                            C;\Users\Thomas>
                            
                            

                            Seems to have worked. But how do I get the files required added and working with SU ruby?

                            Thomas Thomassen — SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

                            1 條回覆 最後回覆 回覆 引用 0
                            • tbdT 離線
                              tbd
                              最後由 編輯

                              search in the gems directory for nokogiri (the lib and ext directory). you can make a test outside Sketchup and use ProcMon to look what files it loads and copy those in SU Plugins subdir

                              SketchUp Ruby Consultant | Podium 1.x developer
                              http://plugins.ro

                              1 條回覆 最後回覆 回覆 引用 0
                              • T 離線
                                toxicvoxel
                                最後由 編輯

                                Having explored a few options in the past I settled on writing a .DLL in .NET that uses the powerful XML query functionality of LINQ to to do the data crunching. By doing this you could call a simple function through COM to retrieve/update specific node and attribute values from SU Ruby. If you do not have knowledge of any of the main .NET languages you could possibly explore using IronRuby for this purpose.

                                1 條回覆 最後回覆 回覆 引用 0
                                • thomthomT 離線
                                  thomthom
                                  最後由 編輯

                                  @unknownuser said:

                                  search in the gems directory for nokogiri (the lib and ext directory). you can make a test outside Sketchup and use ProcMon to look what files it loads and copy those in SU Plugins subdir

                                  I copied nokogiri.rb and nokogiri folder from the lib folder to the SU Plugin folder.

                                  When I start SU I get an error message:

                                  
                                  Error Loading File nokogiri.rb
                                  126; The specified module could not be found.   - C;/Program Files (x86)/Google/Google SketchUp 7/Plugins/nokogiri/1.8/nokogiri.so
                                  
                                  

                                  Which is strange - because the file is there; And a Console test:

                                  
                                  File.exist?('C;/Program Files (x86)/Google/Google SketchUp 7/Plugins/nokogiri/1.8/nokogiri.so')
                                  true
                                  
                                  

                                  So why it claims it's not there - I have no idea.

                                  Thomas Thomassen — SketchUp Monkey & Coding addict
                                  List of my plugins and link to the CookieWare fund

                                  1 條回覆 最後回覆 回覆 引用 0
                                  • thomthomT 離線
                                    thomthom
                                    最後由 編輯

                                    @toxicvoxel said:

                                    Having explored a few options in the past I settled on writing a .DLL in .NET that uses the powerful XML query functionality of LINQ to to do the data crunching. By doing this you could call a simple function through COM to retrieve/update specific node and attribute values from SU Ruby. If you do not have knowledge of any of the main .NET languages you could possibly explore using IronRuby for this purpose.

                                    I've briefly sniffed at C# previously - but I have no idea on how to do what you suggest.

                                    I find it very odd that there isn't a built in XML support in Ruby considering how common XML is.

                                    ...maybe I can send the raw XML content to a Webdialog and have a JS parse it - feeding it back to Ruby. Not ideal - but I can't get any other solutions to work.

                                    Thomas Thomassen — SketchUp Monkey & Coding addict
                                    List of my plugins and link to the CookieWare fund

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • J 離線
                                      Jim
                                      最後由 編輯

                                      It's probably just a matter of getting the paths and require's right. Sometimes when require'ing a .so you might need to respect it's capitalization.

                                      requires dezip.so'

                                      require 'Dezip'

                                      Append your $LOAD_PATH to include the library folder:

                                      On windows (in SetchUp):

                                      $LOAD_PATH.concat eval(c:/ruby/bin/ruby.exe -e "p $:" )

                                      This appends the installed Ruby $LOAD_PATH to SketchUp. (Not well tested by me)

                                      Hi

                                      1 條回覆 最後回覆 回覆 引用 0
                                      • thomthomT 離線
                                        thomthom
                                        最後由 編輯

                                        I'd like to make the lib work by not having full Ruby installed. Want to ship it as a normal SU plugin.

                                        Thomas Thomassen — SketchUp Monkey & Coding addict
                                        List of my plugins and link to the CookieWare fund

                                        1 條回覆 最後回覆 回覆 引用 0
                                        • T 離線
                                          toxicvoxel
                                          最後由 編輯

                                          In basic terms this article may be helpful to explain the principle:
                                          http://stackoverflow.com/questions/265879/can-ruby-import-a-net-dll

                                          If you use IronRuby you may be able to write the XML parser .NET class by leveraging your curent ruby skills.
                                          (You will need to do some homework to confirm that you could make the IronRuby .NET class com-visible though.)
                                          Alternatively if you know java you could use J#.NET.

                                          1 條回覆 最後回覆 回覆 引用 0
                                          • tbdT 離線
                                            tbd
                                            最後由 編輯

                                            I will try to look tomorrow when I get on my Windows machine and make a SU friendly package of a XML parser.

                                            It all depends on what XML files you need to parse - if they are static, then you can write a specific XML parser yourself and save the troubles. I wouldn't use XML for anything, hate that format 😉

                                            SketchUp Ruby Consultant | Podium 1.x developer
                                            http://plugins.ro

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

                                            Advertisement