Dear Friends,
Would you please let me know how can I make a poly line (path) from series of points in a loop (for)?
Thank you in advance
Dear Friends,
Would you please let me know how can I make a poly line (path) from series of points in a loop (for)?
Thank you in advance
The PolyLine objects are not yet exposed to the Ruby API.
Do you want a set of connect edges ?
If you need to use a for
loop for calculating the point positions, then push the points into an array as you calculate them. Then afterward call the #add_curve()
method as shown below.
pts = [ ORIGIN ] # A new array with the model origin as the 1st point
for i in 0..10
x = i + 2
y = x / 2
pts << Geom::Point3d.new( x, y, 0 )
end
Once you have an array with points in it, you can just feed the array to the #add_curve()
method.
model = Sketchup.active_model
ents = model.active_entities
ents.add_curve(pts)
dezmo is correct it’s the #add_curve
method (not #add_edges
.)
for j in 0…@st - 1
path = $ent.add_line @pt[j], @pt[j + 1]
end
This loop works but make separate lines and cannot use for path. How can I make one path with these series of 3d points?
As Dan and me posted above in an example and link:
Assuming @pt
is already an array of Point3D’s
path = $ent.add_curve(@pt)
Thank you so much for your help…
You are great!! Thank you so much for your help… following command solve my problem… path = $ent.add_curve @pt[0…@st]. Fortunately no need any loop.
Please do not use global variables.