Option Explicit 'Script written by Luis Quinones + Griffin Frazen 'Script copyrighted by [n]igma + studioBoom + computationalMatter 'Script version Wednesday, July 29, 2009 9:28:46 AM Call Main() Sub Main() 'User input Dim arrObj (9) Dim gens 'prompt user for number of gens gens = Rhino.GetReal("How many generations", 6) 'arrObj (mesh,pt1,pt2,pt3......pt9) arrObj(0) = Rhino.GetObject("Select Mesh") arrObj(1) = Rhino.GetObject("Select ref point 1",1) arrObj(2) = Rhino.GetObject("Select ref point 2",1) arrObj(3) = Rhino.GetObject("Select ref point 3",1) arrObj(4) = Rhino.GetObject("Select tar1 point 1",1) arrObj(5) = Rhino.GetObject("Select tar1 point 2",1) arrObj(6) = Rhino.GetObject("Select tar1 point 3",1) arrObj(7) = Rhino.GetObject("Select tar2 point 1",1) arrObj(8) = Rhino.GetObject("Select tar2 point 2",1) arrObj(9) = Rhino.GetObject("Select tar2 point 3",1) 'very beginning of main Dim arrItems : arrItems = Array ("Animate", "Off", "On") Dim arrDefaults : arrDefaults = Array(True) 'off is the default 'in the beginning of main with other user inputs Dim arrIterationBlnReturn : arrIterationBlnReturn = Rhino.GetBoolean ("Would you like to ", arrItems, arrDefaults) If Not isArray(arrIterationBlnReturn) Then Exit Sub 'For exporting images If arrIterationBlnReturn(0) = "True" Then Dim intIterationsPerImage : intIterationsPerImage = Rhino.GetInteger ("export images once in how many iterations?", 1, 1) If isNull(arrIterationBlnReturn) Then Exit Sub 'hardcoded variables: 'CHANGE THE FILE NAME TO AN EXISTING FOLDER - THE LAST PART IS THE BEGINNING OF THE FILE NAME Dim strFilename: strFilename ="C:Documents and SettingsAnim_" Dim dblImageXSize : dblImageXSize = 968 Dim dblImageYSize : dblImageYSize = 462 Dim intImageCounter : intImageCounter = 0 'turn off unwanted screen info Dim strView : strView = Rhino.CurrentView() Rhino.ShowGrid strView, False Rhino.ShowGridAxes strView, False Rhino.ShowViewTitle strView, False Rhino.ShowWorldAxes strView, False Call exportImage(strFilename, dblImageXSize, dblImageYSize, strView, intImageCounter) End If Call aggregate (arrObj,gens,0,arrIterationBlnReturn(0),intIterationsPerImage,intImageCounter,strFilename,dblImageXSize,dblImageYSize,strView) 'Call recursive function End Sub Function aggregate (arrObj,gens,ByRef intCounter, blnAnimate,intIterationsPerImage,intImageCounter,strFilename,dblImageXSize,dblImageYSize,strView) Dim arrREFPTs(2) Dim arrTAR1PTs(2) Dim arrTAR2PTs(2) Dim arrOBJ1 Dim arrOBJ2 'condition based on generations If gens > 0 Then 'compile an array of pts : ref,target1,target2 'array of ref pts. arrREFPTs(0) = Rhino.PointCoordinates(arrObj(1)) arrREFPTs(1) = Rhino.PointCoordinates(arrObj(2)) arrREFPTs(2) = Rhino.PointCoordinates(arrObj(3)) arrTAR1PTs(0) = Rhino.PointCoordinates(arrObj(4)) arrTAR1PTs(1) = Rhino.PointCoordinates(arrObj(5)) arrTAR1PTs(2) = Rhino.PointCoordinates(arrObj(6)) arrTAR2PTs(0) = Rhino.PointCoordinates(arrObj(7)) arrTAR2PTs(1) = Rhino.PointCoordinates(arrObj(8)) arrTAR2PTs(2) = Rhino.PointCoordinates(arrObj(9)) 'orient the object arrOBJ1 = Rhino.OrientObjects(arrObj, arrREFPTs, arrTAR1PTs, 1) 'at the end of the loop that you want to intCounter = intCounter + 1 If blnAnimate = "True" Then If intCounter Mod intIterationsPerImage = 0 Then intImageCounter = intImageCounter + 1 Call exportImage(strFilename, dblImageXSize, dblImageYSize, strView, intImageCounter) End If End If arrOBJ2 = Rhino.OrientObjects(arrObj, arrREFPTs, arrTAR2PTs, 1) intCounter = intCounter + 1 'at the end of the loop that you want to If blnAnimate = "True" Then If intCounter Mod intIterationsPerImage = 0 Then intImageCounter = intImageCounter + 1 Call exportImage(strFilename, dblImageXSize, dblImageYSize, strView, intImageCounter) End If End If 'calling recursive function (add the minus one so that the gen runs and each time is one less so it counts down to 0 'otherwise it will never end Call aggregate (arrOBJ1,gens-1,intCounter, blnAnimate,intIterationsPerImage,intImageCounter,strFilename,dblImageXSize,dblImageYSize,strView) Call aggregate (arrOBJ2,gens-1,intCounter, blnAnimate,intIterationsPerImage,intImageCounter,strFilename,dblImageXSize,dblImageYSize,strView) End If End Function Sub exportImage(strFilename, dblImageXSize, dblImageYSize, strView, intIteration) Dim strNumber 'create a number for the image, additional zeros are added to ensure the files are read in the correct order by photoshop batch actions If intIteration < 9 Then strNumber = "000" & (intIteration + 1) ElseIf intIteration > 8 And intIteration < 99 Then strNumber = "00" & (intIteration + 1) ElseIf intIteration > 98 And intIteration < 999 Then strNumber = "0" & (intIteration + 1) Else strNumber = intIteration + 1 End If 'send the image to an appropriately named file Rhino.CreatePreviewImage strFilename & strNumber & ".jpg", strView, array(dblImageXSize, dblImageYSize) End Sub Update