!-_RunScript (
Option Explicit
Call Main()
Sub Main()
Dim Point01, Point02, Point03, Point04, Point05, AuxiliaryPoint, Center
Dim Angle01, Angle02, Angle03, Angle04
Dim Width, Hypotenuse
Dim Operator
Dim newFlapLayer : newFlapLayer = "Fold_Lines::Flap_Lines"
Dim flapObj, arrFlapObj(3)
Dim lineCnt : lineCnt = 0
Width = Rhino.GetReal("Height:",3)
Angle02 = Rhino.GetReal("Angle:", 45, 1, 90)
Angle02 = Angle02 * (Rhino.Pi/ 180)
Operator = 0
Center = Array (0, 0, 0)
Do
Point01 = Rhino.GetPoint("Select the first Point:")
If Not isNull(Point01) Then
Point02 = Rhino.GetPoint("Select second Point:")
If Not isNull(Point02) Then
If Rhino.Distance(Center, Point01) > Rhino.Distance(Center, Point02) Then
AuxiliaryPoint = Array (Point01(0), Point01(1), Point01(2))
Point01 = Array (Point02(0), Point02(1), Point02(2))
Point02 = Array(AuxiliaryPoint(0), AuxiliaryPoint(1), AuxiliaryPoint(2))
End If
Point05 = Rhino.GetPoint("Select Direction:")
Angle01 = Rhino.ATan2(Point02(1) - Point01(1), Point02(0) - Point01(0))
Angle04 = Rhino.ATan2(Point05(1) - Point01(1), Point05(0) - Point01(0))
If Angle01 < 0 Then
Angle01 = 2*Rhino.Pi + Angle01
End If
If Angle04 < 0 Then
Angle04 = 2*Rhino.Pi + Angle04
End If
Hypotenuse = Width / Sin(Angle02)
Rhino.Print Angle01
Rhino.Print Angle04
If Angle04 > Angle01 Then
Angle03 = Rhino.Pi + (Angle01 - Angle02)
Point03 = Array ((Cos(Angle02 + Angle01) * Hypotenuse) + Point01(0), (Sin(Angle02 + Angle01) * Hypotenuse) + Point01(1), 0)
Point04 = Array (Point02(0) + (Cos(Angle03) * Hypotenuse),Point02(1) + (Sin(Angle03) * Hypotenuse), 0)
Else
Angle03 = Rhino.Pi + (Angle01 + Angle02)
Point03 = Array ((Cos(Angle01 - Angle02) * Hypotenuse) + Point01(0), (Sin(Angle01 - Angle02) * Hypotenuse) + Point01(1), 0)
Point04 = Array (Point02(0) + (Cos(Angle03) * Hypotenuse),Point02(1) + (Sin(Angle03) * Hypotenuse), 0)
End If
'생성되는 선들에 이름을 부여 해준다.
Rhino.ObjectName Rhino.AddLine(Point01, Point03), "newFlapline"
Rhino.ObjectName Rhino.AddLine(Point02, Point04), "newFlapline"
Rhino.ObjectName Rhino.AddLine(Point03, Point04), "newFlapline"
Else
Operator = 1
End If
Else
Operator = 1
End If
Loop Until Operator = 1
Rhino.Print "Finished users"
'특정 이름이 부여된 오브젝트들을 flapObj에 담는다.
flapObj = Rhino.ObjectsByName("newFlapline")
'flap이 들어갈 레이어 생성
Rhino.AddLayer("Fold_Lines::Flap_Lines")
'flapObj을 생성된 레이어에 옮겨준다.
Rhino.ObjectLayer flapObj, "Fold_Lines::Flap_Lines"
'flapObj를 선택하고 Join!
Rhino.SelectObjects flapObj
Rhino.Command "Join"
Rhino.Command "SelNone"
End Sub
)
스크립트2
!-_RunScript (
Option Explicit
Call Main()
Sub Main()
Dim arrPoint01, arrPoint02, arrPoint03, arrPoint04
Dim arrPointSide
Dim arrAngle01, arrAngle02, Angle03, Angle04
Dim arrAngleLine01, arrAngleLine02
Dim intWidth, intAngle, intSideLineWidth
Dim arrLineObjects(2)
Dim Operator, strProof
Operator = 0
intWidth = Rhino.GetReal("Height of tab (min 0.1)", 3, 0.1) 'vypytam si sirku chlopne
If Not isNull(intWidth) Then
intAngle = Rhino.GetReal("Angle of side of tab (max 90°, min 1°)", 45, 1, 90) 'vypytam si uhol bocnej ciary chlopne
If Not isNull(intAngle) Then
'intAngle = intAngle * (Rhino.Pi / 180) 'prepocitam uhol chlopne na radiany
intSideLineWidth = intWidth / Sin(intAngle * (Rhino.Pi / 180)) 'vypocitam dlzku bocnej ciary
'MsgBox "Width of side line of tab:" & intSideLineWidth
Do
arrPoint01 = Rhino.GetPoint("Choose first point") 'vypytam si prvy bod
If Not isNull(arrPoint01) Then
arrPoint02 = Rhino.GetPoint("Choose second point") 'vypytam si druhy bod
If Not isNull(arrPoint02) Then
arrPointSide = Rhino.GetPoint("Choose side") 'vypytam si stranu na ktorej sa ma nakreslit chlopna
If Not isNull(arrPointSide) Then
'vypocitam si uhol ktory zviera usecka-hlavna s vodorovnou osou, hodnoty od -180 do 180
arrAngle01 = Rhino.Angle(arrPoint01, arrPoint02)
If arrAngle01(0) < 0 Then
arrAngle01(0) = 360 + arrAngle01(0) 'prevediem uhol na 360
End If
'vypocitam si uhol, ktory zviera usecka-strana s vodorovnou osou, hodnoty od -180 do 180
arrAngle02 = Rhino.Angle(arrPoint01, arrPointSide)
If arrAngle02(0) < 0 Then
arrAngle02(0) = 360 + arrAngle02(0) 'prevediem uhol na 360
End If
'pokial je rozdiel uhlov mimo rozsahu 0-180, tak odpocitam uhol chlopne
If ((arrAngle02(0) - arrAngle01(0)) < 0) Or ((arrAngle02(0) - arrAngle01(0)) > 180) Then
Angle03 = arrAngle01(0) - intAngle
Angle04 = arrAngle01(0) - 90 - (90 - intAngle) 'vypocitam uhol pre opacnu stranu chlopne
Else
Angle03 = arrAngle01(0) + intAngle 'ak je v rozsahu 0-180 tak pripocitam uhol chlopne
Angle04 = arrAngle01(0) + 90 + (90 - intAngle) 'vypocitam uhol pre opacnu stranu chlopne
End If
Angle03 = Angle03 * (Rhino.Pi / 180) 'prevediem uhol na radiany
arrPoint03 = Array((Cos(Angle03) * intSideLineWidth) + arrPoint01(0), (Sin(Angle03) * intSideLineWidth) + arrPoint01(1), 0) 'vypocitam bod 03
Angle04 = Angle04 * (Rhino.Pi / 180) 'prevediem uhol na radiany
arrPoint04 = Array((Cos(Angle04) * intSideLineWidth) + arrPoint02(0), (Sin(Angle04) * intSideLineWidth) + arrPoint02(1), 0) 'vypocitam bod 04
arrLineObjects(0) = Rhino.AddLine(arrPoint01, arrPoint03) 'vytvorim prvu ciaru chlopne
arrLineObjects(1) = Rhino.AddLine(arrPoint02, arrPoint04) 'vytvorim druhu ciaru chlopne
arrLineObjects(2) = Rhino.AddLine(arrPoint03, arrPoint04) 'vytvorim poslednu hlavnu ciaru chlopne
Rhino.ObjectLayer arrLineObjects, "Fold_Lines::Flap_Lines"
Rhino.JoinCurves arrLineObjects, True 'zlucim do jednej polyline vytvorene ciary, vymazem povodne
Else
Operator = 1
End If
Else
Operator = 1
End If
Else
Operator = 1
End If
Loop Until Operator = 1
End If
End if
Rhino.Print "Terminated by user!"
Rhino.Command "-SelLayer Fold_Lines::Flap_Lines"
Rhino.Command "Join"
Rhino.Command "SelNone"
End Sub
)