sketchucation logo sketchucation
    • Login
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    [code] ruby-dxf-reader

    Scheduled Pinned Locked Moved Developers' Forum
    15 Posts 5 Posters 4.1k Views 5 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.
    • J Offline
      Jim
      last edited by

      This code now lives at ruby-dxf-reader on Bitbucket.

      There are 2 branches. Branch 1.0 is a simple version which parses a .dxf into a Ruby Hash of Hashes and Arrays. This is the file posted in the previous post.

      Branch 2 (in progress) does the same job - parsing .dxf files - but uses a hierarchy of classes. These classes map to DXF objects and entities and provide convenience methods for accessing group codes. The hierarchy currently looks like this:

      http://yuml.me/768181e6

      Hi

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        πŸ‘

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

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          Very cool Jim. I'll probably be digging into this script more later this summer. Excellent work!

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

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

            FYI.. I checked Rubyforge and Rubygems to see if anyone had previously created a DXF or DWG Ruby class/module, but got no hits.

            I was surprised that noone has done this before !

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              It'd be nice of it was possible to generate some documentation from the code. RDoc or Yard for instance. (I prefer Yard)
              Is that something you'd also accept contributions for?

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

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                Which reference to the DXF format do you use?

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

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

                  @thomthom said:

                  Which reference to the DXF format do you use?

                  I've been reading the latest and the oldest I could find. It appears the latest versions of the dxf file format are backwards compatible with the earliest as far as parsing the files. New entity types have been added in later versions, new codes have been used, but the algorithm for reading the file and transforming the entities into useful objects should work for all versions of dxf.

                  It remains to be seen if the various versions of the file format will require different methods for drawing the entities. So far in testing, the version appears not to be an issue.

                  @thomthom said:

                  It'd be nice of it was possible to generate some documentation from the code. RDoc or Yard for instance. (I prefer Yard)
                  Is that something you'd also accept contributions for?

                  Absolutely. I was looking at rdoc and yard and based on syntax and features, yard is the one I was likely to go with.

                  @dan rathbun said:

                  I was surprised that noone has done this before !

                  Same here. There are one or two readers written in python, but nothing for Ruby.

                  Hi

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    Yard supports the RDoc syntax - but adds some more explicit structure to it. Been using it for TT_Lib2 and some other project now. I've found it very useful to generate a lookup resource I can use.

                    File: README β€” Documentation by YARD 0.9.9

                    favicon

                    (www.thomthom.net)

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

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      Another thing that might help collaboration is if variables got some more descriptive names other than a single character. Would make it easier to deduce the flow of the code without tracking it all the way to its root.

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

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

                        c, v = code and value throughout the code. They are the group code and value pair which are the "atoms" on which a dxf file is composed.

                        Dxf objects are collections of (code,value) pairs. However, some values may be a single item while others may be a list of items (implemented as an Ruby Array.)

                        The code also determines the type of the value; i.e. Integer, Float, or String.

                        In general, I agree that using more descriptive names would help understanding. πŸ‘

                        Hi

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by

                          Ok good. Just trying to catch up to it's flow.

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

                          1 Reply Last reply Reply Quote 0
                          • DavidBoulderD Offline
                            DavidBoulder
                            last edited by

                            Jim, what is the licencing like on ruby-dxf-reader? In particular I'm wondering if it could be included in the code base for an open source project http://openstudio.nrel.gov/ or if it could be used in a measure (our equivalent of a plugin) on the Building Component Library https://bcl.nrel.gov/. We already support gbXML as an import option, but I'd like to support DXF as well so almost any modeling tool can be used as a starting point.

                            David

                            --

                            David Goldwasser
                            OpenStudio Developer
                            National Renewable Energy Laboratory

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

                              Hi David,

                              I put it up on GitHub.

                              Hi

                              1 Reply Last reply Reply Quote 0
                              • DavidBoulderD Offline
                                DavidBoulder
                                last edited by

                                @jim said:

                                Hi David,

                                I put it up on GitHub.

                                Thanks!! I'll check it out this weekend.

                                David

                                --

                                David Goldwasser
                                OpenStudio Developer
                                National Renewable Energy Laboratory

                                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