몇일전 스크립트 작업을 하던중 RhinoScript에 reparametrize 기능이 없어 Rhino.command를 이용했었는데, 아무래도 function을 만들어 두면 많이 사용 될것 같아서. . .
아래 function은 입력된 커브나 서피스를 0-1 로 reparameterize 하게된다.
Function ReparameterizeCurve(strObject)
Dim intDegree, arrKnots, arrNKnots(),arrPoints, arrWeights, arrDomain,k
intDegree = Rhino.CurveDegree(strObject)
arrKnots = Rhino.CurveKnots(strObject)
arrPoints = Rhino.CurvePoints(strObject)
arrWeights = Rhino.CurveWeights(strObject)
arrDomain = Rhino.CurveDomain(strObject)
k=Ubound(arrKnots)
ReDim arrNKnots(k)
For i=0 To k
arrNKnots(i)= (arrKnots(i)-arrDomain(0))/(arrDomain(1)-arrDomain(0))
Next
ReparameterizeCurve = Rhino.AddNurbsCurve (arrPoints, arrNKnots, intDegree , arrWeights)
End Function
Function ReparameterizeSrf (strObject)
Dim arrDegree, arrKnots, arrNKnotsV(),arrNKnotsU(),arrPoints, arrWeights, arrDomainU,arrDomainV, k, arrPointCount,L
arrPointCount = Rhino.SurfacePointCount(strObject)
arrDegree = Rhino.surfaceDegree(strObject)
arrKnots = Rhino.SurfaceKnots(strObject)
arrPoints = Rhino.SurfacePoints(strObject)
arrWeights = Rhino.SurfaceWeights(strObject)
arrDomainU = Rhino.SurfaceDomain(strObject,0)
arrDomainV = Rhino.SurfaceDomain(strObject,1)
k=Ubound(arrKnots(0))
L=Ubound(arrKnots(1))
ReDim arrNKnotsU(k)
For i=0 To k
arrNKnotsU(i)= (arrKnots(0)(i)-arrDomainU(0))/(arrDomainU(1)-arrDomainU(0))
Next
ReDim arrNKnotsV(L)
For i=0 To L
arrNKnotsV(i)= (arrKnots(1)(i)-arrDomainV(0))/(arrDomainV(1)-arrDomainV(0))
Next
ReparameterizeSrf = Rhino.AddNurbsSurface (arrPointCount, arrPoints, arrNKnotsU, arrNKnotsV, arrDegree , arrWeights)
End Function
No comments:
Post a Comment