sketchucation logo sketchucation
    • 登入
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🔌 Smart Spline | Fluid way to handle splines for furniture design and complex structures. Download

    Can i draw the whole building structure with code?

    已排程 已置頂 已鎖定 已移動 Developers' Forum
    31 貼文 7 Posters 3.9k 瀏覽 7 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • W 離線
      wdbao
      最後由 編輯

      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 條回覆 最後回覆 回覆 引用 0
      • chrisglasierC 離線
        chrisglasier
        最後由 編輯

        @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 條回覆 最後回覆 回覆 引用 0
        • W 離線
          wdbao
          最後由 編輯

          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 條回覆 最後回覆 回覆 引用 0
          • Dan RathbunD 離線
            Dan Rathbun
            最後由 編輯

            @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 條回覆 最後回覆 回覆 引用 0
            • Dan RathbunD 離線
              Dan Rathbun
              最後由 編輯

              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 條回覆 最後回覆 回覆 引用 0
              • W 離線
                wdbao
                最後由 編輯

                @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 條回覆 最後回覆 回覆 引用 0
                • Dan RathbunD 離線
                  Dan Rathbun
                  最後由 編輯

                  @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 條回覆 最後回覆 回覆 引用 0
                  • W 離線
                    wdbao
                    最後由 編輯

                    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 條回覆 最後回覆 回覆 引用 0
                    • Dan RathbunD 離線
                      Dan Rathbun
                      最後由 編輯

                      @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 條回覆 最後回覆 回覆 引用 0
                      • W 離線
                        wdbao
                        最後由 編輯

                        @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 條回覆 最後回覆 回覆 引用 0
                        • chrisglasierC 離線
                          chrisglasier
                          最後由 編輯

                          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 條回覆 最後回覆 回覆 引用 0
                          • 1
                          • 2
                          • 2 / 2
                          • 第一個貼文
                            最後的貼文
                          Buy SketchPlus
                          Buy SUbD
                          Buy WrapR
                          Buy eBook
                          Buy Modelur
                          Buy Vertex Tools
                          Buy SketchCuisine
                          Buy FormFonts

                          Advertisement