My problem is I use code in onLButtonDown and the circle appears in Undo. Is there any way I got circle vertices without drawing it?
Your help will be highly appreciated.
FYI: You don’t need to use a block iterator to get an array of points.
You can get the virtual curve object from the first edge, then get the array
of it’s vertices and map them to position points:
Note: Although you have 16 segments for the circle, the default is 24.
The last time through the loop results in a final point being calculated that is never used. It should rotate the point at or near the initial starting point, which is already in the first array element. Instead of setting the points based on a radius, I set it to unity, and the radius can be used as a scale factor.
Notice use of the “map!” method instead of “each”.
For myself, SIN and COS are more error prone. You said:
I agree. You asked:
I don’t have access to the Sketchup code, but I would think that SIN and COS would be limited to the “.rotation” constructor. After that, it should be matrix multiplication.
Yes, I wasn’t actually trying to create a circle entity. In which case, you could do a final assignment after the for loop:
pts << pts.first.clone
You also asked:
(Referring to use of the map! method). Just to make sure others who read this someday will know I accomplished the same thing in a slightly different manner. Ruby allows the same thing to be accomplished in different ways. If the code isn’t clearer to you when using map, then each may be better for yourself.