Hmm,
I'm not sure I do that? Here is a cut-down version of what I'm doing. Hopefully I'm not breaking too many good practice rules, but please let me know.
Basically I have a lot of class variables (all the @@xyz) which have defaults, but get overridden after the HTML configure() has been ran. When configure() is complete is calls draw() then statistics() to implement the customized design in SketchUp. I use blocking threads to initialize these so that the configure has been finished().
All of my shapes from draw() get pushed into @@geodesic which is a group so that all sub-shapes from the draw are bound together at the end.
Insight appreciated...
# Add a menu item to launch our plug-in.
UI.menu("PlugIns").add_item("Draw Geodesic") {
#Instantiate and configure the Geodesic
geo = Geodesic.new
geo.configure()
}
class Geodesic
#Main Configuration items
@@g_frequency = 3
@@g_radius = 150
@@g_platonic_solid = 20
@@g_fraction = 0.6
@@g_center = Geom;;Point3d.new ([0, 0, -@@g_radius + 2 * @@g_radius * @@g_fraction])
@@draw_primitive_solid_faces = 0
@@primitive_face_material = [rand(255), rand(255), rand(255)]
@@draw_tesselated_faces = 0
@@tesselated_face_material = [rand(255), rand(255), rand(255)]
#Metal hub configuration
@@draw_metal_hubs = 1
@@metal_hub_outer_radius = 2.25
@@metal_hub_outer_thickness = 0.25
@@metal_hub_depth_depth = 4
#Wood strut configuration
@@draw_wood_struts = 1
@@wood_strut_dist_from_hub = 3
@@wood_strut_thickness = 1.5
@@wood_strut_depth = 3.5
@@wood_strut_material = Sketchup;;Color.new(255,215,0)
#Wood frame configuration
@@draw_wood_frame = 1
@@frame_separation = 12
#Dome reference data is stored in these arrays
@@geodesic = Sketchup.active_model.entities.add_group #Main object everything contributes to
@@primitive_points = []
@@strut_points = []
@@triangle_points = []
#Dome shape data is stored in these arrays
@@strut_hubs = []
@@struts = []
@@frame_struts = []
#tolerance factor to circumvent small number errors
@@g_tolerance = 0.5
#HTML pop-up menu to configure and create the Geodesic Dome
def configure
# ... code ...
end
def draw
# ... code ...
end
def statistics
# ... code ...
end
private
#lots of support functions here
SIncerely, Paul.