sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Turn 3D model dimensions into a text file?

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    16 Posts 6 Posters 2.5k Views 6 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.
    • T Offline
      toxicvoxel
      last edited by

      An option may be to export to dxf and parse the object text data from there.
      It will however require you to write a dxf parser if you can't use any commercial dxf object reader in your project. Not too difficult to do once you understand the dxf file structure.

      1 Reply Last reply Reply Quote 0
      • TaffGochT Offline
        TaffGoch
        last edited by

        Metterz,

        As toxicvoxel suggests, I commonly use DXF to both import and export a text file describing lines, endpoints and faces. Note that most DXF files are text files. (Some can be binary, but SketchUp will export the ASCII text version.)

        You can use a text editor, if the model is not too complex, but I also (more often) use Excel. You can learn about the DXF format at the AutoDesk website:

        ASCII DXF File Format

        Regards,
        Taff

        "Information is not knowledge." -- Albert Einstein

        1 Reply Last reply Reply Quote 0
        • GaieusG Offline
          Gaieus
          last edited by

          I am a total non programmer but the collada (*.dae) file SU is capable to export is also a text file (in *.xml format).

          XML format is becoming kind of "popular" nowadays, too. The advantage of it is that even the free version of SU exports it - hidden in the kmz file which is actually a zip file (you can rename it and open it to see within the model folder).

          Gai...

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

            Do you mean simple width, depth, and height information? If so, then you could use Groups to specify each "thing" and export its overall dimensions to a text file.

            Hi

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

              Ok there's no way I can afford SU Pro to export anything other than .kmz files. Is it possible to make a text file without exporting files, eg. using Ruby?

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

                And besides, the program's meant to be written for an end user, so the SU part of the whole thing has to be the freeware version...

                Thanks all for your help

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

                  @metterz said:

                  Ok there's no way I can afford SU Pro to export anything other than .kmz files. Is it possible to make a text file without exporting files, eg. using Ruby?

                  Yes, it's possible, but it's not clear to me exactly what data you need as the output?

                  Hi

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

                    Just a string of numbers will probably do, like maybe co-ords of each corner of each group/component. I just need some text file data that MS Access can use to easily acquire the dimensions of groups/components in a SU file. It will probably easier if I can make an Excel spreadsheet though, instead of a text file.
                    I don't know how the contents of the dimensions file will be arranged, but i'll try to work with whatever I can get out of the SU model

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

                      At a basic level, this will do what you need.

                      
                      
                      outfile = File.new( "c;\\output.csv", "w")
                      
                      Sketchup.active_model.entities.each do |e|
                        next unless e.is_a? Sketchup;;Group or e.is_a? Sketchup;;ConponentInstance
                        bbox = e.bounds
                        0.upto(7) do |i|
                          c = bbox.corner(i)
                          outfile.print "#{c.x.to_f},#{c.y.to_f},#{c.z.to_f}\n"
                        end
                        outfile.puts "\n"
                      end
                      outfile.close
                      
                      

                      Hi

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

                        Ok thanks a lot, but what language is this code in? I tried entering it into Ruby but it died on the second line... Sorry if i'm being awkward, my programming experience is limited - particularly with SU.

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

                          I'll be more specific there: it gave me a syntax error message on the second line...

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

                            Sorry about that, I had to hurry off thismorning.

                            The following snippet is still not a full-featured plugin. Everything is hard-coded in the script. You will need to edit the script and restart SketchUp to make any edits effective. It is just a quick example of how to do it.

                            I gave it a menu item in the Plugins menu called "Export corners."

                            
                            UI.menu("Plugins").add_item("Export Corners") do
                              outfile = File.new( "c;\\output.csv", "w")
                              Sketchup.active_model.entities.each do |e|
                                next unless e.is_a? Sketchup;;Group or e.is_a? Sketchup;;ComponentInstance
                                bbox = e.bounds
                                0.upto(7) do |i|
                                  c = bbox.corner(i)
                                  outfile.print "#{c.x.to_f},#{c.y.to_f},#{c.z.to_f}\n"
                                end
                                outfile.puts "\n"
                              end
                              outfile.close
                            end
                            
                            
                            

                            Hi

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

                              Ok, after entering the first line into the Ruby Console, I got this...

                              UI.menu("Plugins").add_item("Export Corners") do
                              Error; #<SyntaxError; (eval);149; compile error
                              (eval);149; syntax error
                              UI.menu("Plugins").add_item("Export Corners") do
                                                                              ^>
                              (eval);149
                              

                              I'm guessing the code isn't intended for Ruby, so where do I enter it to get the plugin working?

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

                                Oh sorry again - I keep making assumptions that people can read my mind.

                                Here is a file to download and put in your Plugins folder; then restart SketchUp.


                                export_corners.rb

                                Hi

                                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