Sub TestInterTwine ' calls: akCurveBlend.rvb::RebuildCurve ' ------------------------------------------------------------------- intFree = 5 arrCurves = Rhino.GetObjects("select curves:",4) intCrvCnt = UBound (arrCurves) Dim arrAxes () ' Dim arrWeight () ' ------------------------------------------------------------------- ' method alternatives: ' GET RESPECTIVE POINTS - METHOD1: rebuild to max ' GET RESPECTIVE POINTS - METHOD2: rebuild to minCommonMultiplier ' GET RESPECTIVE POINTS - METHOD3: pair nearest CVs ' GET RESPECTIVE POINTS - METHOD5: ClosestCurvePoint ' GET RESPECTIVE POINTS - METHOD6: equal CVCount ' GET RESPECTIVE POINTS - METHOD4: do until CVCountMin ' ------------------------------------------------------------------- ' GET RESPECTIVE POINTS - METHOD1: rebuild to max intPntCnt = -1 For intI = 0 To intCrvCnt intPntCntTmp = Rhino.CurvePointCount(arrCurves(intI)) If intPntCnt < intPntCntTmp Then intPntCnt = intPntCntTmp End If Next For intI = 0 To intCrvCnt intPntCntTmp = Rhino.CurvePointCount(arrCurves(intI)) If intPntCnt <> intPntCntTmp Then arrCurves(intI) = RebuildCurve(arrCurves(intI), intPntCnt-1) End If ' If intPntCnt <> intPntCntTmp Then arrCurves(intI) = RebuildCurve(arrCurves(intI), intPntCnt) End If Next intPntCnt = intPntCnt - 1 Rhino.Print "TestInterTwine - intPntCnt:"&CStr(intPntCnt)&" intCrvCnt: "&CStr(intCrvCnt) For intI= 0 To intPntCnt For intJ = 0 To intCrvCnt Rhino.Print "TestInterTwine - aktCurve#: "&CStr(intJ)&" aktPunkt#: "&CStr(intI)&" curveObj: "&CStr(arrCurves(intJ)) arrCVs = Rhino.CurvePoints(arrCurves(intJ)) Rhino.Print "TestInterTwine - aktCurve#: "&CStr(intJ)&" aktPunkt#: "&CStr(intI)&" aktPunkt: "&Rhino.Pt2Str(arrCVs(intI)) Next Next ' GET ANGLE ARRAY arrAngles = Rhino.CurvePoints (arrCurves(0)) For intI = 0 To UBound(arrAngles)'intPntCnt arrAngles(intI) = 9*(intI+1) Next arrAngles(0) = 0 arrAngles(UBound(arrAngles)) = 0 ' GET WEIGHT ARRAY arrWeight = arrCurves For intI = 0 To UBound(arrWeight) arrWeight(intI) = 1 ' arrWeight(intI) = 9*(intI+1) ' arrWeight(intI) = 9/(intI+1) Next ' ' GET ROTAXIS ARRAY ReDim arrAxes (intPntCnt) Rhino.Print "TestInterTwine - UBound(arrAnglesV): "&CStr(UBound(arrAngles))&" (UBound(arrWeight(intL)): "&CStr(UBound(arrWeight)) arrSecTAN = arrCurves arrSecCVs = arrCurves For intI = 0 To intPntCnt arrCrvCVs = Rhino.CurvePoints (arrCurves(0)) arrTemp = arrCrvCVs(0) dblParam = Rhino.CurveClosestPoint(arrCurves(0),arrTemp) arrData = Rhino.CurveCurvature(arrCurves(0), dblParam) arrTemp = arrData(1) arrSecTAN(0) = arrTemp For intJ = 0 To intCrvCnt arrCrvCVs = Rhino.CurvePoints (arrCurves(intJ)) arrTemp = arrCrvCVs(intI) dblParam = Rhino.CurveClosestPoint(arrCurves(0), arrTemp) arrData = Rhino.CurveCurvature(arrCurves(intJ), dblParam) arrSecCVs(intJ) = arrCrvCVs(intI) arrSecTAN(intJ) = arrData(1) ' arrSecTAN(intJ) = VectorOrient (arrSecTAN(0),arrSecTAN(intJ)) Next arrCent = WeightedCenter(arrSecCVs,arrWeight) arrTang = WeightedCenter(arrSecTAN,arrWeight) arrAxes(intI) = Array(arrCent,Rhino.VectorAdd(arrCent,arrTang)) Next ' DEVIATE CURVE1 AROUND POINT0 Rhino.unselectAllObjects intOff = 20 For intZZ = 0 To 15 For intI = 0 To intCrvCnt Rhino.Print "TestInterTwine - No.Axes:"&CStr(UBound(arrAxes))&" No.Angles: "&CStr(UBound(arrAngles))&" curveObj: "&CStr(arrCurves(intI)) ' For intJ = 0 To UBound(arrAxes) ' arrAxisTmp = arrAxes(intJ) ' Rhino.Print "TestInterTwine - Axis:"&Rhino.Pt2Str(arrAxisTmp(0))&"::"&Rhino.Pt2Str(arrAxisTmp(1))&" Angle: "&CStr(arrAngles(intJ)) ' Next arrAnglesW = arrAngles Rhino.Print "TestInterTwine - UBound(arrAnglesW): "&CStr(UBound(arrAngles))&" (UBound(arrWeight(intL)): "&CStr(UBound(arrWeight)) For intL = 0 To UBound(arrAnglesW) arrAnglesW(intL) = arrAngles(intL) * arrWeight(intI) Next strObject = DeviateCrvAng (arrAxes, arrAnglesW,arrCurves(intI)) Rhino.SelectObject strObject arrCurves(intI) = strObject Next Rhino.Command "-copy 0,0,0 0,"&CStr(intOff)&",0 enter " intOff = intOff + 20 Rhino.unselectAllObjects Next End Sub '===================================================================================RebuildCurve Function RebuildCurve (strObject, intSectionsSub) ' rebuilds an existing curve, creates a new curve, ' returns handle of new curve intSections = intSectionsSub + 1 Rhino.UnselectAllObjects Rhino.SelectObject strObject Rhino.Command "'-Rebuild E=no P=" & intSections &" enter" &" " strObjectNew = Rhino.LastObject Rhino.UnselectAllObjects ' Rhino.SelectObject strObjectNew RebuildCurve = strObjectNew End Function '===================================================================================RebuildCurve Sub TestRebuildCurve strObject = Rhino.GetObject("select a curve: ",4) intSections = Rhino.GetInteger("number of CVs: ",3,1,100) strObjectNew = RebuildCurve (strObject, intSections) arrCVs = Rhino.CurvePoints (strObjectNew) Rhino.Print "No. of CVs: " & CStr(UBound(arrCVs)) End Sub '===================================================================================RebuildCurve