-
Notifications
You must be signed in to change notification settings - Fork 338
/
Copy pathStraightenCircles.rvb
47 lines (36 loc) · 1.3 KB
/
StraightenCircles.rvb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' StraightenCircles.rvb -- September 2008
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 4.0.
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' StraightenCircles
' Creates lines based on the circumferences of circles.
' Lines will be oriented based on the plane of the circle.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub StraightenCircles
Dim obj_list, obj
Dim length, plane, origin, xaxis
Dim endpt, line
obj_list = Rhino.GetObjects("Select circles to straighten", 4, True, True)
If IsArray(obj_list) Then
Call Rhino.EnableRedraw(False)
For Each obj In obj_list
If Rhino.IsCircle(obj) Then
' Gather data
length = Rhino.CurveLength(obj)
plane = Rhino.CurvePlane(obj)
origin = plane(0)
xaxis = plane(1)
' Calculate
xaxis = Rhino.VectorUnitize(xaxis)
xaxis = Rhino.VectorScale(xaxis, length)
endpt = Rhino.PointAdd(origin, xaxis)
line = Rhino.AddLine(origin, endpt)
Call Rhino.SelectObject(line)
End If
Next
Call Rhino.EnableRedraw(True)
End If
End Sub