Skip to content
This repository was archived by the owner on Sep 17, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
74f4873
First Commit with minor Comments added
MrKriss Mar 14, 2013
3a8b321
Restructured folders to hold all plugin code in a single folder, and a
MrKriss Mar 15, 2013
ecc56a6
Added .rbz file for extension install
MrKriss Mar 15, 2013
d6efc62
Minor changes to README
MrKriss Mar 15, 2013
67f3b27
Changed folder name to wikihouse-extension
MrKriss Mar 16, 2013
941a935
make or make build now generates wikihouse_extension.rbz
MrKriss Mar 18, 2013
29689b1
Introduced an encapsulating Module 'WikihouseExtension' to allow for
MrKriss Apr 1, 2013
30721ec
Fixed the error. Origin was extra white space in generated svg file.
MrKriss Apr 1, 2013
1a2c764
Minor comment edits + experimenting with SVG writer code.
MrKriss Apr 9, 2013
4808846
Updated Make file to also install files into default location on Mac
MrKriss Apr 28, 2013
020f1a4
All Web dialogue will soon be moved here fore easier reference.
MrKriss Apr 28, 2013
5faf0c8
New JSON module for parsing of Ruby Hashes and Arrays to and from json
MrKriss Apr 28, 2013
0018ed9
File no longer needed. Constants moved into utils.rb or
MrKriss Apr 28, 2013
5ee3cac
Added some more constants
MrKriss Apr 28, 2013
8eeae13
Changed dimensions to a module vaiable. Added a Hash
MrKriss Apr 28, 2013
049f861
Added settings Web Dialogue. Testing in progress.
MrKriss Apr 28, 2013
29d1978
Finished Testing Settings Web Dialogue.
MrKriss Apr 28, 2013
2e53890
Moved all Web Dialogue related code to one file.
MrKriss Apr 29, 2013
fcc3ede
Make wikihouse_settings a global variable and added sheet_depth
MrKriss Apr 29, 2013
5a7ecd6
Added Changes log file
MrKriss Apr 29, 2013
605bc79
Updated + added alternative manual install
MrKriss Apr 29, 2013
dd4d24a
Minor formating edits
MrKriss Apr 29, 2013
f8684a4
Minor markdown edits
MrKriss Apr 29, 2013
f2fb33f
minor edits to markdown
MrKriss Apr 29, 2013
afc6090
Fixed error in Web Dialogue save and error callbacks.
MrKriss May 26, 2013
81556e8
Added install_mac_SU8 and install_mac_SU2013 options for make file.
MrKriss May 26, 2013
d41c070
Minor edits
MrKriss May 26, 2013
d6d11f4
Changed JSON to a class instead of module. Seems there is a validation
MrKriss May 26, 2013
37bf202
Located the bug in downloading via web dialogues
MrKriss May 26, 2013
6a97356
Minor comment additions to WikihouseLayoutEngine
MrKriss May 27, 2013
cb485d8
Lowered threshold on face area to include. Now able to detect C parts in
MrKriss May 27, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ruby Extension Files #
########################
*.rbz
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Make file for creating wikihouse_extention.rbz

assets=wikihouse-extension/wikihouse-assets/*
libs=wikihouse-extension/lib/*

plugin_dir_2013=${HOME}/Library/Application\ Support/SketchUp\ 2013/SketchUp/Plugins/
plugin_dir_SU8=/Library/Application\ Support/Google\ SketchUp\ 8/SketchUp/plugins/

# Store current git revision
git-rev=$(git rev-parse --short=8 HEAD)

# May need changing - not sure if full url is used for amazon buckets
wikihouse_bucket="https://wikihouse.s3.amazonaws.com/sketchup/"


build: wikihouse_extension_loader.rb $(assets) $(libs)
# Creating .rbz file
zip wikihouse_extension.rbz \
wikihouse_extension_loader.rb \
wikihouse-extension/wikihouse.rb \
$(assets) \
$(libs)

release: wikihouse_extension.rbz
# s3put BUCKET/[OBJECT] [FILE] - OBJECT is the name FILE is saved as in BUCKET
s3put ${wikihouse_bucket}wikihouse_extension-$git-rev.rbz wikihouse_extension.rbz
s3put ${wikihouse_bucket}wikihouse_extension.rbz wikihouse_extension.rbz

install_mac_SU8: wikihouse_extension_loader.rb wikihouse-extension/wikihouse.rb $(assets) $(libs)
# Copying files to their locations
cp -v wikihouse_extension_loader.rb $(plugin_dir_SU8)
cp -v wikihouse-extension/wikihouse.rb $(plugin_dir_SU8)wikihouse-extension/wikihouse.rb
cp -v $(assets) $(plugin_dir_SU8)wikihouse-extension/wikihouse-assets/
cp -v $(libs) $(plugin_dir_SU8)wikihouse-extension/lib/

install_mac_SU2013: wikihouse_extension_loader.rb wikihouse-extension/wikihouse.rb $(assets) $(libs)
# Copying files to their locations
cp -v wikihouse_extension_loader.rb $(plugin_dir_2013)
cp -v wikihouse-extension/wikihouse.rb $(plugin_dir_2013)wikihouse-extension/
cp -v $(assets) $(plugin_dir_2013)/wikihouse-extension/wikihouse-assets/
cp -v $(libs) $(plugin_dir_2013)/wikihouse-extension/lib/
38 changes: 29 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
This is the WikiHouse plugin for use with Google SketchUp. Using it,
## Wikihouse Extension

This is the WikiHouse extension for use Google SketchUp designed for the [Wikihouse](http://www.wikihouse.cc/) open source construction set. Using it,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's Trimble SketchUp now. ;)

you can:

* Import designs from the WikiHouse library.
Expand All @@ -7,18 +9,36 @@ you can:

* Generate cutting sheets for your house designs.

**Installation**
See the [changes log](changes.md) for a list of recent changes and new features.

To install, simply download the zip file and copy over the files into
your SketchUp `plugins` directory.
**Current Version: 0.2 Dev**

**License**
##Installing

All of the code has been released into the [Public Domain]. Do with it
as you please.
###Using the Make File

1. Download or clone the repository, then run `make build` to generate the `wikihouse_extension.rbz` file.
2. Open SketchUp and navigate to **Window** > **Preferences** (Microsoft Windows) or **SketchUp** > **Preferences** (Mac OS X).
3. Click on Extensions, which will display all current extensions installed.
4. Click on the *Install Extension* button and locate the built `wikihouse_extension.rbz` file to install it.

The plugin will then appear in the list of other extensions, and all necessary files will be copied to your plugins directory. If you ever wish to disable it, simply untick it in the list and restart SketchUp.

###Manually

With the "Plugins" folder for SketchUp being by default:

--
Enjoy, tav <<tav@espians.com>>
* `C:\Program Files\Google\Google SketchUp 8\Plugins` On Windows.
* `/Library/Application Support/Google SketchUp 8/SketchUp/Plugins` On Mac.

Download or clone repository and manually move the `wikihouse_extension_loader.rb` file
as well as the `wikihouse-extension` folder plus all contents to the "Plugins" folder for SketchUp.

Installation on previous versions of SketchUp (version 7 and bellow) has to be done the manual way.

##License

All of the code has been released into the [Public Domain]. Do with it
as you please.

[Public Domain]: https://github.com/tav/wikihouse-plugin/raw/master/UNLICENSE
19 changes: 19 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
**Wikihouse Extension 0.2 Dev**

New Features:

* Wikihouse now loadable as a Sketchup Extension.
* Settings Menu added to custimise sheet dimentions.

List of Changes:

* Split the main Wikihouse.rb file into multiple files of related code located in the `wikihouse_extension/lib/` directory.
* Wrapped the whole code into a Ruby module called `WikihouseExtension`, thereby protecting against any namespace clashes in the future.
* `wikihouse_extension_loader.rb` script now contains all the configuration constants such as paths, platform, and run flags which are most likely to be changed between runs.
* All utility functions are now in the file `utils.rb` along with any other perminant constants.
* All output writer classes moved to a file called `writers.rb`.
* All WebDialoge moved to `WebDialog.rb`.
* Added a hash **$wikihouse_settings** as a global variale to store all variable configureation/settup data.
* Any code that is not currently functional is in `other.rb`.
* Added methods to convert Ruby Hash and Array classes to JSON strings and vice versa. This provides a more flexible bridge between Ruby and JavaScript in the Web Dialogues.
* Added this change log file.
57 changes: 57 additions & 0 deletions wikihouse-extension/lib/JSON.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# JSON formatter for parsing Ruby hases and Arrays to JavaScript as
# json objects.
#
# Original Author: Aerilius
# Source: http://sketchucation.com/forums/viewtopic.php?f=180&t=35969
#

module WikihouseExtension

class JSON

# Redefined JSON to a class instead of a module as this seems to through
# a load error otherwise (things run fine though).
# module_function() # Allows Methods to be callable from module

def self.from_json(json_string)
# split at every even number of unescaped quotes; if it's not a string then replace : and null
ruby_string = json_string.split(/(\"(?:.*?[^\\])*?\")/).
collect{|s|
(s[0..0] != '"')? s.gsub(/\:/, "=>").gsub(/null/, "nil") : s
}.
join()
result = eval(ruby_string)
return result
rescue Exception => e
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One shouldn't normally catch Exception - instead StandardError. http://www.skorks.com/2009/09/ruby-exceptions-and-exception-handling/

{}
end

def self.to_json(obj)
json_classes = [String, Symbol, Fixnum, Float, Length, Array, Hash, TrueClass, FalseClass, NilClass]
# remove non-JSON objects
check_value = nil
check_array = Proc.new{|o| o.reject!{|k| !check_value.call(k) } }
check_hash = Proc.new{|o| o.reject!{|k,v| !k.is_a?(String) && !k.is_a?(Symbol) || !check_value.call(v) } }
check_value = Proc.new{|v|
if v.is_a?(Array)
check_array.call(v)
elsif v.is_a?(Hash)
check_hash.call(v)
end
json_classes.include?(v.class)
}
return "null" unless check_value.call(obj)
# split at every even number of unescaped quotes; if it's not a string then turn Symbols into String and replace => and nil
json_string = obj.inspect.split(/(\"(?:.*?[^\\])*?\")/).collect{ |s|
(s[0..0] != '"')? # If we are not inside a string
s.gsub(/\:(\S+?(?=\=>|\s))/, "\"\\1\""). # Symbols to String
gsub(/=>/, ":"). # Arrow to colon
gsub(/\bnil\b/, "null") : # nil to null
s
}.join()
return json_string
end

end #JSON

end # Wikihouse Module
Loading