Option Explicit 'Script written by 'Dimitrie Stefanescu 'http://dimitrie.wordpress.com 'Contact him at: didi [at] improved [dot] ro ' 'and by 'Manuel A. 'http://cadcampuc.blogspot.com/ 'Contact him at: manuel.a7 [at] gmail [dot] com ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''Script released under the Creative Commons Attribution-Non-Commercial-Share Alike 3.0 Licence'' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' 'To (probably) do: make the cuts in a fixed, ordered way - right now they are a bit chaotic, going 'towards the inside then towards the outside. ' Call Main() Sub Main() Dim arrRibsX : arrRibsX = Rhino.GetObjects("Select ribs on X dir:", 8) Dim arrRibsY : arrRibsY = Rhino.GetObjects("Select ribs on Y dir:", 8) Dim matThx : matThx = Rhino.GetReal("Material thickness in X Ribs: ", 1) Dim matThy : matThy = Rhino.GetReal("Material thickness in Y Ribs: ", matThx) Dim obj1, obj2, l, mid, crvDom, cil1, cil2, extn Dim split1, split2, i, j Dim dl : dl = Array() Dim k : k = -1 Dim maxx, maxy : maxx = Ubound(arrRibsX) : maxy = Ubound(arrRibsY) Dim arrItems, arrDefaults, arrResults, lineaLength, cmid arrItems = Array( "Extend_Split _x", "False", "True", "Extend_Split _y", "False", "True", "Invert_directions", "False", "True", "Echo", "False", "True") arrDefaults = Array(False, False, False, True) arrResults = Rhino.GetBoolean("Select options and then press enter:", arrItems, arrDefaults) matThx = matThx / 2 matThy = matThy / 2 Call Rhino.EnableRedraw(False) For i = 0 To Ubound(arrRibsX) For j = 0 To Ubound(arrRibsY) if(arrResults(3)) then Call Rhino.Print("The weahter is fine. We are working. I = " & i & " out of " & maxx & " and J = " & j & " out of " & maxy & ".") End If obj1 = arrRibsX(i) : obj2 = arrRibsY(j) l = Rhino.IntersectBreps(obj1, obj2) If isArray(l) Then crvDom = Rhino.CurveDomain(l(0)) mid = Rhino.DivideCurve(l(0), 2) lineaLength = Rhino.CurveLength (l(0)) If arrResults(0) Then l(0) = Rhino.ExtendCurveLength (l(0), 0, 0, lineaLength/2) End If If arrResults(1) Then l(0) = Rhino.ExtendCurveLength (l(0), 0, 1, lineaLength/2) End If cmid = Rhino.DivideCurve(l(0), 2) If arrResults(2) Then cil1 = Rhino.AddCylinder(mid(1), cmid(2), matThx) Else cil1 = Rhino.AddCylinder(mid(1), cmid(0), matThx) End If If arrResults(2) Then cil2 = Rhino.AddCylinder(mid(1), cmid(0), matThy) Else cil2 = Rhino.AddCylinder(mid(1), cmid(2), matThy) End If split1 = Rhino.SplitBrep(obj1, cil1, True) split2 = Rhino.SplitBrep(obj2, cil2, True) arrRibsX(i) = split1(0) arrRibsY(j) = split2(0) k = k + 5 ReDim Preserve dl(k) dl(k) = cil1 : dl(k-1) = cil2 : dl(k-4) = l(0) dl(k-2) = split1(1) : dl(k-3) = split2(1) Call Rhino.DeleteObjects(dl) 'in case of error, at least you erase the garbage from the good ones. You can manually split the object with the cylinder and then load the script again. Else Call Rhino.Print("Something's odd (no intersection found - probably we're on the edges). It's ok.") End If Next Next Call Rhino.EnableRedraw(True) End Sub