Option Explicit 'Script written by 'Script copyrighted by 'Script version Monday, 25 March 2019 15:22:07 Call Main() Sub Main() 'Surfaces to paint on Dim Canvas Canvas = Rhino.GetObjects("pick surfaces to paint on", 24) ' Get the names of all block definitions in the document Dim arrBlocks arrBlocks = Rhino.BlockNames(True) If Not IsArray(arrBlocks) Then Rhino.Print "No block definitions found in the document." Exit Sub End If ' Select a block name from a list Dim strBlocks strBlocks = Rhino.MultiListBox(arrBlocks, "Select block", "Blocks to place") If IsNull(strBlocks) Then Exit Sub 'Max amount of objects inserted Dim Max Max = Rhino.GetInteger("Max amount of block inserted", 200) 'Time between block insertion Dim FreqBase FreqBase = Rhino.GetInteger("Time between insertion (in milliseconds)", 100) 'Time Scatter Dim Options,Options_default,Scatter Options = Array("Time_Scatter", "Off", "On", "Space_Scatter", "Off", "On", "Scale_Scatter", "Off", "On", "Rotate_Scatter", "Off", "On") Options_default = Array(True, True, True, True) Scatter = Rhino.GetBoolean("Scatter Options : ", Options, Options_default) Dim TimeScatterMax If Scatter(0) Then TimeScatterMax = Rhino.GetInteger("Maximum time scatter change:", FreqBase / 2, 0, FreqBase) Else TimeScatterMax = 0 End If Dim SpaceScatterMax If Scatter(1) Then SpaceScatterMax = Rhino.GetInteger("Maximum space scatter displacement :", 5) Else SpaceScatterMax = 0 End If Dim ScaleScatterMax If Scatter(2) Then ScaleScatterMax = Rhino.GetInteger("Maximum scale change in % :", 10) ScaleScatterMax = ScaleScatterMax / 100 Else ScaleScatterMax = 0 End If Dim ScreenPos Dim CamPos Dim SpacemoveX, SpacemoveY, MoveVect Dim Timechange, Freq Dim Projections Dim Location Dim InsertPt Dim ProjVect Dim RandomPick Dim RandomRotate Dim RandomScale Dim Block Dim Whatever Dim i Call Rhino.MessageBox("Start Painting! Press ESC to quit") For i = 0 To Max Freq = FreqBase ScreenPos = Rhino.GetCursorPos()(0) If Scatter(1)Then SpacemoveX = Rhino.Rnd(SpaceScatterMax * -1, SpaceScatterMax) SpacemoveY = Rhino.Rnd(SpaceScatterMax * -1, SpaceScatterMax) MoveVect = Array(SpacemoveX, SpacemoveY, 0) ScreenPos = Rhino.PointAdd(ScreenPos, MoveVect) End If CamPos = Rhino.ViewCamera() ProjVect = Rhino.VectorCreate(CamPos, ScreenPos) Projections = Rhino.ProjectPointToSurface(ScreenPos, Canvas, Projvect) If Not Isnull(Projections) Then Location = Rhino.PointArrayClosestPoint(Projections, CamPos) InsertPt = Projections(Location) If Ubound(strBlocks) > 0 Then RandomPick = Rhino.Floor(Rhino.Rnd(0, Ubound(strBlocks))) Else RandomPick = 0 End if Block = strBlocks(Randompick) If Scatter(2) Then RandomScale = Rhino.Rnd(1 - ScaleScatterMax, 1 + ScaleScatterMax) Else RandomScale = 1 End If If Scatter(3) Then RandomRotate = Rhino.Rnd(0, 360) Else RandomRotate = 0 End If Call Rhino.InsertBlock(Block, InsertPt, Array(RandomScale, RandomScale, RandomScale), RandomRotate) End If If Scatter(0) Then Timechange = Rhino.Rnd(TimeScatterMax * -1, TimeScatterMax) Freq = Abs(FreqBase + Timechange) + 1 End If Rhino.Sleep(Freq) Next End Sub