@kmk111890 said:
Thank you, sdmitch and TIG. I could partly understand how i have to fix the codes, but not perfect because I showed you code roughly. Maybe, it would be better i show you what i'm doing now. I'm trying to add bezier curve to draw one simple shape. The equation for the quadratic bezier curve represents as shown below
B(t) = (1-t)(1-t)P0+2(1-t)P1+(t)(t)P2
With the equation, I tried to generate coordinates which are from the equation and wanted to use 'For loop'. hmmm It looked like i can make the codes by myself, but didn't work well
This seems to work
ents = Sketchup.active_model.entities
Length = 1000
angle = (60)/2
angle2 = (45)/2
pt0 = [0,0,0]
pt1 = [Length.mm, 0, 0]
aa = 80*0.01
pt2 = pt1.transform(Geom;;Transformation.rotation(pt0,[0,-1,0],angle.degrees))
pt3 = pt1.transform(Geom;;Transformation.rotation(pt0,[0,-1,0],angle2.degrees))
pt4 = [Length.mm*aa, 0, 0]
pt5 = pt4.transform(Geom;;Transformation.rotation(pt0,[0,-1,0],angle.degrees))
arcarray = ents.add_arc [0,0,0], [1,0,0],[0,-1,0], Length.mm, 0, angle2.degrees
arc = arcarray[0]
arccurve = arc.curve
verts = arccurve.vertices
pts=[];pts<<pt0
0.step(1,0.2) do |t1|
x = (1-(t1))*(1-(t1))*pt5.x+2*(1-(t1))*(t1)*pt2.x+(t1)*(t1)*pt3.x
y = (1-(t1))*(1-(t1))*pt5.y+2*(1-(t1))*(t1)*pt2.y+(t1)*(t1)*pt3.y
z = (1-(t1))*(1-(t1))*pt5.z+2*(1-(t1))*(t1)*pt2.z+(t1)*(t1)*pt3.z
pts << Geom;;Point3d.new(x, y, z)
end
pts<<pt1
a = ents.add_line pt0, pt1
b = ents.add_line pt0, pt5
c = ents.add_curve pts
face = ents.add_face pts
path = ents.add_circle [Length,0,0], [-1,0,0], -Length
face.followme path
ents.erase_entities path
face2 = ents.add_face verts
path2 = ents.add_circle [Length,0,0], [-1,0,0], -Length
face2.followme path2
ents.erase_entities path2
group=ents.add_group ents.to_a
[image: 0MNz_kmk.gif]