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

    How to read/parse XML files inside SU

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 4 Posters 791 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.
    • F Offline
      fpmalard
      last edited by

      Hello,

      What is the best way to read/parse XML files inside a SU Ruby script?
      Do I need a specific XML Ruby library or do SU support this natively?

      Regards,
      Fernando.

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

        It depends on what the XML structure and data represent. For processing XML there are some Ruby libraries, i. e. REXML (but REXML seems to be a bit slow). I have used it for ModelHistory which isn't in the wild because I'm lazy 😉

        azuby

        *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

        Bad English? PM me, correct me. :smile:**

        1 Reply Last reply Reply Quote 0
        • tbdT Offline
          tbd
          last edited by

          one idea, if you are on Windows (dont know about Mac) - use win32api and load xerces-c_2_6.dll that is available with Sketchup distro

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

          1 Reply Last reply Reply Quote 0
          • W Offline
            Whaat
            last edited by

            @azuby said:

            It depends on what the XML structure and data represent. For processing XML there are some Ruby libraries, i. e. REXML (but REXML seems to be a bit slow). I have used it for ModelHistory which isn't in the wild because I'm lazy 😉

            azuby

            So...is it true that REXML is not part of the Ruby SketchUp distribution? How do I use this library? I downloaded REXML from this site:
            http://www.germane-software.com/software/rexml/

            It comes as a zip file that contains a ton of files. Do I need to include all these files with my plugin if I want to use the REXML API? I would like to include just one file if possible.

            Thanks.

            SketchUp Plugins for Professionals

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

              If I remember right, I had a fully installed Ruby on my PC and took the REXML lib from it. The directory contains 55 files and five folders. I loaded it this way from my script:

              require 'rexml/document' unless defined? REXML
              

              If you also want to load this way you have to make sure that the Ruby interpreter search in the right place. Put the REXML folder to Plugins or Tools folder - should work with the above code.

              To make sure that your script only runs if REXML is loaded, put this condition to your codee:

              if defined? REXML
                # YOUR CODE HERE
              else
                UI.messagebox "REXML is missed, can't load plugin."
              end
              

              Sorry for my late answer - I'm moving from town to town at the moment.

              azuby

              *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

              Bad English? PM me, correct me. :smile:**

              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