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

Can i draw the whole building structure with code?

Scheduled Pinned Locked Moved Developers' Forum
31 Posts 7 Posters 3.3k Views 7 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.
  • W Offline
    wdbao
    last edited by 24 Jul 2010, 16:44

    it seems to me that Sketchup Ruby API don't have the CSV library.
    should i just use the File class
    or should i add the csv module to it
    and how?

    1 Reply Last reply Reply Quote 0
    • C Offline
      chrisglasier
      last edited by 25 Jul 2010, 00:09

      @wdbao said:

      it seems to me that Sketchup Ruby API don't have the CSV library.
      should i just use the File class
      or should i add the csv module to it
      and how?

      I used this to collect data from json files (could be csv text files)...

      @dlg.add_action_callback("send") { |d, a|
      			nr = Integer(a)
      			subDir = "nset/"
      			files = ["config","nset","mset","words","numbers"]
      			lines = []
      			file = File.join(File.dirname(__FILE__), files[nr] + ".json")
      			File.open(file, 'r') do |f1|
      				while line = f1.gets  
      					lines.push line  
      				end
      			end 
      			array = [nr,lines]
      			array = array.join("qq")
      			#p array
      			script = "rubyReceive('#{array}')";
      			d.execute_script(script)
      
      

      I don't know what you mean by csv library.

      With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

      1 Reply Last reply Reply Quote 0
      • W Offline
        wdbao
        last edited by 25 Jul 2010, 00:31

        i mean CSV library as one of the Ruby Standard Library
        http://forums.sketchucation.com/viewtopic.php?f=180&t=29544&start=0&hilit=ruby+library

        1 Reply Last reply Reply Quote 0
        • D Offline
          Dan Rathbun
          last edited by 25 Jul 2010, 01:42

          @wdbao said:

          i mean CSV library as one of the Ruby Standard Library
          http://forums.sketchucation.com/viewtopic.php?f=180&t=29544&start=0&hilit=ruby+library

          You can add the paths to the full Ruby Library directories, and load from there.
          See a script I posted here, tweek it to your system, version etc.
          (code) Ruby LOAD PATHs script for (Win32)

          You should try to run the same Lib versions as the interpreter that Sketchup loads.
          Are you on a Mac/OSX or PC/Win32 ??

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 25 Jul 2010, 01:52

            To talk more about your CSV File question, I thought TIG posted an example here somewhere on the forums.

            It's not that hard.
            As each line of the file is read ( f = file.readline ) the var contains a string, so you'd use the String method .split and specify the character to split by.
            record = f.split(',')
            At that point the var record is an Array of String values.

            It's up to you if you wish to convert each record to Ruby data, line by line; or just collect an Array of record Arrays, close the file, then do your conversions all at once with a nested loop.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • W Offline
              wdbao
              last edited by 28 Jul 2010, 00:14

              @dan rathbun said:

              To talk more about your CSV File question, I thought TIG posted an example here somewhere on the forums.

              It's not that hard.
              As each line of the file is read ( f = file.readline ) the var contains a string, so you'd use the String method .split and specify the character to split by.
              record = f.split(',')
              At that point the var record is an Array of String values.

              It's up to you if you wish to convert each record to Ruby data, line by line; or just collect an Array of record Arrays, close the file, then do your conversions all at once with a nested loop.

              thanks Dan
              it is easy to get the data on csv file this way. or any other files

              1 Reply Last reply Reply Quote 0
              • D Offline
                Dan Rathbun
                last edited by 28 Jul 2010, 00:35

                @wdbao said:

                thanks Dan
                it is easy to get the data on csv file this way. or any other files

                Is this a question ??

                Do you want examples ??

                EDIT: Well, I posted 1 example using Ruby's IO class:
                [code] reading a CSV file

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • W Offline
                  wdbao
                  last edited by 28 Jul 2010, 12:14

                  thanks again.
                  it is not a question.
                  your help is greatly appreciated.
                  the example code you posted is good for separating the header.
                  but i want to parse the data into hash.
                  then i can access the data in a natural way.

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    Dan Rathbun
                    last edited by 28 Jul 2010, 16:51

                    @wdbao said:

                    but i want to parse the data into hash.
                    then i can access the data in a natural way.

                    OK posted a second example that outputs record Hashes, same thread.
                    [code] reading a CSV file

                    I'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • W Offline
                      wdbao
                      last edited by 29 Jul 2010, 12:07

                      @dan rathbun said:

                      @wdbao said:

                      but i want to parse the data into hash.
                      then i can access the data in a natural way.

                      OK posted a second example that outputs record Hashes, same thread.
                      [code] reading a CSV file

                      Dan, you are marvellous! this will do.

                      1 Reply Last reply Reply Quote 0
                      • C Offline
                        chrisglasier
                        last edited by 31 Jul 2010, 06:18

                        I see that you are progressing well with the "technology" side of csv data storage but I wonder (because I am interested in alternative methods) how you are coping with the complexity of the information itself.

                        I have been always wary of csv because I associate it with spreadsheets and though I have tried very hard from the early days of Lotus 123 I have not found a way to use them to "turn" data to cope with its 3D nature.

                        What I mean by turn is illustrated by the diagram to the left which suggests it is natural to use a cross section to review the number of floors in a building but plan section to review each floor's spaces. I think this is sufficient to demonstrate data is 3d in nature (or perhaps more accurately access to it). The animation I have demonstrated before allows me to cope with it in a 2D UI.

                        Information that is often presented as schedules - rebar, door, sanitaryware, ironmongery(hardware) and so on - can be dealt with in the same way, but the properties of the real (as opposed to code) objects require a data or backup display so that you can see collections of key/value pairs for editting.

                        So assuming you agree basically with what I describe, it would be would interesting to see both a UI design and the structure of the csv or hash solution to compare with the UI and Javascript object notation (json) that I currently use.

                        Cheers!

                        With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

                        1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 2 / 2
                        2 / 2
                        • First post
                          21/31
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement