Hi,
Another question. Is it possible to add an part created in ruby to an component ?
I did a ruby script that create this part, but I wonder if this can be included in a DC component ?
I see that I can call a ruby script from the DC, but I have not been able to add this part to the DC itself. I can only create the part and add it to the model and not to the the selected component.
I'm new to ruby too so it's a little bit complicated.
Here what I did to create the part from the ruby script.
require 'sketchup.rb'
class DCFunctionsV1
protected
def createside(param_array)
mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
lheight = param_array[0]
llength = param_array[1]
ltoeheigth = param_array[2]
ltoelength = param_array[3]
lwidth = param_array[4]
printf("heigth = %d\n", lheight)
printf("length = %d\n", llength)
printf("toe heigth = %d\n", ltoeheigth)
printf("toe length = %d\n", ltoelength)
printf("width = %f\n", lwidth)
# Create a series of "points", each a 3-item array containing x, y, and z.
pt = []
pt[0] = [0, 0, 0]
pt[1] = [0, 0, lheight.to_f]
pt[2] = [llength.to_f, 0, lheight.to_f]
pt[3] = [llength.to_f, 0, ltoeheigth.to_f]
pt[4] = [llength.to_f - ltoelength.to_f, 0, ltoeheigth.to_f]
pt[5] = [llength.to_f - ltoelength.to_f, 0, 0]
new_comp_def = mod.definitions.add("BCSide") ;
# Call methods on the Entities collection to draw stuff.
new_face = new_comp_def.entities.add_face(pt) ; # returns a Face
new_face.reverse! if new_face.normal.z < 0 ; # flip face to up if facing down
new_face.pushpull(lwidth.to_f)
trans = Geom;;Transformation.new
mod.active_entities.add_instance(new_comp_def, trans) ;
#UI.messagebox("heigth = " + lheight.to_s)
return "ok"
end
end