rendered image of the first simple VB script in Rhino. surface is created via lofted set of curves and populated with user defined spheres on x and y axis with a chosen radius.
'Get the number of points on Y axis
nY = Rhino.GetInteger("Number on Y axis", 2, 2)
If IsNull(nY) Then Exit Sub
nY = nY - 1for script details read more.
as you can see the script itself is very simple and i have separated all sections for clearer understanding as i am still in the process of learning inner workings of scripting. for those of you who are also getting to grips with what each piece of code does, i hope you will find this useful.
Project 1 - BojaForm
Option Explicit
'Script written by Shane Gregoran
'Script copyrighted by sinQb
'Script version 1.2. april 2010 20:28:14
Call Project1BojaForm()
Sub Project1BojaForm()
'Collect data on curves to loft
Const rhObjectCurve = 4
Dim arrObjects
arrObjects = Rhino.GetObjects("select curves to loft", rhObjectCurve )
If IsArray(arrObjects) And UBound(arrObjects) > 0 Then
Rhino.AddLoftSrf arrObjects
End If
'Parametrs used for making a uv grid on surface
Dim nX, nY, strSurface
Dim u, v, a, b, arrUV(1), arrPt, R
'Get the surface object
strSurface = Rhino.GetObject("Select surface", 8)
If IsNull(strSurface) Then Exit Sub
'Get the number of points on Y axis
nY = Rhino.GetInteger("Number on Y axis", 2, 2)
If IsNull(nY) Then Print "Set to 2"
nY = 2
nY = nY - 1
End If
'Get the number of points on X axis
nX = Rhino.GetInteger("Number on X axis", 2, 2)
If IsNull(nX) Then Print "Set to 2"
nX = 2
nX = nX - 1
End If
'Choose R value of Spheres
R = Rhino.GetInteger("Radius of Spheres", 2, 1)
If IsNull(R) Then Print "Set to 1"
R=1
End If
'Get the domain of the surface
u = Rhino.SurfaceDomain(strSurface, 0)
v = Rhino.SurfaceDomain(strSurface, 1)
If Not IsArray(U) Or Not IsArray(V) Then Exit Sub
'Add the points
For a = 0 To nY
arrUV(0) = u(0) + (((u(1) - u(0)) / nY) * a)
For b = 0 To nX
arrUV(1) = v(0) + (((v(1) - v(0)) / nX) * b)
arrPt = Rhino.EvaluateSurface(strSurface, arrUV)
'replace points with Spheres of R radius
If (Rhino.IsPointOnSurface(strSurface, arrPt) = True) Then
Call Rhino.AddSphere (arrPt, R)
End If
Next
Next
End Sub
This comment has been removed by the author.
ReplyDeleteKako zaobići if&end
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete