I am practicing a ruby file from Automatic Sketchup book with the following code, creation of component definition and saving.
# Create the component definition list = Sketchup.active_model.definitions comp_def = list.add "Cube" comp_def.description = "This is a simple cube-shaped component." # Add entities to the component definition ents = comp_def.entities face = ents.add_face [0,0,0], [1,0,0], [1,1,0], [0,1,0] face.reverse! face.pushpull 1 # Save the component definition save_path = Sketchup.find_support_file "Components", "" comp_def.save_as(save_path + "/cube.skp") puts "The definition was saved to: " + comp_def.path
help_file = Sketchup.find_support_file("help.html", "Plugins/") ,
Where the syntax for the find_support_file method -> folder name and an empty string & from the Ruby api, the filename followed by the folder name.
Which one is correct to follow.?
Also when try to follow the API, the following error i am getting for the code, which i try to execute.
mod = Sketchup.active_model # Open model ent = mod.entities # All entities in model sel = mod.selection # Current selection #declaration of variables height = 720.mm #Height of the cabinet depth = 550.mm #depth of the cabinet wd = 600.mm #width of the cabinet thickness =18.mm #thickness of the panel bpt= 8.mm #thickness of the back panel tpw = 100.mm # top panel width bpo = 8.mm # back panel offset bppo = 20.mm # back panel position offset sc = 2.mm # shelf clearance so = 20.mm # Shelf offset shch = 2.5.mm # Shutter Clearance height shcv = 1.mm #Shutter clearance width lht = 100.mm # leg height. #Create the component definition list = Sketchup.active_model.definitions comp_def = list.add "LH Panel" comp_def.description = "this the left hand side panel" pt = [0,1,2,3] # referencing early point for drawing. relative coordiante ssytem pt = Geom::Point3d.new(0,0,0) pt = pt + [thickness,0,0] pt = pt + [0,depth,0] pt = pt + [-thickness,0,0] #creation of face - LH Side panel #Add enitities to the component definition ents = comp_def.entities face = ents.add_face(pt) face.reverse! face.pushpull(height, true) #save the component definish save_path = Sketchup.find_support_file ("/LH.skp", "Components") comp_def.save_as(save_path)
where i am making the mistake or i am understanding wrongly.?