-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMP-0259 README.txt
273 lines (175 loc) · 12.3 KB
/
MP-0259 README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
THIS IS THE README FOR THE MP-0259 "Mini-Project" dealing with Sketchup, Ruby Plugins and Wintab Functionality.
There are 6 folders in the MP-0259 Folder
*a breakdown of the folder contents*
MP-0259/FreehandPressureTool
-This folder contains the files:
FreehandPressureTool.rb (The main rubyscript that contains the plugin)
FreehandPressureTool.png (The large (24x24) icon for the tool)
FreehandPressureTool_small.png (The small (16x16) icon for the tool)
FreehandPressureTool_cursor.png (The cursor icon for the tool, size: 24x24)
FreehandPressureLoader.rb (The loader for the tool (see "loader explanation" for reasoning on why a loader is necessary)
FreehandPressureTool_equation.rb (an outdated version of FreehandPressureTool.rb that relies on a BUGGY equation to do calculations vs. the later implemented vector and geometry method)
-The Freehand Pressure Tool ideally should incorporate pressure sensitivity.
MP-0259/DiamondLineTool
-This folder contains the files:
DiamondLineTool.rb (The main rubyscript that contains the plugin)
DiamondLineTool.png (The large (24x24) icon for the tool)
DiamondLineTool_small.png (The small (16x16) icon for the tool)
DiamondLineToolLoader.rb (The loader for the tool (see "loader explanation" for reasoning on why a loader is necessary)
DiamondLineTool_cursor.rb (The cursor icon for the tool, size: 24x24)
-The Diamond Line Tool was a prototype method for the final project, FreehandPressureTool. The geometric sequence it uses is replicated on each OnMouseMove (in the freehandpressuretool.rb) to create the points.
It is a essentially "simplified" version of the FreehandPressureTool that just creates the diamond shape and does not store the points in a Array.
MP-0259/OsDetect
-This folder contains the files:
OsDetect.rb (A one instance rubyscript that is called when sketchup is opened. It will tell whether the OS is MAC||WINDOWS)
OsDetect_Run.rb (A evolved version of the OsDetect.rb script. This actually creates a tool, that when clicked will dictate if the OS is on MAC||WINDOWS||LINUX)
OsDetect_Run.png (The large (24x24) icon for the tool)
OsDetect_Run_small.png (The small (16x16) icon for the tool)
-The OsDetect folder contains the files made for the detection of the operating system and the eventual subsequent calls to the Wintab32.dll. In order for a final ruby plugin that incorporates WACOM driver pressure sensitivity,
this code must be used to allow for cross-OS access.
MP-0259/C Extension for Ruby
-This folder contains the files:
extconf.rb (When executed, this creates a makefile)
Extension_Run_Start.rb (This loads the extension module and file into SketchUp)
rubyextension.c (The main .c file that contains the extended methods)
ruby.h (the ruby cross-communication header file)
MSGPACK.h (Files that are necessary for PressureTest)
PCKTDEF.h ""
PRSTEST.h ""
resource.h ""
Utils.c ""
Utils.h ""
WINTAB.h ""
-The C extension for ruby would, theoretically allow for cross platform tablet communication. Unfortunately Wintab is designated for running in the .exe active window, not as a shared object.
Directions on creating the extension are listed under "C extension creation"
MP-0259/SketchUp Example Files
-This folder contains the files:
Diamond Test (shows an example of what the DiamondLineTool can accomplish)
Freehand Test (shows an example of what the FreehandPressureTool can accomplish)
Freehand Test2 (Same as prior file, but uses the Geom Module)
Multiple Parameters Test (Shows succesful Z-Axis integration and interaction with other 3d objects)
Quadratic Glitch (Shows the initial reasoning for switching to a geometric style conversion system)
Z-Axis Test (Test Z-Axis compatbility)
-These are SketchUp example files that show the integration of the plugin into SketchUp.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
______________________________________________________________________
LOADING THE PLUGINS INTO SKETCHUP
SketchUp Parameters
-All plugins were developed on the latest version of SketchUp circa July 2012. They are compatible with SketchUp 8.0 and up.
-The SketchUp interface should be set in METERS. The plugins were developed in meters and do not have multi-unit functionality (easily put in though)
-The user should have a WACOM tablet to register the "feel" of the plugins, but it is not necessary for functionality.
Operating System Parameters
-Currently the plugins run on Mac and Windows. Linux SketchUp compatibility is a risky, the user must download a windows simulator. None of the plugins have been tested on Linux.
How to load the plugins
1. Locate the plugin folder on the C drive.
-Windows: C:\Program Files (x86)\Google\Google SketchUp\Plugins\*
-Mac: Macintosh HD/Library/Application Support/Google Sketchup 8/SketchUp/Plugins/*
2. Find the folder of the plugin you wish to install.
3. Copy the contents of that folder (all of them, including icons and loaders) into the * destinations above.
4. It should look like this
C:\Program Files (x86)\Goog\Google Sket\Plugins\FreehandPressureTool.rb
\FreehandPressureLoader.rb
5. Execute SketchUp
6. To see the toolbars, go to View\Toolbars\Pressure Tools || Diamond Tools || OS Tools
- There are secondary activation methods in Draw\Freehand Pressure Tool and Draw\Diamond Line Tool and Windows\Operating System Detect
_____________________________________________________________________________
WHY A LOADER IS NECESSARY
- If a toolbar with multiple tool on it is desirable, then a loader is needed. There should be prexisting code at the bottom of each plugin .rb file that allows for loader independecy. Right now it is commmented out.
________________________________________________________________________________
SETTING UP A DEVELOPER ENVIROMENT
1. Install Ruby (1.8.6) with the one click installer (located on the MP-0259 folder or online)
2. If ruby development with visual studios is desired, then the RubyInSteel software is helpful.
-It gives colors and recognition to the ruby syntax in VS2010
http://www.sapphiresteel.com/spip?page=download (Download RubyInSteel^2 (not the all-in-one installer))
Ruby must be installed prior to this because it requires a interpreter
It is a free 60 day trial
3. Install SketchUp
4. Alter the config.h file in ruby (explained below)
5. The Google SketchUp API is extremely useful.
__________________________________________________________________________________
HOW TO CREATE THE MAKEFILE AND EXTENSION
1. Download the Ruby one-click installer. It needs to be 1.8.6. (There should be a .exe included in the MP-0259 folder)
2. Once the installation is complete, open up the config.h file in the Ruby folder off the C drive
C:\Ruby\lib\ruby\1.8\i386-mswin32\*
Find the config.h file in this folder and then comment out these lines. (They should be at the top)
//#if _MSC
//_VER != 1200
//#error MSC version unmatch
//#endiine USE_WINSOCK2 1
3. Now that ruby is configured, open up the visual studio command prompt. The .c source file (and subsequent header files) must be in the same folder with the
extconf.rb ruby file.
4. Navigate to the folder with the "cd" key (C:\MP-0259\C Extension for Ruby\*)
5. Type "ruby extconf.rb" in place of the asterisk placed above
6. The command prompt should return "creating makefile"
7. Then type "nmake" and return
8. It creates the necessary libraries and .obj files for the conversion
9. Copy all the .obj, .lib, .so (and the makefile) files to the SketchUp Plugins folder
10. Copy Extension_Run_Start.rb to the plugin folder also to load the module and connect the extension with SketchUp
*quick overview of the theory of Extension_Run_Start*
require 'sketchup.rb'
require 'rubyextension'----------> This requires the .so makefile
include Pressure-------------->This loads the module and the subsequent methods
___
if RUBY_PLATFORM =~ /mswin32/ |
print ("Running on Windows OS") |
#UI.messagebox ("Running on Windows") |
end |
if (RUBY_PLATFORM =~ /darwin/) |] This is copied from the OsDetect_Run.rb file.
print ("Running on Mac OS.") |]]- It detects the OS and then (could) send a message displaying it.
#UI.messagebox ("Running on Mac OS.") |] In the future it would be needed to load what type of extension (MAC||WINDOWS)
end |
if (RUBY_PLATFORM =~ /linux/) |
print ("Running on Linux. No Compatibility") |
#UI.messagebox ("Running on Linux. No Compatibility") |
end ___|
11. Activate SketchUp
12. Go to windows/ruby console
13. type in pressureshow (or whatever keywords you have declared in the .c file for the ruby methods)
VALUE Pressure = Qnil; ---->Module definition
void Init_rubyextension(); ----->Init definition
VALUE method_pressure(VALUE self); ----->method definition
void Init_rubyextension() {
Pressure = rb_define_module("Pressure"); ---->connecting the module to ruby
rb_define_method(Pressure, "pressureshow", method_pressure, 0); ---->connecting the method to ruby
14. It will execute the method and return a VALUE (ruby can only return values)
*CODE NEEDED FOR THE .C EXTENSION FROM RUBY
-the file ruby.h must be included in the same directory and the project (#include "ruby.h")
-once the ruby.h file is included however, there will be build errors because the syntax is consistent with ruby and C, so VS2010 draws errors
-an example of a basic extension is shown below
-keep in mind that extconf.rb looks for Init_'word'
in this case it looks for rubyextension. There have also been glitches if it needs to look for a uppercase Init_''
#include "ruby.h"
#include <windows.h>
#include <math.h>
#include <string.h>
#include <stdio.h>
VALUE Pressure = Qnil;
void Init_rubyextension();
VALUE method_pressure(VALUE self);
VALUE method_pressure2(VALUE self);
void Init_rubyextension()
{
Pressure = rb_define_module("Pressure");
rb_define_method(Pressure, "pressureshow", method_pressure, 0);
rb_define_method(Pressure, "pressureshow2", method_pressure2, 0);
}
VALUE method_pressure(VALUE self)
{
int x = 10;
return INT2NUM(x);
}
VALUE method_pressure2(VALUE self)
{
int y = 15;
return INT2NUM(y);
}
If this was loaded into SketchUp and the in the ruby console, the user typed "pressureshow" it should return 10. If pressureshow2 is typed, 15 should be returned.
As of now, the extension in the 'C Extension for Ruby' folder has 3 methods and when typed in order return false, false and then a garbage number
15. SIDENOTE: Any ruby plugin can also call the functions without needing the loading code on each header. For example, a seperate ruby plugin could be made that
shows a messagebox when clicked.
def activate
UI.messagebox (*)
16. If we put 'pressureshow' it will return that value. This is key to allowing ruby to pull the pressure data.
______________________________________________________________________________________________________________________________________