SketchUp Links to database

Is it possible to create simple drawings from data in either a database or spread sheet. Starting with a simple cube shape with just Height x Width x Depth. So that a drawing can be created from just data? I believe this is called parametric programming

1 Like

check this extension:
https://extensions.sketchup.com/nl/content/shapes

this will create basic shapes.

If you want to edit shapes, you could create Dynamic Components:

Cube Parametric.skp (191.7 KB)

Profile Builder creates Parametric shapes and goes one step further…

1 Like

You can create a Ruby plugin to open and read information from a file. Depending on what it is you want to do with the data, the SketchUp Ruby APIs can be used to create the geometry desired. Given a text file with data formatted as Height,Width,Depth:

12.5,22,12
10,2,4

You can use the plugin found here to import them:

https://sites.google.com/site/spirixcode/code/jimhami42_import_boxes.rbz

NOTE: This assumes that the values are in inches. If you are using others units, simply scale everything when done.

2 Likes

What computer language is used in creating a Ruby Plug in

Ruby plugins are written in Ruby. The Import Boxes plugin is short and simple:

#----------------------------------------------------------------------------------------
require 'sketchup.rb'
#----------------------------------------------------------------------------------------
module Jimhami42
  module ImportBoxes
# MAIN BODY -----------------------------------------------------------------------------
#
    class  << self
      def import_boxes()
        model = Sketchup.active_model
        filename = UI.openpanel("Select TXT File", "~", "Text Files|*.txt;||")
        data = File.open(filename,"r")
        while(t = data.gets)
          t.gsub(/\s+/,"").chomp
          h,w,d = t.split(',')
          g = model.entities.add_group
          f = g.entities.add_face([0,0,0],[w.to_f,0,0],[w.to_f,d.to_f,0],[0,d.to_f,0])
          f.reverse!
          f.pushpull(h.to_f,0)
        end
      end
    end
# MAIN BODY -----------------------------------------------------------------------------
    unless file_loaded?("jimhami42_import_boxes.rb")
      menu = UI.menu("PlugIns").add_item("Import Boxes") { import_boxes() }
    file_loaded("jimhami42_import_boxes.rb")
    end
# MAIN BODY -----------------------------------------------------------------------------
  end
end

The plugins can be created with almost any text editor and saved as a text file with the extension “.rb”. Zipping the text file into a “.zip” file and renaming it to an “.rbz” extension, will allow it to be imported into SketchUp’s extensions.

Ruby documentation can be found here: https://ruby-doc.org/
SketchUp Ruby APIs can be found here: http://ruby.sketchup.com/

1 Like

What color is the White House ?
Who’s buried in Grant’s tomb?

:rofl:


Please see the search results for previous topics on this subject …

Or for available extensions …

2 Likes

That’s very helpful Thank you

1 Like

Yes it’s easy when you know!!

That’s amazing

That’s clever