--- 曲線.rvb cut here --- '実行後 Ctrl+V で点群をペースト On error resume next 'Option Explicit Dim PI: PI = 3.1415926536 Dim xLen, ySize, Times, flg, i, j, a, s Dim arrPt,strPt,obj:strPt="" Dim x, y, xDelta, divAngle, divNum Dim arr1,arr2,int arr1=array("サインカーブ","コサインカーブ",_ "サイクロイド","インボリュート",_ "カージオイド(心臓形)","三葉線",_ "","キャンセル") arr2=array(0,0,0,0,0,0,0,0) int = Rhino.PopupMenu(arr1,arr2) If int=0 then 'サインカーブ Rhino.Command "_-Runscript (SinCurve 1)" ElseIf int=1 then 'コサインカーブ Rhino.Command "_-Runscript (SinCurve 2)" ElseIf int=2 then 'サイクロイド Rhino.Command "_-Runscript (Cyclo 1)" ElseIf int=3 then 'インボリュート Rhino.Command "_-Runscript (Cyclo 2)" ElseIf int=4 then 'カージオイド Rhino.Command "_-Runscript (Sanyo 0)" ElseIf int=5 then '3葉線 Rhino.Command "_-Runscript (Sanyo 1)" End If Sub SinCurve (flg) 'パラメータの取得 xLen = Rhino.GetReal("X長さ入力(Min=1)",5,1) ySize = Rhino.GetReal("Yサイズ入力(Min=1)",5,1) divAngle = Rhino.GetReal("分割角度(Min=0.1 Max=10)",_ 5,0.1,10) Times = Rhino.GetInteger("繰り返し回数(Max=10)",_ 5,1,10) divNum = CInt(360/divAngle) xDelta = xLen / divNum '曲線データを作成する For i = 0 To Times - 1 For j = 0 To divNum s = (j * divAngle) * PI / 180 x = i * xLen + xDelta * j If flg=1 then y = ySize * Sin(s) ElseIf flg=2 then y= ySize * Cos(s) End If strPt=strPt & x & "," & y & " " Next Next End Sub Sub Cyclo (flg) a = Rhino.GetReal("サイズ入力(Min=1)",5,1) divAngle = Rhino.GetReal("分割角度(Min=0.1 Max=10)",_ 0.5,0.1,10) divNum = CInt(360/divAngle) '曲線データを作成する For i = 0 To divNum s=(i * divAngle) * PI / 180 If flg=1 then x =a*(s-sin(s)) y =a*(1-cos(s)) ElseIf flg=2 then x=a*(cos(s)+s*sin(s)) y=a*(sin(s)-s*cos(s)) End If strPt=strPt & x & "," & y & " " Next End Sub Sub Sanyo (flg) If flg=0 then n=0 Else n = Rhino.GetInteger("パラメータ入力"&_ "(2:4葉線,3:3葉線)",3) End If a = Rhino.GetReal("サイズ入力(Min=1)",5,1) divAngle = Rhino.GetReal("分割角度(Min=0.1 Max=10)",_ 0.5,0.1,10) divNum = CInt(360/divAngle) '曲線データを作成する For i = 0 To divNum s=(i * divAngle) * PI / 180 If n=0 then r=a*(1+cos(s)) Else r = a*Sin(n*s) End If x = r*Cos(s) y = r*Sin(s) strPt=strPt & x & "," & y & " " Next End Sub If int<>-1 and int<>6 Then '曲線を作成 arrPt=Rhino.Str2PtArray(strPt) If IsArray(arrPt) Then obj=Rhino.addPoints (arrPt) Rhino.SelectObjects obj Rhino.Command "ZoomSelected _PointCloud" Rhino.SelectObjects Rhino.LastCreatedObjects Rhino.Command "Cut" Rhino.AddCurve(arrPt) Else Rhino.MessageBox "あれっ?",32 End If End If --- 曲線.rvb cut here --- |