• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Exporting defined attributes to Excel

Scheduled Pinned Locked Moved Plugins
3 Posts 2 Posters 646 Views 2 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.
  • K Offline
    Kenny
    last edited by 23 May 2015, 13:07

    I'm wondering if it's possible to automate a process that I currently do manually. The attached spreadsheet sets out the following information:

    Description of housing units
    Size of each unit
    Number of bedrooms in each unit
    Total square footage of each unit
    Number of Affordable (social) units
    Number of Private (open market) units
    Total square footage of each unit
    Gross Site Area
    Net development Area
    Square feet per acre

    At the moment I name each housing component with a description, number of bedrooms and square footage. I then have to manually sort through the Outliner to find each component, add them up and input the information into the spreadsheet. If I change the design then I have to manually update it every time. It can be quite laborious and I have to double and triple check to avoid errors.

    Does anyone know of an extension that could do this automatically, or if not is it something that could easily be written? The attributes would need to be defined first but if for example the square footage of each unit was input into the definition category of the entity information then I'm hoping that it could then generate something like the example report I've provided.

    The icing on the cake is if it could also work the other way where I can select particular units and amounts of each in a spreadsheet and these are populated into a SketchUp file.


    Example Schedule for automating.xls

    http://www.townscapesolutions.co.uk/

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 23 May 2015, 17:07

      So you have Component definition "A Type 1" with a Description like "2:750" for number of beds and sqft.
      Provided you are consistent in the format of the description it's simple to extract the number of each component's instances and their beds/sqft from the description...
      Although it is possible to right the data to an XLS file, I'd suggest a CSV file with separating commas - it'll open in Excel and you could even OLE that into a formatted XLS...
      Here's some cod-code to get your ideas going...

      model=Sketchup.active_model
      filepath="C;/some...folders/#{model.title}_House_Type_Schedule.csv"
      ### perhaps the File.dirname(model.path)+"/#{model.title}_House_Type_Schedule.csv"
      file=File.open(filepath, "w")
      file.puts("House Type Schedule")
      file.puts("Type,Number,Beds,sqft,Total")
      file.puts("Affordable")
      totA=0
      totP=0
      countA=0
      countP=0
      names=[]
      model.definitions.each{|d|
        next unless d.name =~ /^[AP]/
        names << d.name
      }
      names.sort!
      done=false
      names.each{|name|
        if name =~ /^P/ && !done
          file.puts("Private")
          done=true
        end
        d=model.definitions[name]
        len=d.instances.length
        next unless len > 0
        desc=d.description.split(";")
        next unless desc.length==2
        beds,sqft=desc
        total=sqft*len
        file.puts("#{name},#{len},#{beds},#{sqft},#{total}")
        if d.name =~ /^A/
          totA+=total
          countA+=len
        else ### P
          totP+=total
          countP+=len
        end
      }
      ### end totals etc
      file.puts("Affordable,#{countA},,,#{totA}")
      file.puts("Private,#{countP},,,#{totP}")
      file.puts("Total Units,#{countA+countP},,,#{totA+totP}")
      ###
      # Site Areas etc...
      ###
      file.close
      

      I'll leave you to think how to get the site areas and calculate the development ratio etc...

      TIG

      1 Reply Last reply Reply Quote 0
      • K Offline
        Kenny
        last edited by 24 May 2015, 11:38

        TIG, Thanks for your reply and code. I pasted it into the Ruby console but I got an error message, although I'm not exactly sure of the procedure. Does each component have to be named in a certain convention for example?

        Ideally I'd like to be able to load an extension which then allows me to select the required components (either in the drawing or in the Outliner) and then export the details to a spreadsheet similar to the example I gave. The site area can just be manually input into the spreadsheet as it is less likely to change. The development ratio is calculated by Excel from the number of units and square footage.

        I'll PM you.

        http://www.townscapesolutions.co.uk/

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

        Advertisement