R&D Data/Code · 2025. 9. 7.

종이모형 삼각형 플랩 생성 라이노 스크립트

!-_RunScript (
Option Explicit

Call Main()
Sub Main()
	Dim Line, Length, Height, Operator, Operator02, LengthCurves, Auxiliary01, Auxiliary02
	Dim Point01, Point02, Point03, Point04, Point05
	Dim Distance, Shoulder, Angle01, Angle02, Angle00
	
	
	Do
		Line = Rhino.GetObject("Choose a curve:")
		If Not isNull(Line) Then
			LengthCurves = Rhino.CurveLength(Line)
			Length = Rhino.GetReal("Length:", 5)
			Height = Rhino.GetReal("Height:", 4)
			Point05 = Rhino.GetPoint("Select Direction:")
			Auxiliary01 = LengthCurves \ Length
			Auxiliary02 = LengthCurves Mod Length
	
			If Auxiliary02 < 0.5 Then
				Length = LengthCurves / Auxiliary01
			Else
				Length = LengthCurves / (Auxiliary01 + 1)
			End If
			Operator = 0
			
			Point01 = Rhino.CurveArcLengthPoint(Line, Length * Operator)
			Point02 = Rhino.CurveArcLengthPoint(Line, Length * (Operator + 1))
			
			Angle00 = Rhino.ATan2(Point05(1)-Point01(1),Point05(0)-Point01(0))
			Angle01 = Rhino.ATan2(Point02(1)-Point01(1),Point02(0)-Point01(0))
			If Angle00 > Angle01 Then
				Operator02 = 0
			Else
				Operator02 = 1
			End If
				
	
			Do
				Point01 = Rhino.CurveArcLengthPoint(Line, Length * Operator)
				Point02 = Rhino.CurveArcLengthPoint(Line, Length * (Operator + 1))
				Distance = Rhino.Distance(Point01, Point02)
				Angle01 = Rhino.ATan2(Point02(1)-Point01(1),Point02(0)-Point01(0))
				Point03 = Array (((Distance / 2) * Cos(Angle01)) + Point01(0), ((Distance / 2) * Sin(Angle01)) + Point01(1), 0)
	
				Angle02 = Rhino.ATan2(Height, Distance / 2)
				Shoulder = (Distance / 2) * (Distance / 2) + Height * Height
				Shoulder = Shoulder ^ 0.5
				Angle00 = Rhino.ATan2(Point05(1)-Point01(1),Point05(0)-Point01(0))
	
				If Operator02 = 0 Then
					Point04 = Array ((Shoulder * Cos(Angle01 + Angle02)) + Point01(0), (Shoulder * Sin(Angle01 + Angle02)) + Point01(1), 0)
				Else
					Point04 = Array ((Shoulder * Cos(Angle01 - Angle02)) + Point01(0), (Shoulder * Sin(Angle01 - Angle02)) + Point01(1), 0)
				End If
				
				Rhino.AddLine Point01, Point04
				Rhino.AddLine Point02, Point04
				Operator = Operator + 1
				
				Loop Until ((Operator + 1) * Length) > LengthCurves
		Else
			Rhino.Print"Finished to users"
		End If
	Loop Until isNull (Line)

	Rhino.Command "SelNone"
	Rhino.Command "SelLast"
	Rhino.Command "Join"
	Rhino.Command "-ChangeLayer pause Fold_Lines::Flap_Lines pause"
	Rhino.Command "SelNone"

End Sub
)