# [P]ooper Machine

### Projects details

Code createsÂ Machine Material Deposit Study
–Code was written during the Lunar Outpost [a] research thesis. The machine deposit represents the extracted material during the digging protocols. The base geometry is represented by a single line which represents the trajectory of the robot. Depending on the size and density required, the scale and density of the bundles + structure will adapt.–

### RHINSCRIPT CODE

```Option Explicit
'Script written by Luis Quinones
'Script version Sunday, January 31, 2010 10:01:33 PM

Call Main()
Sub Main()

'///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'select test curve
Dim strCurve
Dim i
Dim arrPoints, arrPoint
Dim arrBaseC()
Dim arrPTsA()
Dim arrPTsB()
Dim arrPTsC()
Dim arrPTsD()
Dim arrPTsE()
Dim arrPTsF()
Dim dblPosX,dblPosY,dblPosZ
Dim count
Dim intFactorA
Dim dblCurveParam,arrData,arrTangent,arrNewPoint
'///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
intFactorA = 72
intFactorA = 72/intFactorA
strCurve = Rhino.GetObject("Select Robot Poop Line",4)
If Rhino.IsCurve(strCurve) Then

Dim curvEnd : curvEnd = Rhino.CurveEndPoint(strCurve)
Dim Robot : Robot = rhino.addtextdot("ROBOT WEAVE",curvEnd)
Call Rhino.TextDotText(Robot,"ROBOT MATERIAL WEAVE")
Dim curvStart : curvStart = Rhino.CurveStartPoint(strCurve)
Dim Robot2 : Robot2 = rhino.addtextdot("ROBOT WEAVE_StepValue["& intFactorA & "]",curvStart)
'Call Rhino.TextDotText(Robot2,"Weave_Error Fix Mode")
'extract the curve points
arrPoints = Rhino.DivideCurve(strCurve,100)
If IsArray(arrPoints) Then
Dim intStep : intStep = intFactorA
Dim intOffset : intOffset = intStep/(intStep*50)
Dim    dblConv : dblConv = 0.0174532925
For i = 0 To 20 Step intStep

count = 0

For Each arrPoint In arrPoints
If IsArray(arrPoint) Then
dblCurveParam = Rhino.CurveClosestPoint(strCurve, arrPoint)

If IsNumeric(dblCurveParam) Then
arrData = Rhino.CurveCurvature(strCurve, dblCurveParam)
If IsArray(arrData) Then
arrTangent  = arrData(1)
arrNewPoint = array((arrPoint(0)+arrTangent(0)),(arrPoint(1)+arrTangent(1)),(arrPoint(2)+arrTangent(2)))
End If
End If
End If

ReDim Preserve arrBaseC(count)
ReDim Preserve arrPTsA(count)
ReDim Preserve arrPTsB(count)
ReDim Preserve arrPTsC(count)
ReDim Preserve arrPTsD(count)
ReDim Preserve arrPTsE(count)
ReDim Preserve arrPTsF(count)
'reference (x.y.z) values
dblPosX = arrNewPoint(0)
dblPosY = arrNewPoint(1)
dblPosZ = arrNewPoint(2)
'returns the remainder of a division operation. For example, 5%2 equals 1 because dividing 5 by 2 gives 2 and the remainder is 1, which is the value returned from this expression.
If count Mod 2 = 0 Then
'///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Else
'///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
End If
count = count + 1
Next
'Dim strCurveA : strCurveA = Rhino.AddInterpCurve(arrPTsA)
'Call  Rhino.ObjectColor (strCurveA,RGB (255,255,255))
'Call  Rhino.ObjectLayer(strCurveA,"ISH_A")
'Dim strCurveB : strCurveB = Rhino.AddInterpCurve(arrPTsB)
Dim strCurveC : strCurveC = Rhino.AddInterpCurve(arrPTsC)
Call  Rhino.ObjectColor (strCurveC,RGB (255,255,255))
Call  Rhino.ObjectLayer(strCurveC,"ISH_C")
Dim strCurveD : strCurveD = Rhino.AddInterpCurve(arrPTsD)
Call  Rhino.ObjectColor (strCurveD,RGB (255,120,90))
Call  Rhino.ObjectLayer(strCurveD,"ISH_D")
'Dim strCurveE : strCurveE = Rhino.AddInterpCurve(arrPTsE)
'Call  Rhino.ObjectColor (strCurveE,RGB (255,120,90))
'Call  Rhino.ObjectLayer(strCurveE,"ISH_E")
'Dim strCurveF : strCurveF = Rhino.AddInterpCurve(arrPTsF)
'Call  Rhino.ObjectColor (strCurveF,RGB (255,120,90))
'Call  Rhino.ObjectLayer(strCurve4,"ISH_F")
'select the 2nd to last curve from strCurveC to use
If i = 19 Then

Call Rhino.ObjectLayer(strCurveC,"LastCurve")
End If
'select the last to last curve from strCurveC to use
If i = 20 Then
Call Rhino.ObjectLayer(strCurveD,"LastCurve")
End If
Dim strPoopCurves : strPoopCurves = Rhino.ObjectsByLayer("LastCurve",True)
Next
Call PoopBracket(strPoopCurves)
End If
End If
End Sub

Dim strLine, strPipe
Call Rhino.SelectObject (strLine)
strPipe = Rhino.LastObject
Call Rhino.ObjectColor (strPipe, rgb(0,k,0))
Call Rhino.Command ("Selnone ")
Call Rhino.DeleteObject (strLine)
End Function

Function PoopBracket(strPoopCurves)
Dim strPoopCurve
Dim count3
count3 = 0
For Each strPoopCurve In  strPoopCurves
Dim strPoopCurve2 : strPoopCurve2 = Rhino.ObjectsByLayer("LastCurve",True)
If IsNull(strPoopCurve2) Then Exit Function
Dim crvObject2 : crvObject2 = strPoopCurve2(count3)
Dim intSteps : intSteps = 60
If IsNull(intSteps) Then Exit Function
Dim crvDomain : crvDomain = Rhino.CurveDomain(crvObject2)
Dim t, count

If count3 = 0 Then

Dim arrCrossSections(), CrossSectionPlane
Dim crvCurvature, crvPoint, crvTangent, crvPerp, crvNormal

count = 0

For t = crvDomain(0) To crvDomain(1) + 1e-9 Step (crvDomain(1)-crvDomain(0))/intSteps

crvCurvature = Rhino.CurveCurvature(crvObject2, t)
'If IsNull(crvCurvature) Then
'crvPoint = Rhino.EvaluateCurve(crvObject, t)
'crvTangent = Rhino.CurveTangent(crvObject, t)
'crvPerp = Array(0,0,1)
'crvNormal = Rhino.VectorCrossProduct(crvTangent, crvPerp)
'    Else
crvPoint = crvCurvature(0)
crvTangent = crvCurvature(1)
crvPerp = Rhino.VectorUnitize(crvCurvature(4))
crvNormal = Rhino.VectorCrossProduct(crvTangent, crvPerp)
'Dim strPoint : strPoint =  Rhino.AddPoint(crvNormal)
'Call Rhino.ObjectColor(strPoint,RGB(255,255,255))
CrossSectionPlane = Rhino.PlaneFromFrame(crvPoint, crvPerp, crvNormal)
ReDim Preserve arrCrossSections(count)
Else
End If
count = count + 1
Next

Else

Dim arrCrossSections1()
count = 0
For t = crvDomain(0) To crvDomain(1) + 1e-9 Step (crvDomain(1)-crvDomain(0))/intSteps

crvCurvature = Rhino.CurveCurvature(crvObject2, t)
'If IsNull(crvCurvature) Then
'crvPoint = Rhino.EvaluateCurve(crvObject, t)
'crvTangent = Rhino.CurveTangent(crvObject, t)
'crvPerp = Array(0,0,1)
'crvNormal = Rhino.VectorCrossProduct(crvTangent, crvPerp)
'    Else
crvPoint = crvCurvature(0)
crvTangent = crvCurvature(1)
crvPerp = Rhino.VectorUnitize(crvCurvature(4))
crvNormal = Rhino.VectorCrossProduct(crvTangent, crvPerp)
'Dim strPoint : strPoint =  Rhino.AddPoint(crvNormal)
'Call Rhino.ObjectColor(strPoint,RGB(255,255,255))
'End If
'origin, x axis, y axis
CrossSectionPlane = Rhino.PlaneFromFrame(crvPoint, crvPerp, crvNormal)
ReDim Preserve arrCrossSections1(count)
Else
End If
count = count + 1
Next
End If
If count < 1 Then Exit Function
If count3 = 0 Then
Dim strRobotPoopSrf : strRobotPoopSrf =  Rhino.AddLoftSrf(arrCrossSections)
Call Rhino.ObjectLayer(strRobotPoopSrf,"Robot_Mini_PooP")
Call Rhino.CurrentLayer("Robot_Mini_PooP_curves")
Call Rhino.ObjectsByLayer("Robot_Mini_PooP",True)
Call Rhino.Command("extractwireframe")
Call Rhino.LayerVisible ("Robot_Mini_PooP",False)
Dim arrPoopCrvs : arrPoopCrvs = Rhino.ObjectsByLayer("Robot_Mini_PooP_curves")
'///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Dim arrPoopCrv,count1
count1 = 0
For Each arrPoopCrv In arrPoopCrvs
Dim strCurrentCurve : strCurrentCurve = Rhino.SelectObject(arrPoopCrvs(count1))
strCurrentCurve = Rhino.LastObject
Call Rhino.ObjectColor (strCurrentCurve, rgb(255,255,255))
Call Rhino.Command ("Selnone ")
Call Rhino.DeleteObject (strCurrentCurve)
count1 = count1 + 1
Next
count3 = count3 + 1
Else
Dim strRobotPoopSrf2 : strRobotPoopSrf2 =  Rhino.AddLoftSrf(arrCrossSections1)
Call Rhino.ObjectLayer(strRobotPoopSrf2,"Robot_Mini_PooP2")
Call Rhino.CurrentLayer("Robot_Mini_PooP_curves2")
Call Rhino.ObjectsByLayer("Robot_Mini_PooP2",True)
Call Rhino.Command("extractwireframe")
Call Rhino.LayerVisible ("Robot_Mini_PooP2",False)
arrPoopCrvs = Rhino.ObjectsByLayer("Robot_Mini_PooP_curves2")
'///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
count1 = 0
For Each arrPoopCrv In arrPoopCrvs

strCurrentCurve = Rhino.SelectObject(arrPoopCrvs(count1))
strCurrentCurve = Rhino.LastObject
Call Rhino.ObjectColor (strCurrentCurve, rgb(255,255,255))
Call Rhino.Command ("Selnone ")
Call Rhino.DeleteObject (strCurrentCurve)
count1 = count1 + 1
Next
count3 = count3 + 1
'///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
End If
Next
End Function
Update
```

• Share