Please log in to write a message.
-
6. ledisnomad (Feb 01, 2012 15.00):
Well, it took me a long time to check back in, so you may already have solved your problem. If not, here is a script I wrote awhile ago that drops objects onto a surface:
Option Explicit
'Script written by Damon Sidel
'Script copyrighted by Damon Sidel
'Script version Monday, May 09, 2011
Call DropOntoSurface()
Sub DropOntoSurface()
'Get surface to populate
Dim strSrf : strSrf = Rhino.GetObject("Select the surface to be populated")
If IsNull(strSrf) Then Exit Sub
'Get the points to drop
Dim arrObj : arrObj = Rhino.GetObjects("Select the objects to drop")
If IsNull(arrObj) Then Exit Sub
Call Rhino.EnableRedraw(False)
'Create jittery grid
Dim obj, k, x, y, z, line, csX, BB, p1, p2
For Each obj In arrObj
'Object information
BB = Rhino.BoundingBox(obj)
p1 = Array((BB(0)(0)+BB(2)(0))/2, (BB(0)(1)+BB(2)(1))/2, (BB(0)(2)+BB(2)(2))/2)
'Find point on surface to insert block
line = Rhino.AddLine(p1,Array(p1(0),p1(1),0))
csX = Rhino.CurveSurfaceIntersection(line,strSrf)
If IsArray(csX) Then
For k = 0 To UBound(csX)
If csX(k,0) = 1 Then
p2 = csX(k,3)
Call Rhino.MoveObject(obj,p1,p2)
Else
Rhino.Print "Intersection is not a point"
End If
Next
End If
Call Rhino.DeleteObject(line)
Next
Call Rhino.EnableRedraw(True)
End Sub
-
5. Aleksandar (Jan 17, 2012 15.11):
All I need to do is select an existing array of blocks (which are situated above the plane), and move them to the plane as shown in the image below.
-
4. ledisnomad (Jan 17, 2012 14.24):
Can you tell me what you are trying to accomplish? The script was rather specific for my personal needs at the time. It randomly distributes two blocks called "tree01" and "tree02" onto the surface. If you tell me what you want to do, I'd be happy to adjust the script so it works for you, but I need more info than just "It stops working..." Below is a more general purpose script a friend created that you can try, or feel free to let me know what functionality you are looking for and I'll try to help:
Option Explicit
'Script written by Trevor Patt
'Script licensed under Creative Commons license
'any use, alteration, or redistribution is permitted under the following
'restrictions: derivative works must made open under an identical license
'Script written for GSD RVB_Workshop_1. (1106-08)
Call CopyToSurface()
Sub CopyToSurface()
Dim objID, srfID, intNum, stPt, enPT, rndUV(1)
Dim domU, domV
objID = Rhino.GetObject("Select object to copy")
If IsNull(objID) Then Exit Sub
srfID = Rhino.GetObject("Select surface",8)
If IsNull(srfID) Then Exit Sub
intNum = Rhino.GetInteger("How many copies?",100)
If IsNull(intNum) Then Exit Sub
Call Rhino.HideObject(srfID)
Call Rhino.EnableRedraw(False)
stPt = Rhino.SurfaceVolumeCentroid(objID)
domU = Rhino.SurfaceDomain(srfID,0)
domV = Rhino.SurfaceDomain(srfID,1)
Dim i
For i=0 To intNum
rndUV(0) = Rnd*(domU(1)-domU(0)) + domU(0)
rndUV(1) = Rnd*(domV(1)-domV(0)) + domV(0)
enPT = Rhino.EvaluateSurface(srfID,rndUV)
Call Rhino.CopyObject(objID,stPt(0),enPt)
Next
Call Rhino.EnableRedraw(True)
End Sub
-
3. Aleksandar (Jan 17, 2012 10.36):
Thanks for the help, but I have a problem
It stops working afetr I enter number in U and V direction...
-
2. ledisnomad (Jan 16, 2012 20.41):
Hey Aleksandear, You could try my "Insert Block On Surface". Looks like you have an even grid of objects. Is that what you want? What is your ultimate goal?
-
1. Aleksandar (Jan 12, 2012 19.32):
Hi,
I am trying to move many objects down to the deformed surface, but in a way that every object just touches it with one end; without intersection and keeping all faces without intersection with the bottom surface, or deformation (as in extrude to object command...)
Sketchup already has a script like this (see picture)
Is there anything like this in Rhinoscript?
Regards,
Aleksandar