surface Offset+Connection

	Option Explicit
	'Script written by onur yuce gun
	'Script copyrighted by
	'Script version Tuesday, December 15, 2009 10:28:40 AM
Dim uNum
Dim vNum

	Call Main()
Sub Main()
	Dim mySrf
	Dim mySrf1
	uNum = Rhino.GetInteger ("enter u division number",10)
	vNum = Rhino.GetInteger ("enter v division number",20)
	mySrf = rhino.GetObject("select surface")
	mySrf1 = rhino.OffsetSurface (mySrf,16)
	rhino.EnableRedraw False
	'get the surface points from the first function
	Dim srfPt
	Dim srfPt1
	srfPt =	uvPts(mySrf,uNum,vNum)
	srfPt1 =	uvPts(mySrf1,uNum,vNum)
	'create xBrace on the uv grid
	Dim xBr
	Dim xBr1
	xBr = xBrace(srfPt)
	xBr1 = xBrace(srfPt1)
	'create sub syrface
	Dim sSrf
	'sSrf = subSrf(srfPt)
	Dim i,j
	For i = 0 To uNum
		For j = 0 To vNum
			rhino.AddLine srfPt(i,j),srfPT1(i,j)
		Next
	Next

	rhino.EnableReDraw True
End Sub
Function uvPts(srf, uDiv, vDiv)
	'find the surface domain
	Dim srfDomU
	Dim srfDomV
	srfDomU = Rhino.SurfaceDomain(srf,0)
	srfDomV = Rhino.SurfaceDomain(srf,1)
	'define parameter variables
	Dim parU
	Dim parV
	Dim parUV
	'all points array
	Dim allPt
	ReDim allPt (uDiv,vDiv)
	'counters
	Dim i,j
	For i = 0 To uDiv
		For j = 0 To vDiv
			parU = (srfDomU(1)/uDiv)*i
			parV = (srfDomV(1)/vDiv)*j
			parUV = Array(parU,parV)
			allPt(i,j) = Rhino.EvaluateSurface (srf, parUV)
			rhino.AddPoint allPt(i,j)
		Next
	Next
	uvPts = allPt
End Function
Function xBrace(ptArray)
	rhino.AddLayer "xBrace"
	Dim m
	Dim n
	Dim a1
	Dim a2
	For m = 0 To uNum-1
		For n = 0 To vNum-1
			a1 = rhino.AddLine (ptArray(m,n), ptArray(m+1,n+1))
			a2 = rhino.AddLine (ptArray(m+1,n), ptArray(m,n+1))
			rhino.ObjectLayer a1, "xBrace"
			rhino.ObjectLayer a2, "xBrace"
		Next
	Next
End Function
Advertisement

~ by onuryucegun on 2009/12/29.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.