++ COMPUTATIONAL / PARAMETRIC / ALGORITHMIC // DESIGN & EXPERIMENTATION
Coming soon, an array of scripts, definition files and other experiments involving computation.
++ RhinoScript
++Cube Warp : Draws cube of given size and warps it according to a given vector
‘Script written by Erik Eugenio Martinez
‘Script copyrighted by Rosas el Pelón
‘Script version Monday, January 26, 2009 9:12:45 PM
Call Main()
Sub Main()
‘Specify initial point for Cube
Dim arrInitialPoint : arrInitialPoint = Rhino.GetPoint(“Specify initial point”)
‘Get Points for initial cube
Dim CubePoints : CubePoints = MakeCube(arrInitialPoint)
‘Draw cube lines based on those points
Dim Cube : Cube = DrawCube(CubePoints)
‘Get Points to warp cube
Dim arrPoints : arrPoints = Rhino.GetPoints(False, False, “Specify Points to move”)
‘Define and create vector
Dim arrVecStart : arrVecStart = Rhino.GetPoint(“Specicy vector initial point”)
Dim arrVecEnd : arrVecEnd = Rhino.GetPoint(“Specicy vector end point”)
Dim vecMove : vecMove = Rhino.VectorCreate(arrVecEnd, arrVecStart)
Dim i, j, Points, newPoints
For i=0 To Ubound(CubePoints)
For j = 0 To Ubound(arrPoints)
‘Check that points are equal
If Rhino.PointCompare(arrPoints(j), CubePoints(i)) = True Then
‘Add a point and move it
Points = Rhino.AddPoint(arrPoints(j))
newPoints = Rhino.MoveObject(Points,vecMove)
‘Get that moved point’s world coordinates
arrPoints(j) = Rhino.PointCoordinates(newPoints)
‘Assign that coordinate to original array of points
CubePoints(i)=arrPoints(j)
End If
Next
Next
‘Delete old geometry
Call Rhino.DeleteObjects(Rhino.UnselectedObjects())
‘Draw new cube with modified point array
Call DrawCube(CubePoints)
End Sub
Function MakeCube(arrInitialPoint)
Call Rhino.EnableRedraw(False)
Dim arrCube, dblCubeSize, arrLowerSquare1, arrLowerSquare2, arrLowerSquare3, arrLowerSquare4, arrUpSquare1, arrUpSquare2, arrUpSquare3, arrUpSquare4
dblCubeSize = Rhino.getreal(“Specify length of cube”)
arrLowerSquare1 = arrInitialPoint
arrLowerSquare2 = array(arrInitialPoint(0)+dblCubeSize,arrInitialPoint(1), arrInitialPoint(2))
arrLowerSquare3 = array(arrInitialPoint(0)+dblCubeSize,arrInitialPoint(1)+dblCubeSize, arrInitialPoint(2))
arrLowerSquare4 = array(arrInitialPoint(0),arrInitialPoint(1)+dblCubeSize, arrInitialPoint(2))
arrUpSquare1 = array(arrInitialPoint(0),arrInitialPoint(1), arrInitialPoint(2)+dblCubeSize)
arrUpSquare2 = array(arrInitialPoint(0)+dblCubeSize,arrInitialPoint(1), arrInitialPoint(2)+dblCubeSize)
arrUpSquare3 = array(arrInitialPoint(0)+dblCubeSize,arrInitialPoint(1)+dblCubeSize, arrInitialPoint(2)+dblCubeSize)
arrUpSquare4 = array(arrInitialPoint(0),arrInitialPoint(1)+dblCubeSize, arrInitialPoint(2)+dblCubeSize)
‘ Dim arrUpSquare : arrUpSquare = array(arrUpSquare1, arrUpSquare2, arrUpSquare3, arrUpSquare4, arrUpSquare1)
‘ Call Rhino.AddPolyline(arrUpSquare)
arrCube = array(arrLowerSquare1, arrLowerSquare2, arrLowerSquare3, arrLowerSquare4,arrUpSquare1, arrUpSquare2, arrUpSquare3, arrUpSquare4)
‘Call Rhino.AddBox(arrCube)
Call Rhino.EnableRedraw(True)
MakeCube = arrCube
End Function
Function DrawCube(CubePoints)
‘ Call Rhino.AddPoints(CubePoints)
Dim Line1, Line2, Line3, Line4
Call Rhino.AddPolyline(array(CubePoints(0), CubePoints(1), CubePoints(2), CubePoints(3),CubePoints(0)))
Call Rhino.AddPolyline(array(CubePoints(4), CubePoints(5), CubePoints(6), CubePoints(7),CubePoints(4)))
Line1 = Rhino.AddLine(cubePoints(0),CubePoints(4))
Line2 = Rhino.AddLine(cubePoints(1),CubePoints(5))
Line3 = Rhino.AddLine(cubePoints(2),CubePoints(6))
Line4 = Rhino.AddLine(cubePoints(3),CubePoints(7))
Call Rhino.AddSrfPt(array(CubePoints(0), CubePoints(1), CubePoints(2), CubePoints(3)))
Call Rhino.AddSrfPt(array(CubePoints(4), CubePoints(5), CubePoints(6), CubePoints(7)))
Call Rhino.AddLoftSrf(array(line1, line2, line3, line4),,,2,,,True)
End Function
++Attractor : Copies and scales object around a given set of attractor points
Dim i, j, k, arrStart, arrEnd
intXSize = Rhino.GetInteger(“Input the number of copies in X, please”,5,2,50)
If IsNull(intXSize) Then Exit Sub
intYSize = Rhino.GetInteger(“Input the number of copies in Y, please”,5,2,50)
If IsNull(intYSize) Then Exit Sub
intZSize = Rhino.GetInteger(“Input the number of copies in Z, please”,5,2,50)
If IsNull(intZSize) Then Exit Sub
strObject = Rhino.GetObject(“give me an object to copy around”)
If IsNull(strObject) Then Exit Sub
Dim arrStrPoints : arrStrPoints = rhino.GetObjects(“Give me locators”,1)
Dim arrPoints : arrPoints = arrStrPoints
For i=0 To Ubound(arrStrPoints)
arrPoints(i) = rhino.PointCoordinates(arrStrPoints(i))
Next
‘loop from 0 to 9
For i = 0 To intXSize – 1
For j = 0 To intYSize – 1
For k = 0 To intZSize – 1
arrStart = array(-1,-1,-1)
arrEnd = array(i,j,k)
Dim arrDistances : arrDistances = myOwnDistance(arrEnd, arrPoints)
arrDistances = rhino.sortnumbers(arrDistances)
Dim strCopy : strCopy = rhino.CopyObject(strObject,arrStart,arrEnd)
Call Rhino.ScaleObject(strCopy,arrEnd, array(arrDistances(0)*0.1, arrDistances(0)*0.1, arrDistances(0)*0.1))
Next ‘end the k loop
Next ‘end the j loop
Next ‘end the i loop
End Sub
Function MyOwnDistance(arrPoint, arrLocators)
Dim i
Dim arrDistances : arrDistances = arrLocators
For i=0 To Ubound(arrLocators)
arrDistances(i) = rhino.Distance(arrPoint, arrLocators(i))
Next
MyOwnDistance = arrDistances
End Function
++Sin Surf : Creates a lofted sin curve surface
Sub Main()
Dim x,y,z,i
Dim PI : PI = 3.14159265
Dim dblA : dblA = Rhino.GetReal (“type the amplitude”, 1)
Dim dblC : dblC = Rhino.GetReal (“type the vertical offset”, 2)
Dim dblP : dblP = Rhino.GetReal (“type the period”, 2)
Dim dblw : dblw = 2*PI/dblP
Dim dblAlfa : dblAlfa = Rhino.GetReal (“type the phase shift”, .3)
Dim dblLength : dblLength = Rhino.GetReal (“type the length”, 10)
Dim dblRes : dblRes = Rhino.GetReal (“type the resolution”, 100)
Dim dblStep : dblStep = dblLength/dblres
Dim arrLine()
Dim j
Dim k : k=0
Dim arrSurf()For k=0 To 10
j=0
ReDim arrLine(0)
For i=0 To dblLength Step dblStep
x=i
y=k
z=dblA*sin(dblW*(x-dblAlfa))+dblC
dblA=cos(k+sin(i))+sin(i)
dblAlfa=cos(k)
ReDim Preserve arrLine(j)
arrLine(j) = array(x,y,z)
‘Call Rhino.AddPoint(array(x,y,z))
j=j+1
Next
ReDim Preserve arrSurf(k)
arrSurf(k) = Rhino.AddInterpCurve(arrLine)
Next
Call Rhino.AddLoftSrf(arrSurf)
End Sub
++Lorenz Attractor : Creates a series of lorenz attractor monsters
Sub Main()Call Rhino.EnableRedraw(False)
Dim x,y,z
Dim xPt, Ypt, Zpt
ReDim arrPoints(1000)
‘ Dim a : a = 1
‘ Dim b : b = 2.51
‘ Dim c : c = 2.2049
‘ Dim d : d = 0.14
Dim i,j
For j=0 To 9
Dim a : a = randBetween(2.24, -1.2)
Dim b : b = randBetween(2.24, -1.2)
Dim c : c = randBetween(2.24, -1.2)
Dim d : d = randBetween(2.24, -1.2)
For i=0 To 1000
xPt = ((Sin(a * y) – z * Cos(b * x))+(j*5))
yPt = z * Sin(c * x) – Cos(d * y)
zPt = Sin(x)
‘ Call Rhino.AddPoint(array(xPt,yPt,zPt))
arrPoints(i) = array(xPt,yPt,zPt)
x = xPt
y = yPt
z = zPt
Next
Rhino.AddInterpCurve(arrPoints)
‘Rhino.AddPointCloud(arrPoints)
Call Rhino.EnableRedraw(True)
Next
End Sub
Function randBetween (upper, Lower)
randBetween = ((upper-lower)*Rnd + lower)
End Function
++CA Surface : Creates a surface from a cellular automata rule
Option Explicit
Option Explicit
‘Script written by <insert name>
‘Script copyrighted by <insert company name>
‘Script version Tuesday, January 27, 2009 11:37:10 PM
Call Main()
Sub Main()
‘Define the starting condition
Dim strGen
strGen = “1,1,0,1,1,1,1,0,0,1,1,0,1,0,0,1,0,1,1,1,1,1,0,0,1,1,1,1,1,1,1″
Dim arrPolyline(), strPolyline, arrLoftLines()
Dim intHowMany : intHowMany = Rhino.GetInteger(“How many generations?”,10)
Dim j
Call Rhino.EnableRedraw(False)
For J=0 To intHowMany
Rhino.Print strGen
Dim arrToken : arrToken = rhino.Strtok(strGen, “,”)
Dim i
For i=0 To Ubound(arrToken)
Dim strCurrentChar : strCurrentChar = arrToken(i)
‘Dim strTextDotID : strTextDotID = Rhino.AddTextDot(arrToken(i), array(i,j,0))
Dim strPointCenter : strPointCenter = Rhino.AddPoint(array(i,j,0))
Dim a, b, c, d, arrSquare, strSquare
a = array(i+.5, j+.5,0)
b = array(i-.5, j+.5, 0)
c = array(i-.5, j-.5, 0)
d = array(i+.5, j-.5,0)
arrSquare = array(a,b,c,d)
strSquare = Rhino.AddSrfPt(arrSquare)
If strCurrentChar=0 Then
Call Rhino.ObjectColor(strSquare, rgb(250,250,250))
Rhino.AddPoint(array(i,j,1))
ReDim Preserve arrPolyline(i)
arrPolyline(i) = array(i,j,1)
Else
Call Rhino.ObjectColor(strSquare, rgb(0,0,0))
Rhino.AddPoint(array(i,j,-1))
ReDim Preserve arrPolyline(i)
arrPolyline(i) = array(i,j,-1)
End If
‘ rhino.print arrPolyline(i)
Next
strPolyline = rhino.addinterpcurve(arrPolyline)
strGen = NextGeneration(StrGen)
ReDim Preserve arrLoftLines(j)
arrLoftLines(j) = strPolyline
Next
Call Rhino.AddLoftSrf(arrLoftLines)
Call Rhino.EnableRedraw(True)
End Sub
Function NextGeneration(strGen)
‘define 3 variables
Dim strCharacter, strLeftCharacter, strRightCharacter, strNextGen, arrToken
strNextGen = “”
arrToken = rhino.Strtok(StrGen, “,”)
Dim i
For i=0 To Ubound(arrToken)
strCharacter = arrToken(i)
If i = 0 Then
strLeftCharacter = arrToken(Ubound(arrToken))
Else
strLeftCharacter = arrToken(i-1)
End If
If i= Ubound(arrToken) Then
strRightCharacter = arrToken(0)
Else
strRightCharacter = arrToken(i+1)
End If
If strLeftCharacter = 1 And strCharacter = 1 And strRightCharacter = 1 Then
strNextGen = strNextGen & “,0″
End If
If strLeftCharacter = 1 And strCharacter = 1 And strRightCharacter = 0 Then
strNextGen = strNextGen & “,0″
End If
If strLeftCharacter = 1 And strCharacter = 0 And strRightCharacter = 1 Then
strNextGen = strNextGen & “,0″
End If
If strLeftCharacter = 1 And strCharacter = 0 And strRightCharacter = 0 Then
strNextGen = strNextGen & “,1″
End If
If strLeftCharacter = 0 And strCharacter = 1 And strRightCharacter = 1 Then
strNextGen = strNextGen & “,1″
End If
If strLeftCharacter = 0 And strCharacter = 1 And strRightCharacter = 0 Then
strNextGen = strNextGen & “,1″
End If
If strLeftCharacter = 0 And strCharacter = 0 And strRightCharacter = 1 Then
strNextGen = strNextGen & “,1″
End If
If strLeftCharacter = 0 And strCharacter = 0 And strRightCharacter = 0 Then
strNextGen = strNextGen & “,0″
rhino.Print i
End If
Next
‘tokenize the strGen+
NextGeneration = strNextGen
‘loop through each of the arrTokens
‘go through the wolfram rules
‘if furle applies change char
‘return the new created string
End Function
++ MEL
++256 Cells : Creates a series of 256 cells based on an L-System engine. The L-System changes the position at which solids are created, these are then multiplied by using a mirror boolean (the AutoSymmetry Script) and moved. The script is cyclic, so the first few iterations repeat. To run: 1) Load the AutoSymmetry script and run once, even if it doesn’t do anything. 2) Run the locator grid script to create a series of locators 3) run the 256Cells script to create them.
int $j = 0;
int $k = 0;
int $l = 0;
int $B = 1;
int $Rule[ ];
$Rule[0] = 0;
$Rule[1] = 0;
$Rule[2] = 0;
$Rule[3] = 0;
while ( $i < 4 ) {
$Rule[0] = $i;
$i++;
$j = 0;
while ( $j < 4) {
$Rule[1] = $j;
$j++;
$k = 0;
while ( $k < 4 ) {
$Rule[2] = $k;
$k++;
$l = 0;
while ( $l < 4) {
$Rule[3] = $l;
$l++;
print(($Rule[0])); print(($Rule[1])); print(($Rule[2])); print(($Rule[3]+” “));
matrix $Top[3][3] = << 1, 3, 1; 0, 2, 0; 1, 3, 1 >>;
matrix $Middle[3][3] = << 2, 0, 2; 3, 1, 3; 2, 0, 2 >>;
matrix $Bottom[3][3] = << 1, 3, 1; 0, 2, 0; 1, 3, 1 >>;
//SPECIFY RULESET
int $R1[] = {$Rule[2]};
int $R2[] = {$Rule[2],$Rule[1]};
int $R3[] = {$Rule[3]};
string $Letters[] = {“A”,”B”,”C”,”D”};
string $Point1;
int $i = 0;
while ( $i < 2 ) {
int $j = 0;
while ( $j < 2){
if ( $Top [$i] [$j] == $R1[0] ) {
$Point1 = ($Letters[($R1[0])]+($i+1)+($j+1)+”_Top”);
print ($Point1);
break;
}
$j++;
}
$i++;
}
float $P1[ ] = pointPosition($Point1);
string $Point2;
int $i = 0;
while ( $i < 2 ) {
int $j = 0;
while ( $j < 2){
if ( $Middle [$i] [$j] == $R2[0] ) {
$Point2 = ($Letters[($R2[0])]+($i+1)+($j+1)+”_Mid”);
print ($Point2);
break;
}
$j++;
}
$i++;
}
float $P2[ ] = pointPosition($Point2);
string $Point3;
int $i = 0;
while ( $i < 2 ) {
int $j = 0;
while ( $j < 2){
if ( $Middle [$i] [$j] == $R2[1] ) {
$Point3 = ($Letters[($R2[1])]+($i+1)+($j+1)+”_Mid”);
print ($Point3);
break;
}
$j++;
}
$i++;
}
float $P3[ ] = pointPosition($Point3);
string $Point4;
int $i = 0;
while ( $i < 2 ) {
int $j = 0;
while ( $j < 2){ if ( $Top [$i] [$j] == $R3[0] ) { $Point4 = ($Letters[($R3[0])]+($i+1)+($j+1)+”_Top”); print ($Point4); break; } $j++; } $i++; } float $P4[ ] = pointPosition($Point4); string $Cube1[] = `polyCube -w 1.1 -h 1.1 -d 1.1`; move $P1[0] $P1[1] $P1[2]; string $Cube2[] = `polyCube -w 1.1 -h 1.1 -d 1.1` ; move $P2[0] $P2[1] $P2[2]; polyBoolOp -n (“Cube3″+$B) $Cube1[0] $Cube2[0]; string $Cube4[] = `polyCube -w 1.1 -h 1.1 -d 1.1` ; move $P3[0] $P3[1] $P3[2]; select -cl; polyBoolOp -n (“Cube5″+$B) (“Cube3″+$B) $Cube4[0]; select -cl; string $Cube6[] = `polyCube -w 1.1 -h 1.1 -d 1.1` ; move $P4[0] $P4[1] $P4[2]; string $Po[] = `polyBoolOp -n (“Poly”+($B)) (“Cube5″+$B) $Cube6[0]`; select $Po[0]; Run_symmetry 0; select (“Poly”+($B+1)); Run_symmetry 1; select (“Poly”+($B+2)); Run_symmetry 2; select (“Poly”+($B+3)); rename (“Poly”+($B));int $i = 1; select $Po[0]; rename (“Poly”+($B)); select (“Poly”+($B)); move -r -os -wd ($B*20) ; print (“/////”+$B+”//////”+”\n”); //if ($B > 2){
// if (($B == 3)){
// select -cl;
// polyBoolOp -n (“P” +($B+2)) (“Poly” + ($B-1)) (“Poly” + ($B-2));
// }
// else
// polyBoolOp -n (“P” +($B+2)) (“P” + ($B+1)) (“Poly” + ($B-1));
//}
$B++;
select -cl;
}
}
}
}
++Locator Grid : Creates a 3*3*3 locator grid, for 256 Cell Script
$StrMidLocator = “locator1″;
float $FlMidPt[ ] = pointPosition($StrMidLocator);
//DRAW CUBE GRID LOCATORS
//FIRST ROW TOP
float $B1Top[];
$B1Top[0] = $FlMidPt[0] -1;
$B1Top[1] = $FlMidPt[1] -1;
$B1Top[2] = $FlMidPt[2] + 1;
spaceLocator -p $B1Top[0] $B1Top[1] $B1Top[2] -n “B11 Top”;
float $D1Top[];
$D1Top[0] = $FlMidPt[0] – 1;
$D1Top[1] = $FlMidPt[1] – 0;
$D1Top[2] = $FlMidPt[2] + 1;
spaceLocator -p $D1Top[0] $D1Top[1] $D1Top[2] -n “D12 Top”;
float $B2Top[];
$B2Top[0] = $FlMidPt[0] -1;
$B2Top[1] = $FlMidPt[1] +1;
$B2Top[2] = $FlMidPt[2] + 1;
spaceLocator -p $B2Top[0] $B2Top[1] $B2Top[2] -n “B13 Top”;
//SECOND ROW TOP
float $A1Top[];
$A1Top[0] = $FlMidPt[0] – 0;
$A1Top[1] = $FlMidPt[1] -1;
$A1Top[2] = $FlMidPt[2] + 1;
spaceLocator -p $A1Top[0] $A1Top[1] $A1Top[2] -n “A21 Top”;
float $C1Top[];
$C1Top[0] = $FlMidPt[0] – 0;
$C1Top[1] = $FlMidPt[1] – 0;
$C1Top[2] = $FlMidPt[2] + 1;
spaceLocator -p $C1Top[0] $C1Top[1] $C1Top[2] -n “C22 Top”;
float $A2Top[];
$A2Top[0] = $FlMidPt[0] -0;
$A2Top[1] = $FlMidPt[1] +1;
$A2Top[2] = $FlMidPt[2] + 1;
spaceLocator -p $A2Top[0] $A2Top[1] $A2Top[2] -n “A23 Top”;
//THIRD ROW TOP
float $B3Top[];
$B3Top[0] = $FlMidPt[0] +1;
$B3Top[1] = $FlMidPt[1] -1;
$B3Top[2] = $FlMidPt[2] + 1;
spaceLocator -p $B3Top[0] $B3Top[1] $B3Top[2] -n “B31 Top”;
float $D2Top[];
$D2Top[0] = $FlMidPt[0] +1;
$D2Top[1] = $FlMidPt[1] – 0;
$D2Top[2] = $FlMidPt[2] + 1;
spaceLocator -p $D2Top[0] $D2Top[1] $D2Top[2] -n “D32 Top”;
float $B4Top[];
$B4Top[0] = $FlMidPt[0] +1;
$B4Top[1] = $FlMidPt[1] +1;
$B4Top[2] = $FlMidPt[2] + 1;
spaceLocator -p $B4Top[0] $B4Top[1] $B4Top[2] -n “B33 Top”;
//FIRST ROW MID
float $C1Mid[];
$C1Mid[0] = $FlMidPt[0] -1;
$C1Mid[1] = $FlMidPt[1] -1;
$C1Mid[2] = $FlMidPt[2] + 0;
spaceLocator -p $C1Mid[0] $C1Mid[1] $C1Mid[2] -n “C11 Mid”;
float $A1Mid[];
$A1Mid[0] = $FlMidPt[0] – 1;
$A1Mid[1] = $FlMidPt[1] – 0;
$A1Mid[2] = $FlMidPt[2] + 0;
spaceLocator -p $A1Mid[0] $A1Mid[1] $A1Mid[2] -n “A12 Mid”;
float $C2Mid[];
$C2Mid[0] = $FlMidPt[0] -1;
$C2Mid[1] = $FlMidPt[1] +1;
$C2Mid[2] = $FlMidPt[2] + 0;
spaceLocator -p $C2Mid[0] $C2Mid[1] $C2Mid[2] -n “C13 Mid”;
//SECOND ROW MID
float $D1Mid[];
$D1Mid[0] = $FlMidPt[0] -0;
$D1Mid[1] = $FlMidPt[1] -1;
$D1Mid[2] = $FlMidPt[2] + 0;
spaceLocator -p $D1Mid[0] $D1Mid[1] $D1Mid[2] -n “D21 Mid”;
float $B1Mid[];
$B1Mid[0] = $FlMidPt[0] – 0;
$B1Mid[1] = $FlMidPt[1] – 0;
$B1Mid[2] = $FlMidPt[2] + 0;
spaceLocator -p $B1Mid[0] $B1Mid[1] $B1Mid[2] -n “B22 Mid”;
float $D2Mid[];
$D2Mid[0] = $FlMidPt[0] -0;
$D2Mid[1] = $FlMidPt[1] +1;
$D2Mid[2] = $FlMidPt[2] + 0;
spaceLocator -p $D2Mid[0] $D2Mid[1] $D2Mid[2] -n “D23 Mid”;
//THIRD ROW MID
float $C3Mid[];
$C3Mid[0] = $FlMidPt[0] +1;
$C3Mid[1] = $FlMidPt[1] -1;
$C3Mid[2] = $FlMidPt[2] + 0;
spaceLocator -p $C3Mid[0] $C3Mid[1] $C3Mid[2] -n “C31 Mid”;
float $A2Mid[];
$A2Mid[0] = $FlMidPt[0] + 1;
$A2Mid[1] = $FlMidPt[1] – 0;
$A2Mid[2] = $FlMidPt[2] + 0;
spaceLocator -p $A2Mid[0] $A2Mid[1] $A2Mid[2] -n “A32 Mid”;
float $C4Mid[];
$C4Mid[0] = $FlMidPt[0] + 1;
$C4Mid[1] = $FlMidPt[1] +1;
$C4Mid[2] = $FlMidPt[2] + 0;
spaceLocator -p $C4Mid[0] $C4Mid[1] $C4Mid[2] -n “C33 Mid”;
//FIRST ROW BOT
float $B1Bot[];
$B1Bot[0] = $FlMidPt[0] -1;
$B1Bot[1] = $FlMidPt[1] -1;
$B1Bot[2] = $FlMidPt[2] -1;
spaceLocator -p $B1Bot[0] $B1Bot[1] $B1Bot[2] -n “B11 Bot”;
float $D1Bot[];
$D1Bot[0] = $FlMidPt[0] – 1;
$D1Bot[1] = $FlMidPt[1] – 0;
$D1Bot[2] = $FlMidPt[2] – 1;
spaceLocator -p $D1Bot[0] $D1Bot[1] $D1Bot[2] -n “D12 Bot”;
float $B2Bot[];
$B2Bot[0] = $FlMidPt[0] -1;
$B2Bot[1] = $FlMidPt[1] +1;
$B2Bot[2] = $FlMidPt[2] – 1;
spaceLocator -p $B2Bot[0] $B2Bot[1] $B2Bot[2] -n “B13 Bot”;
//SECOND ROW MID
float $A1Bot[];
$A1Bot[0] = $FlMidPt[0] -0;
$A1Bot[1] = $FlMidPt[1] -1;
$A1Bot[2] = $FlMidPt[2] -1;
spaceLocator -p $A1Bot[0] $A1Bot[1] $A1Bot[2] -n “A21 Bot”;
float $C1Bot[];
$C1Bot[0] = $FlMidPt[0] – 0;
$C1Bot[1] = $FlMidPt[1] – 0;
$C1Bot[2] = $FlMidPt[2] – 1;
spaceLocator -p $C1Bot[0] $C1Bot[1] $C1Bot[2] -n “C22 Bot”;
float $A2Bot[];
$A2Bot[0] = $FlMidPt[0] -0;
$A2Bot[1] = $FlMidPt[1] +1;
$A2Bot[2] = $FlMidPt[2] – 1;
spaceLocator -p $A2Bot[0] $A2Bot[1] $A2Bot[2] -n “A23 Bot”;
//THIRD ROW MID
float $B3Bot[];
$B3Bot[0] = $FlMidPt[0] +1;
$B3Bot[1] = $FlMidPt[1] -1;
$B3Bot[2] = $FlMidPt[2] -1;
spaceLocator -p $B3Bot[0] $B3Bot[1] $B3Bot[2] -n “B31 Bot”;
float $D2Bot[];
$D2Bot[0] = $FlMidPt[0] + 1;
$D2Bot[1] = $FlMidPt[1] – 0;
$D2Bot[2] = $FlMidPt[2] – 1;
spaceLocator -p $D2Bot[0] $D2Bot[1] $D2Bot[2] -n “D32 Bot”;
float $B4Bot[];
$B4Bot[0] = $FlMidPt[0] + 1;
$B4Bot[1] = $FlMidPt[1] +1;
$B4Bot[2] = $FlMidPt[2] – 1;
spaceLocator -p $B4Bot[0] $B4Bot[1] $B4Bot[2] -n “B33 Bot”;
++Move Camera : Moves camera at given interval and sets keyframe, great for batch rendering many objects
int $i = 1;
while ($i <20) {
currentTime $i ;
select camera1;
setKeyframe -v ($i*3 + 6) -at translateX;
print $i;
$i++;
}
}
++Rotate&Mirror : Takes object e2 and rotates and mirrors at given angles (AutoSymmetry script is necessary)
int $i = 10;
int $j = 2;
while ( $i < 360 ) {
select e2;
duplicate;
rotate -r $i 0 0;
Run_symmetry 2;
select -cl;
select (“e” + ($j+2));
move -r $i 0 0;
select -cl;
$i = $i+10;
$j = $j +2;
}
++AutoSymmetry : A modified version of Keegan’s Symmetry script, which allows x,y,z mirroring on call, by Alex Loyer Hughes @ Resolution
// LOAD SCRIPT
select -all;
global proc Auto_symmetry()
{
if (`window -exists Auto_symmetry`)
deleteUI -window Auto_symmetry;
window -rtf 1 -title “Auto_symmetry” Auto_symmetry;
columnLayout -adjustableColumn 1 mainco;
separator -h 10;
rowLayout -nc 2;
radioCollection worldorobject;
radioButton -label “Object Space” -select object;
radioButton -label “World Space” world;
setParent mainco;
separator -h 10;
rowLayout -nc 3;
radioCollection planedirection;
radioButton -label “YZ plane” -select x;
radioButton -label “ZX plane” y;
radioButton -label “XY plane” z;
setParent mainco;
separator -h 10;
button -label “Symmetry” -h 30 -c symmetry;
button -label “Finalise” -h 30 -c finalise;
string $master_text = `textField -visible 0 -editable 0 -text “” tfm`;
string $symmetry_text = `textField -editable 0 -text “” tfs`;
progressBar -height 10 -maxValue 100 pgb;
//showWindow;
}
/////////////////////////////////////////////////////////////////////////////////
global proc symmetry (int $qx, int $qy, int $qz, string $direction, int $world)
{
selectMode -component;
selectMode -object;
string $master[] = `ls -sl`;
float $boundingBox[] = `xform -q -boundingBox $master`;
float $xmin = $boundingBox[0];
float $xmax = $boundingBox[3];
float $ymin = $boundingBox[1];
float $ymax = $boundingBox[4];
float $zmin = $boundingBox[2];
float $zmax = $boundingBox[5];
float $xout = $xmin + $xmax;
float $yout = $ymin + $ymax;
float $zout = $zmin + $zmax;
textField -edit -text $master tfm;
//string $direction = `radioCollection -q -select planedirection`;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
//int $qx = `radioButton -q -select x`;
//int $qy = `radioButton -q -select y`;
//int $qz = `radioButton -q -select z`;
//int $world = `radioButton -q -select world`;
if ($world == 1)
{
xform -worldSpace -rotatePivot 0 0 0 -scalePivot 0 0 0;
$kkpolycut = `polyCut -cuttingDirection $direction -deleteFaces 1`;
rename $kkpolycut kk_symmetrypolycut;
setAttr “kk_symmetrypolycut.cutPlaneCenterX” 0;
setAttr “kk_symmetrypolycut.cutPlaneCenterY” 0;
setAttr “kk_symmetrypolycut.cutPlaneCenterZ” 0;
}
else
{
xform -centerPivots;
$kkpolycut = `polyCut -cuttingDirection $direction -deleteFaces 1`;
rename $kkpolycut kk_symmetrypolycut;
}
if ($qx == 1)
{
if ($xout < -.0 )
{
setAttr “kk_symmetrypolycut.cutPlaneRotateX” 180;
}
}
if ($qy == 1)
{
if ($yout < -.0 )
{
setAttr “kk_symmetrypolycut.cutPlaneRotateZ” 180;
}
}
if ($qz == 1)
{
if ($zout < -.0 )
{
setAttr “kk_symmetrypolycut.cutPlaneRotateY” 180;
}
}
duplicate -instanceLeaf -name ($master[0]+” is symmetry”);
string $symmetry []= `ls -sl`;
textField -edit -text $symmetry tfs;
createDisplayLayer -noRecurse -name “symmetry_layer”;
setAttr symmetry_layer.displayType 2;
if ($qx == 1)
{
scale -1 1 1;
}
if ($qy == 1)
{
scale 1 -1 1;
}
if ($qz == 1)
{
scale 1 1 -1;
}
polyMergeVertex -d 0.0001;
select -cl;
select $master;
delete -ch;
selectMode -component;
}
/////////////////////////////////////////////////////////////////////////
global proc finalise()
{
selectMode -object;
delete symmetry_layer;
string $tfm = `textField -q -text tfm`;
string $tfs = `textField -q -text tfs`;
polyUnite -name $tfm $tfm $tfs ;
polyMergeVertex -d 0.0001 ;
delete -ch;
select -cl;
textField -edit -text “” tfm;
textField -edit -text “” tfs;
delete $tfm;
}
/////////////////////////////////////////////////////////////////////////
global proc Run_symmetry(int $pick)
{
Auto_symmetry;
switch($pick){
case 0: // YZ PLANE //
symmetry 1 0 0 x 1;
finalise;
break;
case 1: // ZX PLANE //
symmetry 0 1 0 y 1;
finalise;
break;
case 2: // XY PLANE //
symmetry 0 0 1 z 1;
finalise;
break;
}
}
// FINISH LOAD SCRIPT
// RUN SCRIPT
Run_symmetry 1;




No Comments Yet