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

    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.
    • chrisglasierC Offline
      chrisglasier
      last edited by

      wdbao, I hope you don't mind my moving our PM discussion here. It just might be of interest to others.

      In a PM to me
      @wdbao said:

      ... i hope i can contribute sth to this nice community
      but i haven't had much time, most of the time i have to work day and night
      believe me ...

      Living in Hong Kong and China for many years I certainly believe you!

      So I am wondering, in pursuit of the point behind the question in the title, whether you would be better off for the time being just acknowledging that Ruby code can assemble components as a 3D model and concentrate on exploring how to structure data of one of your current projects that will later enable you to so. The same data can be used for buying materials, planning and monitoring progress, instructing labour, supporting payment requests and so on. So you should be able to incorporate your research into your day to day work for the benefit of your business.

      As I mentioned in one of my PMs I was responsible for fitting out the Forum Hotel in Shenzhen, China - 750 guestrooms and three floors of public spaces - where I put to the test my previous adventures into using spreadsheets for large quantities of data (particularly on Norman Foster's Hong Kong Bank project). This was in 1988 about a year after Lotus introduced their multi-sheet application (123 v 4.0), which initially I thought would greatly help deal with the three dimensional nature of data. But it didn't; let me explain using a simple example of a concrete column by looking at the hierarchies within the data.

      COLUMN > Width, depth, height, x, y, z;
      COLUMN > Material, labour, equipment;
      COLUMN > Start date, duration
      COLUMN - Material > Concrete, rebar, plywood, struts, clamps;
      COLUMN - Labour > Steel fixer, carpenter, concretor;

      Of course this is just the start (yet to list are suppliers, costs, prices, instances of other columns and on and on). It is like you need to keep turning each list through 90 degs alternatively on the XY, XZ and YZ planes; it just doesn't work; either the data overlays other data on the XY plane or is just too difficult to drill down into the underlying sheets in the Z oriented planes.

      What we did on the Forum Hotel was to list everything in one column only adding data to columns to the right to terminate a hierarchy - e.g. width = 300mm. We set up a number of columns on the left of the data for various indexes to allow us to alternatively sort the data into different aspects of the object in question. One aspect was shop drawings (drawn by hand in those days) which now could be the natural output of structured data as a fully supported Sketchup model. And of course all that tedious sorting can now be avoided by animation.

      What I realised from our discussion so far was that the menu system I was using for namesets wasn't in line with what I have said. So I have now started to redevelop it. I think the structure is OK for the objects in the nameset itself; it's the backup that assumes devices rather devices being called by the data (or something like that!).

      Anyway I think if you would like to start to introduce some of what I have said into your day to day work, hopefully quite soon I can take your data and turn it into a nameset ... and then we can use it to start generating Sketchup models. This should then help you learn Ruby coding.

      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
      • M Offline
        minguinhirigue
        last edited by

        wdbao, any improvment in this big project of yours ?

        1 Reply Last reply Reply Quote 0
        • W Offline
          wdbao
          last edited by

          @chrisglasier said:

          Also for the Ruby part see Automatic Sketchup which is reviewed in this topic.

          been busy with a lot of stuff
          now i am reading the automatic sketchup, since the author make the pdf file public.
          it's a really great work.
          and only now i truely understand the important of hirarchy chris have told me about.

          1 Reply Last reply Reply Quote 0
          • W Offline
            wdbao
            last edited by

            @minguinhirigue said:

            wdbao, any improvment in this big project of yours ?

            progress has been slow
            now i still looking for ways to read csv files from inside the ruby script
            and make use of the data in csv files

            1 Reply Last reply Reply Quote 0
            • W Offline
              wdbao
              last edited by

              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
              • chrisglasierC Offline
                chrisglasier
                last edited by

                @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

                  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
                  • Dan RathbunD Offline
                    Dan Rathbun
                    last edited by

                    @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
                    • Dan RathbunD Offline
                      Dan Rathbun
                      last edited by

                      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

                        @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
                        • Dan RathbunD Offline
                          Dan Rathbun
                          last edited by

                          @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

                            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
                            • Dan RathbunD Offline
                              Dan Rathbun
                              last edited by

                              @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

                                @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
                                • chrisglasierC Offline
                                  chrisglasier
                                  last edited by

                                  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
                                  • First post
                                    Last post
                                  Buy SketchPlus
                                  Buy SUbD
                                  Buy WrapR
                                  Buy eBook
                                  Buy Modelur
                                  Buy Vertex Tools
                                  Buy SketchCuisine
                                  Buy FormFonts

                                  Advertisement