sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Looking for File Parcer

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 4 Posters 1.5k 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.
    • A Offline
      a4chitect
      last edited by

      you mean a tool able to parse text data into geometry?

      1 Reply Last reply Reply Quote 0
      • T Offline
        todd burch
        last edited by

        Can you be more specific? Is this on Windows? Once this text is parsed, what do you want to do with it?

        1 Reply Last reply Reply Quote 0
        • T Offline
          todd burch
          last edited by

          Any scripting language with Regular Expression (RE) support comes to mind, (Perl, Ruby, Python, VB) unless the format is so predictable that parsing based on column offsets and/or data attributes doesn't warrant RE use. I've done several tasks for myself and others using Ruby to perform such a task. The last one was for a telephone company in Oklahoma, parsing out records for a reverse-phone number lookup directory. (sorted on phone number, not last name).

          Not sure what a .cdf is.

          If you want to send me a complete sample, I can quote it for you.

          1 Reply Last reply Reply Quote 0
          • M Offline
            mozzie
            last edited by

            For "quick and dirty" stuff, there's a number of old command line utilities ... free.

            I've used "gawk" with considerable success extracting data from various proprietary/COBOL datasets of 100,000s of lines. Its a really simple regular expression script language, well documented (O'Reilly or The AWK book http://www.gnu.org/software/gawk/manual/gawk.html), available for Windows (http://gnuwin32.sourceforge.net/packages/gawk.htm) Mac (http://gawk.darwinports.com/) etc.

            It reads a line of text, does the parsing, writes it out. Fast.

            If you have formatted printout type data then I've also had success with Monarch (but its expensive) http://www.datawatch.com/

            Good luck

            1 Reply Last reply Reply Quote 0
            • AdamBA Offline
              AdamB
              last edited by

              Sure you could use grep, sed etc but wait, what if we had a scripting language in Sketchup that had good file reading capability, powerful regular expression matching, and a binding to the Sketchup geometry API etc.

              I guess we can only hope. πŸ˜„

              Seriously, something like this works fine:

              
              IO.foreach("my_inputfile.ext") { |aline|
              
                      /^(\S*) ([^$]*)/.match(aline)
                      verb = $1
                      rest = $2
                      case verb
              
                      ....whatever you need to do here eg entities.add_face, entities.add_group etc
              }
              
              

              This is my mickey mouse .obj importer I use for Sketchup:

              
              pos = []
              tex = []
              group = nil
              
              IO.foreach("/tmp/test.obj") { |aline|
              
                      /^(\S*) ([^$]*)/.match(aline)
              
                      verb = $1
                      rest = $2
                      case verb
                              when "s"
                                      # ignore smoothing group
                              when "v"
                                      # close current group
                                      if group
                                              pos = []
                                              tex = []
                                              group = nil
                                      end
                                      / (\S*) (\S*) (\S*)/.match(rest)
                                      pos.push Geom;;Point3d.new($1.to_f,$2.to_f,$3.to_f)
                              when "f"
                                      if /(\S*)\/(\S*) (\S*)\/(\S*) (\S*)\/(\S*)/.match(rest)
                                              vertices = [pos[$1.to_i], pos[$3.to_i], pos[$5.to_i]]
                                      elsif /(\S*) (\S*) (\S*)/.match(rest)
                                              vertices = [pos[$1.to_i], pos[$2.to_i], pos[$3.to_i]]
                                      end
                                      group.entities.add_face vertices
                              when "g"
                                      # open a new group
                                      /(\S*)/.match(rest)
                                      group = Sketchup.active_model.entities.add_group
                                      group.name = $1
                                      puts "group(#{$1})"
                      end
              }
              
              

              Adam

              Developer of LightUp Click for website

              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