
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cwwang.com &#187; Rhinoscript</title>
	<atom:link href="http://cwwang.com/category/software/rhinoscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://cwwang.com</link>
	<description>Che-Wei Wang</description>
	<lastBuildDate>Thu, 08 Jul 2010 15:02:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Sprocket Rhinoscript</title>
		<link>http://cwwang.com/2009/04/01/sprocket-rhinoscript/</link>
		<comments>http://cwwang.com/2009/04/01/sprocket-rhinoscript/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 05:15:09 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[Mechanisms]]></category>
		<category><![CDATA[Rhinoscript]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://cwwang.com/?p=1071</guid>
		<description><![CDATA[UPDATE: this script generates inaccurately spaced teeth. sorry! fixes in new version coming soon. (6.25.09) Here&#8217;s some basic rhinoscript code to draw your own sprockets based on the number of desired teeth, chain pitch and roller diameter. It&#8217;s very basic, but enough to draw what you want and get some custom sprockets lasercut. Draw a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cwwang.com/wordpress/wp-content/uploads/sprockets-converted-01.png" rel="lightbox[1071]" title="sprockets-converted-01" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/sprockets-converted-01.thumbnail.png" alt="sprockets-converted-01" width="128" height="91" class="attachment wp-att-1072 " /></a></p>
<p>UPDATE: this script generates inaccurately spaced teeth. sorry!  fixes in new version coming soon. (6.25.09)</p>
<p>Here&#8217;s some basic rhinoscript code to draw your own sprockets based on the number of desired teeth, chain pitch and roller diameter. It&#8217;s very basic, but enough to draw what you want and get some custom sprockets lasercut.  Draw a circle that&#8217;s larger than what you think it&#8217;s going to be in top view, then run the code.<br />
<span id="more-1071"></span></p>
<pre><code>Option Explicit
'Script written by cw wang
'based on sprocket drawing instructions from http://www.gizmology.net/sprockets.htm
'Script copyrighted by cwwang.com
'Script version Sunday, March 29, 2009 7:12:48 PM

Call Main()
Sub Main()
	Dim circle:circle=Rhino.getobject("select circle",4)
	Dim teeth:teeth=Rhino.GetInteger("number of teeth",10)
	Dim pitch:pitch=RHino.GetReal("pitch",.25)
	Dim rollerD:rollerD=RHino.GetReal("roller diameter",.13)

	Dim center:center=Rhino.CircleCenterPoint(circle)
	Dim	radius:radius=Rhino.CircleRadius(circle)

	Dim ln(2)
	Dim lnOff(3)
	ln(0)=Rhino.AddLine(center,array(center(0),center(1)+radius,center(2)))
	lnOff(0)=Rhino.OffsetCurve(ln(0),center,pitch/2,array(0,0,-1))(0)
	lnOff(1)=Rhino.OffsetCurve(ln(0),center,pitch/2,array(0,0,1))(0)

	ln(1)=Rhino.RotateObject(ln(0),center,(360/teeth),,True)
	Dim offsetDir:offsetDir=rhino.CurveEndPoint(ln(0))
	lnOff(2)=Rhino.OffsetCurve(ln(1),offsetDir,pitch/2)(0)
	ln(2)=Rhino.RotateObject(ln(0),center,-1*(360/teeth),,True)
	lnOff(3)=Rhino.OffsetCurve(ln(2),offsetDir,pitch/2)(0)

	'draw rollers
	Dim intersection1:intersection1=rhino.curvecurveIntersection(lnOff(0),lnOff(3))
	Dim plane1:plane1=rhino.planeFromNormal(intersection1(0,1),array(0,0,1))
	Dim roller1:roller1= rhino.AddCircle(plane1,rollerD/2)
	Dim intersection2:intersection2=rhino.curvecurveIntersection(lnOff(1),lnOff(2))
	Dim plane2:plane2=rhino.planeFromNormal(intersection2(0,1),array(0,0,1))
	Dim roller2:roller2= rhino.AddCircle(plane2,rollerD/2)
	Dim interLn:interLn=rhino.AddLine(intersection1(0,1),intersection2(0,1))	

	'draw circles
	Dim rollerLineIntersection1:rollerLineIntersection1=Rhino.CurveCurveIntersection(interLn,roller1)
	Dim r1:r1=Rhino.Distance(intersection2(0,1),rollerLineIntersection1(0,1))
	Dim circle1:circle1=Rhino.addCircle(plane1,r1)

	Dim rollerLineIntersection2:rollerLineIntersection2=Rhino.CurveCurveIntersection(interLn,roller2)
	Dim r2:r2=Rhino.Distance(intersection2(0,1),rollerLineIntersection2(0,1))
	Dim circle2:circle2=Rhino.addCircle(plane2,r1)

	Dim tootharc(3)
	'trim sharp part
	Dim tip:tip=Rhino.CurveCurveIntersection(circle1,circle2)
	Dim arrinterval(1)
	arrInterval(0)=Rhino.CurveClosestPoint(circle1,	tip(0,1))
	arrInterval(1)=RHino.CurveClosestPoint(circle1, rollerLineIntersection1(0,1))
	toothArc(0)=Rhino.TrimCurve(circle1,arrInterval,True)

	arrInterval(1)=Rhino.CurveClosestPoint(circle2,	tip(0,1))
	arrInterval(0)=RHino.CurveClosestPoint(circle2, rollerLineIntersection2(0,1))
	toothArc(1)=Rhino.TrimCurve(circle2,arrInterval,True)

	'trim valley
	Dim intersection:intersection=Rhino.CurveCurveIntersection(roller1,lnOff(3))
	arrinterval(0)=Rhino.CurveClosestpoint(roller1,rollerLineIntersection1(0,1))
	arrInterval(1)=RHino.CurveClosestPoint(roller1,	 intersection(1,1))
	toothArc(2)=Rhino.TrimCurve(roller1,arrInterval,True)

	intersection=Rhino.CurveCurveIntersection(roller2,lnOff(1))
	arrinterval(1)=Rhino.CurveClosestpoint(roller2,rollerLineIntersection2(0,1))
	arrInterval(0)=RHino.CurveClosestPoint(roller2,	 intersection(1,1))
	toothArc(3)=Rhino.TrimCurve(roller2,arrInterval,True)

	'delete stuff
	Call Rhino.DeleteObjects(ln)
	Call Rhino.DeleteObjects(lnOff)
	Call RHino.DeleteObject(interLn)

	Dim sprocketCrv()
	ReDim sprocketCrv(1)

	sprocketCrv(0)=Rhino.JoinCurves(toothArc,True)(0)

	Dim i
	For i=1 To teeth-1
		ReDim Preserve sprocketCrv(i)
		sprocketCrv(i)= Rhino.RotateObject(sprocketCrv(0),center,i*360/teeth,,True)
	Next

	Call Rhino.JoinCurves(sprocketCrv,True)

	Call Rhino.AddText(teeth,center,pitch)

	Call Rhino.addPoint(center)

End Sub</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2009/04/01/sprocket-rhinoscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sun Angle Script</title>
		<link>http://cwwang.com/2009/02/28/sun-angle-script/</link>
		<comments>http://cwwang.com/2009/02/28/sun-angle-script/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 19:00:43 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[Rhinoscript]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://cwwang.com/?p=1015</guid>
		<description><![CDATA[The following rhinoscript code calculates and draws a series of sun angles based on the time, day and latitude. NOTE: in my test there&#8217;s something happening to the angles around noon causing them to be inaccurate because the calculations are based on cos values. All other times besides noon should be fine. Updated version with [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cwwang.com/wordpress/wp-content/uploads/sun_angle.png" rel="lightbox[1015]" title="sun_angle" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/sun_angle.thumbnail.png" alt="sun_angle" width="128" height="83" class="attachment wp-att-1016 " /></a></p>
<p>The following rhinoscript code calculates and draws a series of  sun angles based on the time, day and latitude.<br />
NOTE: in my test there&#8217;s something happening to the angles around noon causing them to be inaccurate because the calculations are based on cos values. All other times besides noon should be fine.</p>
<p>Updated version with nicer UI from <a href="http://algorithmicdesign.net">Ezio</a>. Thank you!<br />
Download:<a href='http://cwwang.com/wordpress/wp-content/uploads/sunbatchrender_ezb.rvb'>sunbatchrender_ezb.rvb</a></p>
<p><span id="more-1015"></span></p>
<pre><code>Option Explicit
'Script written by cwwang.com augmented by algorithmicdesign.net
'Script version Sunday, March 01, 2009 9:39:09 PM

Call Main()
Sub Main()

	Dim i,j,k
	Dim hour
	Dim arrSettings : arrSettings   = getSunSettings()
	Dim longitude	: longitude		= CDbl(arrSettings(0))
	Dim latitude	: latitude		= CDbl(arrSettings(1))
	Dim offset		: offset		= CDbl(arrSettings(2))
	'day number --&gt; January 1 = day 1, January 2 = day 2, etc.
	'March equinox 78
	'September equinox 264
	'June solstice 171
	'Dec solstice 354
	Dim startDay	: startDay		= CDbl(arrSettings(3))
	Dim endDay		: endDay		= CDbl(arrSettings(4))
	Dim dayIncrement: dayIncrement 	= CDbl(arrSettings(5))
	Dim startHour   : startHour     = CDbl(arrSettings(6))
	Dim endHour		: endHour		= CDbl(arrSettings(7))
	Dim increment	: increment		= CDbl(arrSettings(8))
	'Dim increment	: increment		=.1666666666666666666666666666666' 10/60=.16666 every ten  minutes
	'Dim increment	: increment		=.01666666666666666666666666666666' 1/60=.016666 every minute
	Dim pathFolder 	: pathFolder 	= Rhino.BrowseForFolder(,"Pick a destination folder", "Output Folder")
	Dim nTimes		: nTimes     	=(endHour-startHour)/increment
	Dim nDays		: nDays      	=(endDay-startDay)/dayIncrement

	ReDim analemmaPoints(CInt(nTimes),CInt(nDays))
	'ReDim analemmaPoints(150,50)

	Call Rhino.EnableRedraw(False)

	Dim count:count=0
	For i=startDay To endDay

		Dim count2:count2=0
		Dim paz:paz=0
		Dim switchaz:switchaz=False

		hour=startHour
		For k=0 To (endHour-hour)/increment

			Dim N:N=i 

			Dim g:g = (360/365.242199)*(N + hour/24.0)
			'Rhino.Print(g)

			'calculation of the declination of the sun
			Dim	D:D = 0.396372-22.91327*cos(Rhino.ToRadians(g))+4.02543*sin(Rhino.ToRadians(g))-0.387205*cos(Rhino.ToRadians(2*g))+0.051967*sin(Rhino.ToRadians(2*g))-0.154527*cos(Rhino.ToRadians(3*g)) + 0.084798*sin(Rhino.ToRadians(3*g))
			'Rhino.Print("Declination "&amp;d)

			'calculate the time correction For solar angle:
			Dim TC:TC = 0.004297+0.107029*cos(Rhino.ToRadians(g))-1.837877*sin(Rhino.ToRadians(g))-0.837378*cos(Rhino.ToRadians(2*g))-2.340475*sin(Rhino.ToRadians(2*g))
			'Rhino.Print("Time Correction " &amp;tc)

			'calculate the Solar Hour Angle (SHA)
			Dim SHA:SHA = (hour+offset-12)*15 + Longitude + TC
			'rhino.Print("Solar Hour Angle "&amp;sha)

			'Note that If SHA Is greater than 180, Then you must add (-360) To the
			'result And If SHA Is lower than -180, Then you must add 360 To the
			If (SHA&gt;180) Then
				SHA=SHA-360
			ElseIf(SHA&lt;-180)Then
				SHA=SHA+360
			End If
			'calculate the Sun Zenith Angle (SZA):
			Dim SZA:SZA = (sin(Rhino.ToRadians(Latitude))*sin(Rhino.ToRadians(D)) )+ (cos(Rhino.ToRadians(Latitude))*cos(Rhino.ToRadians(D))*cos(Rhino.ToRadians(SHA)))
			'rhino.Print("cos(sza) "&amp;sza)

			'NOTE: If cos(SZA) formula gives a figure greater than 1 use 1 And If
			'it gives you a figure lower than -1 use -1.
			'Dim SSZA:SSZA=SZA
			If(SZA&gt;=1) Then
				SZA=1
			ElseIf(SZA&lt;=-1) Then
				SZA=-1
			End If

			sza=ArcCos(sza)
			'SZA Is the complementary angle of the Sun Elevation Angle Or
			Dim sea:sea=90-sza

			'calculate the Azimuth Angle (AZ):
			Dim AZ
			AZ = (sin(Rhino.ToRadians(D))-sin(Rhino.ToRadians(Latitude))*cos(Rhino.ToRadians(SZA) ) )/(cos(Rhino.ToRadians(Latitude))*sin(Rhino.ToRadians(SZA))) 

			az=arccos(az)

			If(paz&gt;az And switchaz=False)Then
				switchAz=True
			End If
			paz=az

			If(switchaz=True)Then
				az=0-az
			End If

			'rhino.Print("Azimuth Angle "&amp; az)
			'rhino.Print("Zenith Angle "&amp; sza)
			'rhino.Print("Altitude Angle "&amp; sea)

			Dim ray:ray=Rhino.AddLine( Array(0,0,0),array(0,40,0) )
			ray= Rhino.RotateObject(ray,array(0,0,0),sea,array(1,0,0),False)
			ray= Rhino.RotateObject(ray,array(0,0,0),az,array(0,0,-1),False)

			analemmaPoints(count2,count)=rhino.CurveEndPoint(ray)
			Dim sun : sun = Rhino.AddDirectionalLight (rhino.CurveEndPoint(ray), rhino.CurveStartPoint(ray))
			Call BatchRender(i, k, pathFolder)
			Call Rhino.DeleteObject(sun)
			'Call rhino.AddText(cstr(hour),analemmaPoints(count),.04)
			count2=count2+1

			hour=hour+increment
			'Rhino.Print(hour)

		Next

		i=i+dayIncrement

		count=count+1

	Next
	'Call rhino.AddLine(analemmaPoints(0,0),analemmaPoints(0,1) )

	For i=0 To count2-1
		For j=0 To count-2			

			'Dim analemmaCurve:analemmaCurve=rhino.AddCurve(analemmaPoints(3),4 )
			Call rhino.AddLine(analemmaPoints(i,j),analemmaPoints(i,j+1) )
		Next	

	Next

	Call Rhino.EnableRedraw(True)
	Rhino.Print("---")
End Sub

Function ArcCos(ByVal X)
	If X &lt;&gt; 1 Then
		ArcCos =rhino.ToDegrees( Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1) )
	Else
		ArcCos = 0
	End If
End Function

Sub BatchRender(strDay, strHour, pathFolder)

	Dim FileName : FileName = Chr(34) &amp; pathFolder &amp; strDay &amp; "_" &amp; strHour &amp; ".jpg" &amp; Chr(34)
	Rhino.Command "-_Render "
	Rhino.Command "-_SaveRenderWindowAs " &amp; FileName &amp; " _Enter"
	Rhino.Command "-_CloseRenderWindow "
End Sub

Function getSunSettings()

	getSunSettings	= Null

	Dim arrSettings(8), arrPrompt(8)
	arrPrompt(0)   = "Longitude"
	arrPrompt(1)   = "Latitude"
	arrPrompt(2)   = "GMT"
	arrPrompt(3)   = "StartDay"
	arrPrompt(4)   = "EndDay"
	arrPrompt(5)   = "DayIncrement"
	arrPrompt(6)   = "StartHour"
	arrPrompt(7)   = "EndHour"
	arrPrompt(8)   = "HourIncrement"

	arrSettings(0) = Rhino.GetSettings(Rhino.InstallFolder &amp; "SunRender.ini", "SunRender", arrPrompt(0))
	If IsNull(arrSettings(0)) Then arrSettings(0) = -73.997
	arrSettings(1) = Rhino.GetSettings(Rhino.InstallFolder &amp; "SunRender.ini", "SunRender", arrPrompt(1))
	If IsNull(arrSettings(1)) Then arrSettings(1) = 40.73
	arrSettings(2) = Rhino.GetSettings(Rhino.InstallFolder &amp; "SunRender.ini", "SunRender", arrPrompt(2))
	If IsNull(arrSettings(2)) Then arrSettings(2) = 5
	arrSettings(3) = Rhino.GetSettings(Rhino.InstallFolder &amp; "SunRender.ini", "SunRender", arrPrompt(3))
	If IsNull(arrSettings(3)) Then arrSettings(3) = 0
	arrSettings(4) = Rhino.GetSettings(Rhino.InstallFolder &amp; "SunRender.ini", "SunRender", arrPrompt(4))
	If IsNull(arrSettings(4)) Then arrSettings(4) = 1
	arrSettings(5) = Rhino.GetSettings(Rhino.InstallFolder &amp; "SunRender.ini", "SunRender", arrPrompt(5))
	If IsNull(arrSettings(5)) Then arrSettings(5) = 5
	arrSettings(6) = Rhino.GetSettings(Rhino.InstallFolder &amp; "SunRender.ini", "SunRender", arrPrompt(6))
	If IsNull(arrSettings(6)) Then arrSettings(6) = 6.0
	arrSettings(7) = Rhino.GetSettings(Rhino.InstallFolder &amp; "SunRender.ini", "SunRender", arrPrompt(7))
	If IsNull(arrSettings(7)) Then arrSettings(7) = 18.0
	arrSettings(8) = Rhino.GetSettings(Rhino.InstallFolder &amp; "SunRender.ini", "SunRender", arrPrompt(8))
	If IsNull(arrSettings(8)) Then arrSettings(8) = 1
	'Dim increment	: increment		=.1666666666666666666666666666666' 10/60=.16666 every ten  minutes
	'Dim increment	: increment		=.01666666666666666666666666666666' 1/60=.016666 every minute
	'day number --&gt; January 1 = day 1, January 2 = day 2, etc.
	'March equinox 78
	'September equinox 264
	'June solstice 171
	'Dec solstice 354

	Dim arrReturnSettings : arrReturnSettings =	Rhino.PropertyListBox (arrPrompt,  arrSettings, "Please enter the appropriate values" ,"Sun Batch Render Settings")
	Dim i
	For i = 0 To Ubound(arrSettings)
		'write these settings to a file so that you don't have to re-enter them next time
		Rhino.SaveSettings Rhino.InstallFolder &amp; "SunRender.ini", "SunRender", arrPrompt(i), arrReturnSettings(i)
	Next

	getSunSettings = arrReturnSettings

End Function</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2009/02/28/sun-angle-script/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>MultiMesh</title>
		<link>http://cwwang.com/2008/08/09/multimesh/</link>
		<comments>http://cwwang.com/2008/08/09/multimesh/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 00:51:02 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[Rhinoscript]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://cwwang.com/?p=811</guid>
		<description><![CDATA[Rhino loves to crash when it attempts to mesh a large set of surfaces in one shot. This often happens when you go to render and Rhino has to mesh all the objects in the scene. The MultiMesh plugin meshes multiple objects one at a time. By meshing your enormous elaborately detailed scene before you [...]]]></description>
			<content:encoded><![CDATA[<p>Rhino loves to crash when it attempts to mesh a large set of surfaces in one shot.  This often happens when you go to render and Rhino has to mesh all the objects in the scene.  The MultiMesh plugin meshes multiple objects one at a time.  By meshing your enormous elaborately detailed scene before you render, you save time and your sanity. </p>
<p>Version:0.03<br />
<a href="http://cwwang.com/wordpress/wp-content/rhino/MultiMesh.rhp.zip">MultiMesh.rhp.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2008/08/09/multimesh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rhinoscript Sound Alert</title>
		<link>http://cwwang.com/2008/08/09/rhinoscript-sound-alert/</link>
		<comments>http://cwwang.com/2008/08/09/rhinoscript-sound-alert/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 22:04:57 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[Rhinoscript]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://cwwang.com/?p=804</guid>
		<description><![CDATA[Make your scripts beep at you when they&#8217;re done. add the following code at the end of &#8220;sub main&#8221;, right before &#8220;end sub&#8221; 'BEEP when done Dim objShell, strCommand 'change the path to any .wav file of your choice Dim strSoundFile : strSoundFile = "C:WINDOWSMediaNotify.wav" Set objShell = CreateObject("Wscript.Shell") strCommand = "sndrec32 /play /close " [...]]]></description>
			<content:encoded><![CDATA[<p>Make your scripts beep at you when they&#8217;re done.</p>
<p>add the following code at the end of &#8220;sub main&#8221;, right before &#8220;end sub&#8221;<br />
<span id="more-804"></span></p>
<pre><code>	'BEEP when done
	Dim  objShell, 	   strCommand

	'change the path to any .wav file of your choice
	Dim strSoundFile : strSoundFile = "C:WINDOWSMediaNotify.wav"

	Set objShell = CreateObject("Wscript.Shell")
	strCommand = "sndrec32 /play /close " &amp; chr(34) &amp; strSoundFile &amp; chr(34)
	objShell.Run strCommand, 0, True</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2008/08/09/rhinoscript-sound-alert/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Render Groups Plugin</title>
		<link>http://cwwang.com/2008/07/13/render-groups-plugin/</link>
		<comments>http://cwwang.com/2008/07/13/render-groups-plugin/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 00:58:40 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[Rhinoscript]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://cwwang.com/?p=793</guid>
		<description><![CDATA[Here&#8217;s a Rhino plugin that automates the task of rendering multiple views objects within a single Rhino file. Download Render_Groups.rhp (Version 066) Installation 1.Copy plugin file to a folder on your computer 2.Drag and drop plugin file into the Rhino viewport Instructions 1. Ungroup everything 2. Group objects you want to render (the plugin will [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a Rhino plugin that automates the task of rendering multiple views objects within a single Rhino file.<br />
<span id="more-793"></span><br />
Download<br />
<a href="http://cwwang.com/wordpress/wp-content/uploads/Render_Groups.rhp">Render_Groups.rhp</a> (Version 066)</p>
<p>Installation<br />
1.Copy plugin file to a folder on your computer<br />
2.Drag and drop plugin file into the Rhino viewport</p>
<p>Instructions<br />
1. Ungroup everything<br />
2. Group objects you want to render<br />
(the plugin will render all groups whether they are visible or not, embedded in another group, etc.<br />
so make sure you only group things that you want rendered)<br />
3. Run the command &#8220;RenderGroups&#8221;<br />
4. Pick a place to save renderings, pick the views you want, resolution, file name, etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2008/07/13/render-groups-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Excel Import to Rhinoscript</title>
		<link>http://cwwang.com/2008/04/08/excel-import-to-rhinoscript/</link>
		<comments>http://cwwang.com/2008/04/08/excel-import-to-rhinoscript/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 19:32:45 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[Rhinoscript]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Teaching]]></category>
		<category><![CDATA[Work in Progress]]></category>

		<guid isPermaLink="false">http://cwwang.com/?p=724</guid>
		<description><![CDATA[Example Rhinoscript to import excel files into variables. Option Explicit 'excel import to rhinoscript , che-wei wang 4.8.2008 'excel cell numbers begin with 1,1 (not 0,0) Call Main() Sub Main() Dim FileName, file, excel FileName = Rhino.OpenFileName("Select Excel File","Excel Files (*.xls)&#124;*.xls&#124;&#124;") If isNull(FileName) Then Exit Sub Set excel = CreateObject("Excel.Application") excel.Visible = True excel.Workbooks.Open(FileName) Set [...]]]></description>
			<content:encoded><![CDATA[<p>Example Rhinoscript to import excel files into variables.<br />
<span id="more-724"></span></p>
<pre><code>Option Explicit
'excel import to rhinoscript , che-wei wang 4.8.2008
'excel cell numbers begin with 1,1 (not 0,0)

Call Main()
Sub Main()
	Dim FileName, file, excel
	FileName = Rhino.OpenFileName("Select Excel File","Excel Files (*.xls)|*.xls||")
	If isNull(FileName) Then Exit Sub

	Set excel = CreateObject("Excel.Application")
	excel.Visible = True

	excel.Workbooks.Open(FileName)
	Set file = excel.ActiveSheet

	Dim x:x= file.Cells(1,2).Value

	Call Rhino.Print(x)

	excel.UserControl = True
End Sub
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2008/04/08/excel-import-to-rhinoscript/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Align to Point Rhinoscript</title>
		<link>http://cwwang.com/2008/03/15/align-to-point-rhinoscript/</link>
		<comments>http://cwwang.com/2008/03/15/align-to-point-rhinoscript/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 19:54:46 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[Comp Form]]></category>
		<category><![CDATA[Parametric Modeling]]></category>
		<category><![CDATA[Rhinoscript]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Teaching]]></category>
		<category><![CDATA[Work in Progress]]></category>

		<guid isPermaLink="false">http://cwwang.com/2008/03/15/align-to-point-rhinoscript/</guid>
		<description><![CDATA[A basic Rhinoscript to rotate surfaces to align their normal to a point. Option Explicit 'Script written by Che-Wei Wang 'Script version Friday, March 07, 2008 10:55:15 AM Call Main() Sub Main() 'select srfs to rotate Dim arrSurfaces:arrSurfaces=Rhino.GetObjects("select surfaces to rotate") 'select point Dim point:point=Rhino.GetPoint("select light source point") 'calcuate vector from point to each srf [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cwwang.com/wordpress/wp-content/uploads/rotatesurfacescript.jpg" title="rotatesurfacescript.jpg" rel="lightbox[677]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/rotatesurfacescript.thumbnail.jpg" width="128" height="60" alt="rotatesurfacescript.jpg" class="imageframe" /></a></p>
<p>A basic Rhinoscript to rotate surfaces to align their normal to a point.<br />
<span id="more-677"></span></p>
<pre><code>Option Explicit
'Script written by Che-Wei Wang
'Script version Friday, March 07, 2008 10:55:15 AM

Call Main()
Sub Main()
	'select srfs to rotate
	Dim arrSurfaces:arrSurfaces=Rhino.GetObjects("select surfaces to rotate")

	'select point
	Dim point:point=Rhino.GetPoint("select light source point")

	'calcuate vector from point to each srf
	Dim srf
	For Each srf In arrSurfaces
		'find center of each srf
		Dim arrCentroid:arrCentroid=Rhino.SurfaceAreaCentroid(srf)
		'arrCentroid(0) is the center point
		Dim lightVector:lightVector=Rhino.VectorCreate( point,arrCentroid(0) )		

		'calculate normal to srf
		Dim srfNormal:srfNormal=Rhino.SurfaceNormal( srf, Array(0,0) )
		'normalize vectors
		lightVector=Rhino.VectorUnitize(lightVector)
		srfNormal=Rhino.VectorUnitize(srfNormal)

		'calcuate dot product and convert to radians
		Dim Angle:Angle=acos(Rhino.VectorDotProduct( lightVector,srfNormal)) 

		'calculate rotation axis
		Dim rotAxis:rotAxis=Rhino.VectorCrossProduct(lightVector, srfNormal )

		'rotate srf by that angle
		Call Rhino.RotateObject(srf,arrCentroid(0),360-Rhino.toDegrees(angle),rotAxis)

	Next	

End Sub</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2008/03/15/align-to-point-rhinoscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basic Branching RhinoScript</title>
		<link>http://cwwang.com/2008/03/15/basic-branching-rhinoscript/</link>
		<comments>http://cwwang.com/2008/03/15/basic-branching-rhinoscript/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 19:41:58 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[Comp Form]]></category>
		<category><![CDATA[Parametric Modeling]]></category>
		<category><![CDATA[Rhinoscript]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Teaching]]></category>
		<category><![CDATA[Work in Progress]]></category>

		<guid isPermaLink="false">http://cwwang.com/2008/03/15/basic-branching-rhinoscript/</guid>
		<description><![CDATA[Option Explicit 'Script written by Che-Wei Wang 'Script version Friday, March 14, 2008 11:38:10 AM Call Main() Sub Main() ReDim arrStart(0) 'set startpoint arrStart(0)= array(0,0,0) 'call drawBraches Function with initial settings(arrStart startPostition, L initialLength, number of branches, number of generations) Call drawBranches(arrStart, 2, 2, 6) End Sub Function drawBranches( arrStart(), L, nBranches, generations) ReDim arrEndPoints(nBranches) [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cwwang.com/wordpress/wp-content/uploads/branching.jpg" title="branching.jpg" rel="lightbox[674]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/branching.thumbnail.jpg" width="128" height="103" alt="branching.jpg" class="imageframe" /></a><br />
<span id="more-674"></span></p>
<pre><code>Option Explicit
'Script written by Che-Wei Wang
'Script version Friday, March 14, 2008 11:38:10 AM

Call Main()
Sub Main()

	ReDim arrStart(0)
	'set startpoint
	arrStart(0)= array(0,0,0)
	'call drawBraches Function with initial settings(arrStart startPostition, L initialLength, number of branches, number of generations)
	Call drawBranches(arrStart, 2, 2, 6)

End Sub

Function drawBranches( arrStart(), L, nBranches, generations)
	ReDim arrEndPoints(nBranches)
	Dim k,j
	Dim arrEnd, strobject, branchCount
	'reset branch count
	branchCount=0
	'for each start point
	For k = 0 To uBound(arrStart)
		'draw branches
		For j=0 To nBranches-1
			'endpoint based on startpoint
			arrEnd=array(arrStart(k)(0),arrStart(k)(1)+L,arrStart(k)(2)+rnd*L)
			'add line
			strObject=rhino.addline(arrStart(k), arrEnd)
			'rotate line randomly between -30 and 30
			Call rhino.RotateObject(strObject, arrStart(k), rnd*60-30)	 		

			'save each branches endpoint in an array
			ReDim Preserve arrEndPoints(branchCount)
			arrEndPoints(branchCount)=	Rhino.CurveEndPoint(strObject)
			'keep a count of the number of branches drawn
			branchCount=branchCount+1								     		

		Next
	Next

	'exit loop if generations=0
	If generations&gt;0 Then
		'recursive call with endpoints as startpoints, modified length, number of branches, and generation count-1
		Call drawBranches(arrEndPoints, l*.85, nBranches , generations-1)
	End If				

End Function</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2008/03/15/basic-branching-rhinoscript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MultiPipe</title>
		<link>http://cwwang.com/2007/06/26/multipipe/</link>
		<comments>http://cwwang.com/2007/06/26/multipipe/#comments</comments>
		<pubDate>Tue, 26 Jun 2007 22:11:04 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Rhinoscript]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://cwwang.com/wordpress/2007/06/26/multipipe/</guid>
		<description><![CDATA[MultiPipe is a simple plugin for Rhino 4.0 to pipe multiple curves at once with start and end diameter options and cap type options. Unzip and install by dragging the plugin into Rhino. The command line for the tool is &#8220;MultiPipe&#8217;. Download: multipipe04.zip]]></description>
			<content:encoded><![CDATA[<p>MultiPipe is a simple plugin for Rhino 4.0 to pipe multiple curves at once with start and end diameter options and cap type options. Unzip and install by dragging the plugin into Rhino.  The command line for the tool is &#8220;MultiPipe&#8217;.</p>
<p>Download: <a href="http://cwwang.com/wordpress/wp-content/uploads/MultiPipe04.rhp.zip" title="multipipe.zip">multipipe04.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2007/06/26/multipipe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Seroussi Pavillion</title>
		<link>http://cwwang.com/2007/04/19/seroussi-pavillion/</link>
		<comments>http://cwwang.com/2007/04/19/seroussi-pavillion/#comments</comments>
		<pubDate>Thu, 19 Apr 2007 16:38:53 +0000</pubDate>
		<dc:creator>che-wei wang</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Parametric Modeling]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Rhinoscript]]></category>

		<guid isPermaLink="false">http://cwwang.com/wordpress/2007/04/19/seroussi-pavillion/</guid>
		<description><![CDATA[Here are some images from a collaboration with biothing. My focus was on developing the outer tiling module. The facted skylight is modulated with intersecting sin wave functions in relation to nodes of interest distributed across the site. Rhinoscript 'component surface array 'cw wang'modified from 'skin panel prototype 'joshua vermillion Dim sourceSurface, uDiv, vDiv, height, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cwwang.com/wordpress/wp-content/uploads/biothing_roof_001.jpg" title="biothing_roof_001.jpg" rel="lightbox[404]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/biothing_roof_001.thumbnail.jpg" alt="biothing_roof_001.jpg" class="imageframe" height="96" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/biothing_roof_0021.jpg" title="biothing_roof_0021.jpg" rel="lightbox[404]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/biothing_roof_0021.thumbnail.jpg" alt="biothing_roof_0021.jpg" class="imageframe" height="96" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/biothing_roof_003.jpg" title="biothing_roof_003.jpg" rel="lightbox[404]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/biothing_roof_003.thumbnail.jpg" alt="biothing_roof_003.jpg" class="imageframe" height="96" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/biothing_roof_004.jpg" title="biothing_roof_004.jpg" rel="lightbox[404]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/biothing_roof_004.thumbnail.jpg" alt="biothing_roof_004.jpg" class="imageframe" height="96" width="128" /></a></p>
<p>Here are some images from a collaboration with <a href="http://biothing.org/wiki/doku.php?id=seroussi">biothing</a>.  My focus was on developing the outer tiling module.  The facted skylight is modulated with intersecting sin wave functions in relation to nodes of interest distributed across the site.</p>
<p><span id="more-404"></span></p>
<p><a href="http://cwwang.com/wordpress/wp-content/uploads/biothing_roof_005.jpg" title="biothing_roof_005.jpg" rel="lightbox[404]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/biothing_roof_005.thumbnail.jpg" alt="biothing_roof_005.jpg" class="imageframe" height="96" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/electric-line-charge-with-components-03-v3maxwell-r01.jpg" title="electric-line-charge-with-components-03-v3maxwell-r01.jpg" rel="lightbox[404]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/electric-line-charge-with-components-03-v3maxwell-r01.thumbnail.jpg" alt="electric-line-charge-with-components-03-v3maxwell-r01.jpg" class="imageframe" height="96" width="128" /></a></p>
<p><a href="http://cwwang.com/wordpress/wp-content/uploads/img_0211.jpg" title="img_0211.jpg" rel="lightbox[404]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/img_0211.thumbnail.jpg" alt="img_0211.jpg" class="imageframe" height="96" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/img_0212.jpg" title="img_0212.jpg" rel="lightbox[404]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/img_0212.thumbnail.jpg" alt="img_0212.jpg" class="imageframe" height="96" width="128" /></a></p>
<p><a href="http://cwwang.com/wordpress/wp-content/uploads/seroussi-house-r07-gf-pink.jpg" title="seroussi-house-r07-gf-pink.jpg" rel="lightbox[404]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/seroussi-house-r07-gf-pink.thumbnail.jpg" alt="seroussi-house-r07-gf-pink.jpg" class="imageframe" height="96" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/seroussi-house-r08-gf-pink.jpg" title="seroussi-house-r08-gf-pink.jpg" rel="lightbox[404]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/seroussi-house-r08-gf-pink.thumbnail.jpg" alt="seroussi-house-r08-gf-pink.jpg" class="imageframe" height="96" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/seroussi-house-r09-gf-pink.jpg" title="seroussi-house-r09-gf-pink.jpg" rel="lightbox[404]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/seroussi-house-r09-gf-pink.thumbnail.jpg" alt="seroussi-house-r09-gf-pink.jpg" class="imageframe" height="96" width="128" /></a><a href="http://cwwang.com/wordpress/wp-content/uploads/seroussi-house-r10-gf-pink.jpg" title="seroussi-house-r10-gf-pink.jpg" rel="lightbox[404]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/seroussi-house-r10-gf-pink.thumbnail.jpg" alt="seroussi-house-r10-gf-pink.jpg" class="imageframe" height="96" width="128" /></a></p>
<p><a href="http://cwwang.com/wordpress/wp-content/uploads/roofplan.jpg" aiotarget="false" aiotitle="roofplan.jpg" rel="lightbox[404]" rel="lightbox"><img src="http://cwwang.com/wordpress/wp-content/uploads/roofplan.thumbnail.jpg" alt="roofplan.jpg" class="imageframe" height="190" width="128" /></a></p>
<p>Rhinoscript</p>
<pre><code>
'component surface array

'cw wang</code>'modified from

'skin panel prototype

'joshua vermillion

Dim sourceSurface, uDiv, vDiv, height, grid

Dim uStep, vStep

Dim uVal, vVal

Dim width

Dim depth

Dim  ap1,ap2,ap3,ap4,ap5

Dim  ap1n,ap2n,ap3n,ap4n,ap5n

Dim yTilt

Dim xTilt

Dim xTmin

Dim xTmax

Dim yTmin

Dim yTmax

Dim yStep

Dim offset

Dim splitWidth

Dim parentLayer

Dim midCurve

Dim midSurface

Dim componentColor : componentColor = RGB(125,125,125)

Dim underCocoon

Dim overCocoon

Dim court

Dim sinMult

Dim locator

Dim locatorMidDist

Sub panel

Dim i, j ,k

Dim sourceCurves

 'Prompt user for input data

 'sourceSurface = Rhino.GetObject("Select a surface to populate", 8,, True)

 parentLayer = Rhino.GetString("Enter layer number",1)

 sourceCurves = Rhino.GetObjects("Select curves", 4,, True)

Dim componentType : componentType =  Rhino.ListBox(Array("Exterior","Mesh"),"Select Component Type")

Dim vertBool	: vertBool = Rhino.GetBoolean("Build vertical?", Array("Build", "horizontal", "vertical"),Array(False))

 Dim louvres : louvres = Rhino.GetBoolean("Build courtyard louvres?", Array("Build", "no", "yes"),Array(False))

 locator= Rhino.GetPoint("select locator point")

'uDiv = Rhino.GetInteger("Enter the number of divisions in the U direction", 1, 1)

 uDiv = 1

 If componentType = "Mesh"  Then

 	vDiv = Rhino.GetInteger("Enter the number of divisions in the V direction", 5, 1)

 	'	height = Rhino.GetReal("Enter a height multiplier ", 2)

 	height=2

 	'		xTmin =  Rhino.GetReal("Enter x tilt minimum(0-1)", .7)

 	'		xTmax =  Rhino.GetReal("Enter x tilt maximum(0-1)", .8)

 	'

 	'		yTmin =  Rhino.GetReal("Enter Y tilt minimum(0-1)", .4)

 	'		yTmax =  Rhino.GetReal("Enter Y tilt maximum(0-1)", .45)

 	'

 	xTmin = .7

 	xTmax =   .8

yTmin = .4

 	yTmax =.45

End If

If componentType = "Exterior"  Then

 	vDiv = Rhino.GetInteger("Enter the number of divisions in the V direction", 60, 1)

 	'vDiv=60

 	'height = Rhino.GetReal("Enter a height multiplier ", .2)

 	'sinMult = Rhino.GetReal("Enter a Sin multiplier ", 3)

 	sinMult =3

'splitWidth = Rhino.GetReal("Enter split width", 15)

 	splitWidth =15

 	'xTmin =  Rhino.GetReal("Enter x tilt minimum(0-1)", .1)

 	'xTmax =  Rhino.GetReal("Enter x tilt maximum(0-1)", .9)

 	xTmin=.1

 	xTmax=.9

 	'yTmin =  Rhino.GetReal("Enter Y tilt minimum(0-1)", .3)

 	'yTmax =  Rhino.GetReal("Enter Y tilt maximum(0-1)", .9)

 	yTmin=.2

 	yTmax=.9

 	'offset =  Rhino.GetReal("Enter component offset (0-1)", .05)

 	offset=.02

 	height =.1

End If

If componentType = "Transition"  Then

 	vDiv = Rhino.GetInteger("Enter the number of divisions in the V direction", 80, 1)

 	height = Rhino.GetReal("Enter a height multiplier ", .02)

splitWidth = Rhino.GetReal("Enter split width", 30)

 	'xTmin =  Rhino.GetReal("Enter x tilt minimum(0-1)", .1)

 	'xTmax =  Rhino.GetReal("Enter x tilt maximum(0-1)", .9)

 	xTmin=.2

 	xTmax=.5

 	'yTmin =  Rhino.GetReal("Enter Y tilt minimum(0-1)", .3)

 	'yTmax =  Rhino.GetReal("Enter Y tilt maximum(0-1)", .9)

 	yTmin=.9

 	yTmax=.9

 	'offset =  Rhino.GetReal("Enter component offset (0-1)", .05)

 	offset=.1

 End If

 If componentType = "Wall"  Then

 	vDiv = Rhino.GetInteger("Enter the number of divisions in the V direction", 60, 1)

 	height = Rhino.GetReal("Enter a height multiplier ", .4)

xTmin =  Rhino.GetReal("Enter x tilt minimum(0-1)", .1)

 	xTmax =  Rhino.GetReal("Enter x tilt maximum(0-1)", .8)

yTmin =  Rhino.GetReal("Enter Y tilt minimum(0-1)", .1)

 	yTmax =  Rhino.GetReal("Enter Y tilt maximum(0-1)", .8)

splitWidth = Rhino.GetReal("Enter split width", 8)

 	offset =  Rhino.GetReal("Enter component offset (0-1)", .05)

 End If

'Dim flip : flip = Rhino.GetBoolean("Flip U and V?", Array("Flip","U,V", "V,U"),Array(False))

 '	Dim showDraw : showDraw =  Rhino.GetBoolean("Show or Hide construction?", Array("Construction","Hide", "Show"), Array(True))

'loft curves

If vertBool(0)=True	 Then

 	ReDim sourceSurface(UBound(sourceCurves)-2)

Dim a: a=0

 	For i=0 To UBound(sourceSurface)

Dim scArrV : scArrV = Array(sourceCurves(i),sourceCurves(i+2))

 		CheckLayerParent "construction"

 		sourceSurface(i)  = Rhino.AddEdgeSrf(scArrV)

 		'sourceSurface(i)  =Rhino.AddLoftSrf (scArrV ,  ,  , 3 , 1 )

 		Rhino.Command "SelNone"

 		Rhino.LastCreatedObjects  True

 		Rhino.Command "Reparameterize 0 1 0 1 "

a=a+2

Next

Else

 	ReDim sourceSurface(UBound(sourceCurves)-1)

 	For i=0 To 	UBound(sourceSurface )

 		Dim scArr : scArr = Array(sourceCurves(i),sourceCurves(i+1))

CheckLayerParent "construction"

 		sourceSurface(i)  = Rhino.AddEdgeSrf(scArr)

Rhino.Command "SelNone"

 		Rhino.LastCreatedObjects  True

 		Rhino.Command "Reparameterize 0 1 0 1 "

Next

 End If

'	If cocoonBool(0) = True Then

 '

 '		For i=0 To UBound(sourceCurves)-1

 '			CheckLayerParent "construction"

 '			Dim sourceSurfaceM : sourceSurfaceM  = Rhino.AddEdgeSrf(Array(sourceCurves(1),sourceCurves(3)))

 '

 '			Rhino.Command "SelNone"

 '			Rhino.LastCreatedObjects  True

 '			Rhino.Command "Reparameterize 0 1 0 1 "

 '

 '			'		Dim arrDomU :	arrDomU = Rhino.SurfaceDomain(sourceSurfaceM, 0)

 '			'		Dim u0 :	u0 = arrDomU(0)+.5

 '			'		Dim u1 :	u1 = arrDomU(1)-.5

 '			'		Dim arrDomV:	arrDomV = Rhino.SurfaceDomain(sourceSurfaceM, 1)

 '			'		Dim v0:v0 = arrDomV(0)

 '			'		Dim v1: v1 = arrDomV(1)

 '			'		CheckLayerParent "construction"

 '			'		midCurve=Rhino.AddInterpCrvOnSrfUV(sourceSurfaceM,Array(Array(u0,v0), Array(u1,v1)))

 '			'

 '

 '			'

 '

 '

 '			'		For j=0 To 	UBound(midCurve)-1

 '			'			CheckLayerParent "construction"

 '			'			midSurface(j)  = Rhino.AddEdgeSrf(Array(midCurve(j),midCurve(j+1)))

 '			'			Rhino.Command "SelNone"

 '			'			Rhino.LastCreatedObjects  True

 '			'			Rhino.Command "Reparameterize 0 1 0 1 "

 '			'		Next

 '

 '			End If

ReDim ap1<sup>1</sup>

 ReDim ap2<sup>2</sup>

 ReDim ap3<sup>3</sup>

 ReDim ap4<sup>4</sup>

 ReDim ap5<sup>5</sup>

ReDim ap1n<sup>6</sup>

 ReDim ap2n<sup>7</sup>

 ReDim ap3n<sup>8</sup>

 ReDim ap4n<sup>9</sup>

 ReDim ap5n<sup>10</sup>

ReDim underCocoon<sup>11</sup>

 ReDim overCocoon<sup>12</sup>

'Redimension the arrays that will hold all the values of U and V to the number of tiles in each direction

 ReDim uVal(uDiv)

 ReDim vVal(vDiv)

'Find the step value, i.e. the distance between tiles in each direction. (note: this is not the euclidian distance, it is the distance measured in UV space)

 uStep = 1/uDiv

 vStep = 1/vDiv

'Fill the arrays with the actual values of U and V at each step

 For i = 0 To uDiv

 	uVal(i) = i * uStep

 	'Rhino.Print "uVal(" &amp; i &amp; "):" &amp; uVal(i)

 Next

For i = 0 To vDiv

 	vVal(i) = i * vStep

'Rhino.Print "vVal(" &amp; i &amp; "):" &amp; vVal(i)

 Next

'Disable Rhino from redrawing the views during the tile construction to speed things up

 '	If showDraw(0) = False Then

 '		Rhino.EnableRedraw vbFalse

 '		Rhino.Print "Populating component..."

 '	End If

'Start looping through each u and v division and create the tile within

If componentType = "Wall"  Then

 	Dim UB : UB=	 UBound(sourceSurface)/2

Else

 	UB=	 UBound(sourceSurface)

 End If

For k = 0 To UB

 	yStep = 0

 	xStep = 0

For i = 0 To uDiv-1

 		For j = 0 To vDiv-1

'Find the 3D coordinate for each of the 4 corners of the tile using the UV coordinates as input

 			Dim topLeft :topLeft=	Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)))

 			Dim topRight : topRight = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+1, vVal(j)))

 			Dim bottomLeft : bottomLeft = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j+1)))

width =  Rhino.Distance(topLeft,topRight)

 			depth =  Rhino.Distance(topLeft,bottomLeft)

Dim curveMid:CurveMid=Rhino.EvaluateSurface(sourceSurface(k),Array(uVal(uDiv/2), vVal(vDiv/2)))

 			locatorMidDist=Rhino.Distance(Array(curveMid(0),curveMid(1),curveMid(2)),locator)

If componentType = "Wall"  Then

 				Dim top :top=	Rhino.EvaluateSurface(sourceSurface(k*2), Array(uVal(i), vVal(j)))

 				Dim bottom : bottom = Rhino.EvaluateSurface(sourceSurface(k*2+1),Array(uVal(i), vVal(j)))

 				height=Rhino.Distance(top,bottom)

 				wallComponent i,j,k*2,sourceSurface

End If

If componentType = "Mesh"  Then

meshComponent i,j,k,sourceSurface

End If

'					For m = 0 To 1

 			'						height=height*-1

 			'

If componentType = "Exterior" Or componentType="Transition"  Then

If width &gt;splitWidth Then

 					For p=0 To 1

 						uVal(0)=p/2

 						uVal(1)=1/2

 						extComponent i,j,k

 					Next

 				End If

If width<splitwidth></splitwidth>

If louvres(0)=True   Then

 						louvreComponent i,j,k

 						louvres(0)=False

 					Else

uVal(0)=0

 						uVal(1)=1

 						extComponent i,j,k

End If

Else

 					If width <splitwidth>

 						uVal(0)=0

 						uVal(1)=1

 						extComponent i,j,k

 					End If</splitwidth>

End If

 			End If

Next

 	Next

 Next

Rhino.DeleteObjects (sourceSurface)

Dim YN2:YN2= Rhino.MessageBox ("Delete construction lines?"  , 4)

 If YN2 =6 Then

 	Rhino.PurgeLayer ("construction")

 	'			Rhino.DeleteObjects(underCocoon(0,RandomNumber(0,UBound(underCocoon))))

 	'			Rhino.DeleteObjects(overCocoon(0,RandomNumber(0,UBound(overCocoon))))

 End If

End Sub

panel

Function cocoonComponent (i,j,k,surfaceA)

 checkLayerParent(parentLayer)

yTilt = Sin(j/vDiv)

If yTilt&gt;yTmax Then

 	yTilt = yTmax

 End If

 If yTilt<ytmin></ytmin>

yTilt = yTmin

 End If

xTilt = Sin(j/vDiv)

If xTilt&gt;xTmax Then

 	xTilt = xTmax

 End If

If xTilt<xtmin>

 	xTilt = xTmin

 End If</xtmin>

Dim overC : overC = RGB(125,125,125)

Dim a0 : a0 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i), vVal(j)))

 Dim c0 : c0 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i)+uVal(1), vVal(j)))

 Dim c2 : c2 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i)+uVal(1), vVal(j+1)))

 Dim a2 : a2 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i), vVal(j+1)))

Dim b1 : b1 = Rhino.SurfaceCurvature(surfaceA(k), Array(uVal(i)+(uVal(1)*.5), vVal(j) + vVal(1)*(1-xTilt)))

 ap1(i,j) = offsetCalc(b1, height*.1)

 Dim bb1 : bb1 = Rhino.SurfaceCurvature(surfaceA(k), Array(uVal(i)+(uVal(1)*.5), vVal(j)+vVal(1)*xTilt ))

 ap2(i,j) = offsetCalc(bb1, height*.1)

ap3(i,j) = offsetCalc(b1, height/2)

 ap4(i,j) = offsetCalc(bb1, height/2)

Dim a0B : a0B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i), vVal(j)))

 Dim c0B : c0B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i)+uVal(1), vVal(j)))

 Dim c2B : c2B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i)+uVal(1), vVal(j+1)))

 Dim a2B : a2B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i), vVal(j+1)))

Dim b1B : b1B = Rhino.SurfaceCurvature(surfaceA	(k+1), Array(uVal(i)+(uVal(1)*.5), vVal(j) + vVal(1)*(1-xTilt)))

 ap1n(i,j) = offsetCalc(b1B, -height*.1)

Dim bb1B : bb1B = Rhino.SurfaceCurvature(surfaceA(k+1), Array(uVal(i)+(uVal(1)*.5), vVal(j)+vVal(1)*xTilt))

 ap2n(i,j) = offsetCalc(bb1B, -height*.1)

'based on curvature

 'ap1(i,j) = offsetCalc(cb2, height*cb2(7)*10)

 'ap2(i,j) = offsetCalc(cb4, height*cb4(7)*10)

'constant height

 'ap1(i,j) = offsetCalc(cb2, height)

 'ap2(i,j) = offsetCalc(cb4, height)

'based on width height

 'xTilt=.1

'	ap2(i,j) = offsetCalc(c0, height*(1-yTilt))

 '	ap3(i,j) = offsetCalc(d0, height*xTilt)

 '	ap4(i,j) = offsetCalc(e0, height*(1-yTilt))

 '	ap5(i,j) = offsetCalc(f0, height*yTilt)

 '

 '	ap1n(i,j) = offsetCalc(b1, height*yTilt)

 '	ap2n(i,j) = offsetCalc(c1, height*(1-yTilt))

 '	ap3n(i,j) = offsetCalc(d1, height)

 '	ap4n(i,j) = offsetCalc(e1, height*(1-yTilt))

 '	ap5n(i,j) = offsetCalc(f1, height*yTilt)

CheckLayerParent "construction"

 'Dim a2ap1c0 : a2ap1c0 = Rhino.AddArc3Pt(a2,c0,ap1(i,j))

 'Dim c4ap4e2 : c4ap4e2 = Rhino.AddArc3Pt(c4,e2,ap4(i,j))

 'Dim a0ap1ap2b3 : a0ap1ap2b3 = Rhino.AddNurbsCurve (Array(a0,ap1(i,j),ap2(i,j),b3),Array(-1,-.5,0,.5,1) ,2,Array(100,1,1,100))

 'Dim a0nap1fnap2fnb3n : a0nap1fnap2fnb3n = Rhino.AddNurbsCurve (Array(a0n,ap1fn(i,j),ap2fn(i,j),b3n),Array(-1,-.5,0,.5,1) ,2,Array(100,1,1,100))

'Dim a2ap1c0 : a2ap1c0 = Rhino.AddEllipse3Pt (a2,c0,ap1(i,j))

 'Dim c4ap4e2 : c4ap4e2 = Rhino.AddEllipse3Pt (c4,e2,ap4(i,j))

'	Dim a0a1: a0a1 = Rhino.AddLine(a0,a1)

'horiz

 'top

 Dim a0ap1c0 : a0ap1c0 = Rhino.AddNurbsCurve (Array(a0,ap1(i,j),c0),Array(0,0,1,1) ,2,Array(100,100,100))

 'bottom

 Dim a0Bap1nc0B : a0Bap1nc0B = Rhino.AddNurbsCurve (Array(a0B,ap1n(i,j),c0B),Array(0,0,1,1) ,2,Array(100,100,100))

 'vert

 'left

 Dim a0ap3a0B :  a0ap3a0B = 	Rhino.AddNurbsCurve (Array(a0,ap3(i,j),a0B),Array(0,0,1,1) ,2,Array(100,100,100))

 'right

 Dim c0ap3c0B :  c0ap3c0B = 	Rhino.AddNurbsCurve (Array(c0,ap3(i,j),c0B),Array(0,0,1,1) ,2,Array(100,100,100))

'horiz

 'top

 Dim a2ap2c2 : a2ap2c2 = Rhino.AddNurbsCurve (Array(a2,ap2(i,j),c2),Array(0,0,1,1) ,2,Array(100,100,100))

 'bottom

 Dim a2Bap2nc2B : a2Bap2nc2B = Rhino.AddNurbsCurve (Array(a2B,ap2n(i,j),c2B),Array(0,0,1,1) ,2,Array(100,100,100))

'vert

 'left

 Dim a2ap4a2B :  a2ap4a2B = 	Rhino.AddNurbsCurve (Array(a2,ap4(i,j),a2B),Array(0,0,1,1) ,2,Array(100,100,100))

 'right

 Dim c2ap4c2B :  c2ap4c2B = 	Rhino.AddNurbsCurve (Array(c2,ap4(i,j),c2B),Array(0,0,1,1) ,2,Array(100,100,100))

CheckLayer"Cocoon Component" , overC

 'overCocoon(i,j)=Rhino.AddLoftSrf(Array(a0a1,ap1ap1n,ap2ap2n,ap3ap3n))

'underCocoon(i,j)=Rhino.AddLoftSrf(Array(ap3ap3n,ap4ap4n,ap5ap5n,g0g1))

'	Rhino.AddEdgeSrf(Array(a0ap1c0, a0Bap1nc0B,a0ap3a0B, c0ap3c0B))

 '	Rhino.AddEdgeSrf(Array(a2ap2c2, a2Bap2nc2B,a2ap4a2B, c2ap4c2B))

 '	edgeSurface a0ap1c0,  a2ap2c2

 '	edgeSurface a0Bap1nc0B,  a2Bap2nc2B

 '	edgeSurface a0ap3a0B,  a2ap4a2B

 '	edgeSurface c0ap3c0B,  c2ap4c2B

'Rhino.AddLoftSrf Array(	a0ap3a0B, c0ap3c0B,c2ap4c2B,a2ap4a2B),,,,,,True

 edgeSurface  a0ap1c0, a2ap4a2B

edgeSurface   a2Bap2nc2B, c0ap3c0B

End Function

Function meshComponent (i,j,k,surface)

checkLayerParent(parentLayer)

yTilt = Sin(j/vDiv)

If yTilt&gt;yTmax Then

 	yTilt = yTmax

 End If

 If yTilt<ytmin></ytmin>

yTilt = yTmin

 End If

xTilt = Sin(1-j/vDiv)

If xTilt&gt;xTmax Then

 	xTilt = xTmax

 End If

If xTilt<xtmin></xtmin>

xTilt = xTmin

 End If

Dim overC : overC = RGB(125,125,125)

Dim a0 : a0 = Rhino.EvaluateSurface(surface(k), Array(uVal(i), vVal(j)))

 Dim g0 : g0 = Rhino.EvaluateSurface(surface(k), Array(uVal(i)+uVal(1), vVal(j)))

 Dim g1 : g1 = Rhino.EvaluateSurface(surface(k), Array(uVal(i)+uVal(1), vVal(j+1)))

 Dim a1 : a1 = Rhino.EvaluateSurface(surface(k), Array(uVal(i), vVal(j+1)))

Dim b0 : b0 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*.05), vVal(j)))

 Dim c0 : c0 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*yTilt), vVal(j)+vVal(1)*xTilt))

Dim d0 : d0 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*.5), vVal(j)))

 Dim e0 : e0 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*(1-yTilt)), vVal(j)+vVal(1)*xTilt))

Dim f0 : f0 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*.95), vVal(j)))

Dim b1 : b1 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*.05), vVal(j+1)))

 Dim c1 : c1 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*yTilt), vVal(j+1)-vVal(1)*xTilt))

Dim d1 : d1 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*.5), vVal(j+1)))

 Dim e1 : e1 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*(1-yTilt)), vVal(j+1)-vVal(1)*xTilt))

Dim f1 : f1 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*.95), vVal(j+1)))

ap1(i,j) = offsetCalc(b0, height*yTilt)

 ap2(i,j) = offsetCalc(c0, height*(1-yTilt))

 ap3(i,j) = offsetCalc(d0, height)

 ap4(i,j) = offsetCalc(e0, height*(1-yTilt))

 ap5(i,j) = offsetCalc(f0, height*yTilt)

ap1n(i,j) = offsetCalc(b1, height*yTilt)

 ap2n(i,j) = offsetCalc(c1, height*(1-yTilt))

 ap3n(i,j) = offsetCalc(d1, height)

 ap4n(i,j) = offsetCalc(e1, height*(1-yTilt))

 ap5n(i,j) = offsetCalc(f1, height*yTilt)

CheckLayerParent "construction"

Dim a0a1: a0a1 = Rhino.AddLine(a0,a1)

 Dim ap1ap1n:ap1ap1n = Rhino.AddLine(ap1(i,j),ap1n(i,j))

 Dim ap2ap2n:ap2ap2n = Rhino.AddLine(ap2(i,j),ap2n(i,j))

 Dim ap3ap3n:ap3ap3n = Rhino.AddLine(ap3(i,j),ap3n(i,j))

 Dim ap4ap4n:ap4ap4n = Rhino.AddLine(ap4(i,j),ap4n(i,j))

 Dim ap5ap5n:ap5ap5n = Rhino.AddLine(ap5(i,j),ap5n(i,j))

 Dim g0g1:g0g1 = Rhino.AddLine(g0,g1)

CheckLayer"Cocoon Component" , overC

 overCocoon(i,j)=Rhino.AddLoftSrf(Array(a0a1,ap1ap1n,ap2ap2n,ap3ap3n))

 underCocoon(i,j)=Rhino.AddLoftSrf(Array(ap3ap3n,ap4ap4n,ap5ap5n,g0g1))

End Function

Function wallComponent(i,j,k,surfaceA)

checkLayerParent(parentLayer)

yTilt = Sin(j/vDiv)

If yTilt&gt;yTmax Then

 	yTilt = yTmax

 End If

 If yTilt<ytmin></ytmin>

yTilt = yTmin

 End If

xTilt = Sin(j/vDiv)

If xTilt&gt;xTmax Then

 	xTilt = xTmax

 End If

If xTilt<xtmin>

 	xTilt = xTmin

 End If</xtmin>

wallComponent

Dim overC : overC = RGB(125,125,125)

Dim a0 : a0 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i), vVal(j)))

 Dim c0 : c0 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i)+uVal(1), vVal(j)))

 Dim c2 : c2 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i)+uVal(1), vVal(j+1)))

 Dim a2 : a2 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i), vVal(j+1)))

Dim b1 : b1 = Rhino.SurfaceCurvature(surfaceA(k), Array(uVal(i)+(uVal(1)*.5), vVal(j) + vVal(1)*(1-xTilt)))

 ap1(i,j) = offsetCalc(b1, height*.1)

 Dim bb1 : bb1 = Rhino.SurfaceCurvature(surfaceA(k), Array(uVal(i)+(uVal(1)*.5), vVal(j)+vVal(1)*xTilt ))

 ap2(i,j) = offsetCalc(bb1, height*.1)

ap3(i,j) = offsetCalc(b1, height/2)

 ap4(i,j) = offsetCalc(bb1, height/2)

Dim a0B : a0B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i), vVal(j)))

 Dim c0B : c0B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i)+uVal(1), vVal(j)))

 Dim c2B : c2B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i)+uVal(1), vVal(j+1)))

 Dim a2B : a2B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i), vVal(j+1)))

Dim b1B : b1B = Rhino.SurfaceCurvature(surfaceA	(k+1), Array(uVal(i)+(uVal(1)*.5), vVal(j) + vVal(1)*(1-xTilt)))

 ap1n(i,j) = offsetCalc(b1B, -height*.1)

Dim bb1B : bb1B = Rhino.SurfaceCurvature(surfaceA(k+1), Array(uVal(i)+(uVal(1)*.5), vVal(j)+vVal(1)*xTilt))

 ap2n(i,j) = offsetCalc(bb1B, -height*.1)

CheckLayerParent "construction"

'horiz

 'top

 Dim a0ap1c0 : a0ap1c0 = Rhino.AddNurbsCurve (Array(a0,ap1(i,j),c0),Array(0,0,1,1) ,2,Array(100,100,100))

 'bottom

 Dim a0Bap1nc0B : a0Bap1nc0B = Rhino.AddNurbsCurve (Array(a0B,ap1n(i,j),c0B),Array(0,0,1,1) ,2,Array(100,100,100))

 'vert

 'left

 Dim a0ap3a0B :  a0ap3a0B = 	Rhino.AddNurbsCurve (Array(a0,ap3(i,j),a0B),Array(0,0,1,1) ,2,Array(100,100,100))

 'right

 Dim c0ap3c0B :  c0ap3c0B = 	Rhino.AddNurbsCurve (Array(c0,ap3(i,j),c0B),Array(0,0,1,1) ,2,Array(100,100,100))

'horiz

 'top

 Dim a2ap2c2 : a2ap2c2 = Rhino.AddNurbsCurve (Array(a2,ap2(i,j),c2),Array(0,0,1,1) ,2,Array(100,100,100))

 'bottom

 Dim a2Bap2nc2B : a2Bap2nc2B = Rhino.AddNurbsCurve (Array(a2B,ap2n(i,j),c2B),Array(0,0,1,1) ,2,Array(100,100,100))

'vert

 'left

 Dim a2ap4a2B :  a2ap4a2B = 	Rhino.AddNurbsCurve (Array(a2,ap4(i,j),a2B),Array(0,0,1,1) ,2,Array(100,100,100))

 'right

 Dim c2ap4c2B :  c2ap4c2B = 	Rhino.AddNurbsCurve (Array(c2,ap4(i,j),c2B),Array(0,0,1,1) ,2,Array(100,100,100))

CheckLayer"Cocoon Component" , overC

edgeSurface  a0ap1c0, a2ap4a2B

 edgeSurface   a2Bap2nc2B, c0ap3c0B

End Function

Function extComponent (i,j,k)

 checkLayerParent(parentLayer)

Dim ySin:ySin = Abs(Sin(sinMult*j/vDiv))

 Dim xSin:xSin = Abs(Sin(sinMult*j/vDiv))

Dim glassColor : glassColor = RGB(127,255,191 )

 Dim a0 : a0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)))

Dim dist : dist=Rhino.Distance(Array(a0(0),a0(1),a0(2)),locator)

Dim arrNormal:arrNormal = Rhino.SurfaceNormal(sourceSurface(k), Array(uVal(i), vVal(j)))

 CheckLayerParent "construction"

Rhino.addline Array(0,0,0),arrNormal

 Rhino.addline a0,locator

 Dim angle:angle=Rhino.Angle2(Array(a0,locator),Array(Array(0,0,0),arrNormal))

 'xTilt=1- locatorMidDist/dist

 'yTilt=1-locatorMidDist/dist

xTilt=angle(0)/30

 yTilt=angle(0)/30

 Rhino.Print "x"&amp; xTilt

 Rhino.Print "y"&amp; yTilt

If yTilt&gt;yTmax Then

 	yTilt = yTmax

 End If

 If yTilt<ytmin>

 	yTilt = yTmin

 End If</ytmin>

If xTilt&gt;xTmax Then

 	xTilt = xTmax

 End If

If xTilt<xtmin>

 	xTilt = xTmin

 End If</xtmin>

Dim f0 : f0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(j)))

 Dim a5 : a5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)+ vVal(1)))

Dim c0 : c0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(xTilt)), vVal(j)))

 Dim e0 : e0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-offset)), vVal(j)))

Dim a1 : a1 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)+vVal(1)*(offset)))

Dim a2 : a2 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)+vVal(1)*(yTilt)))

 Dim b2 : b2 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(offset)) , vVal(j)+vVal(1)*(yTilt)))

Dim b5 : b5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(offset)) , vVal(j)+vVal(1)))

 Dim d5 : d5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-xTilt)) , vVal(j)+vVal(1)))

Dim e3 : e3 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-offset)), vVal(j)+vVal(1)*(1-yTilt)))

 Dim f3 : f3 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(j)+vVal(1)*(1-yTilt)))

 Dim f4 : f4 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(j)+vVal(1)*(1-offset)))

Dim f5 : f5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(j)+vVal(1)))

Dim cc1 : cc1 = Rhino.SurfaceCurvature(sourceSurface(k), Array(uVal(i)+(uVal(1)*(xTilt)), vVal(j)+(vVal(1)*offset)))

 Dim cd4 : cd4 = Rhino.SurfaceCurvature(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-xTilt)), vVal(j)+vVal(1)*(1-offset)))

'based on width height

height=xTilt/10

 ap1(i,j) = offsetCalc(cc1,  width*height)

 ap2(i,j) = offsetCalc(cd4,  width*height)

Dim arrVertices(15)

 arrVertices(0) = a0

 arrVertices(1) = c0

 arrVertices(2) = e0

 arrVertices(3) = f0

 arrVertices(4) = a1

 arrVertices(5) = ap1(i,j)

 arrVertices(6) = a2

 arrVertices(7) =b2

 arrVertices(8) =e3

 arrVertices(9) =f3

 arrVertices(10) =ap2(i,j)

 arrVertices(11) =f4

 arrVertices(12) =a5

 arrVertices(13) =b5

 arrVertices(14) =d5

 arrVertices(15) =f5

Dim arrFaceVertices(7)

 arrFaceVertices(0) = Array(0,1,5,4)

 arrFaceVertices(1) = Array(1,2,8,5)

 arrFaceVertices(2) = Array(2,3,9,8)

 arrFaceVertices(3) = Array(4,5,7,6)

 arrFaceVertices(4) = Array(8,9,11,10)

 arrFaceVertices(5) = Array(6,7,13,12)

 arrFaceVertices(6) = Array(7,10,14,13)

 arrFaceVertices(7) = Array(10,11,15,14)

CheckLayer"Component" , componentColor

 Rhino.AddMesh arrVertices, arrFaceVertices

Dim arrGlassVertices(1)

 arrGlassVertices		(0) = Array(5,8,10,10)

 arrGlassVertices(1) = Array(5,7,10,10)

CheckLayer"Component Glass" , glassColor

 Rhino.AddMesh arrVertices, arrGlassVertices

End Function

Function louvreComponent (i,j,k)

 checkLayerParent(parentLayer)

yTilt = Sin(5*j/vDiv)

If yTilt&gt;yTmax Then

 	yTilt = yTmax

 End If

 If yTilt<ytmin></ytmin>

yTilt = yTmin

 End If

xTilt = Sin(5*j/vDiv)

If xTilt&gt;xTmax Then

 	xTilt = xTmax

 End If

If xTilt<xtmin>

 	xTilt = xTmin

 End If</xtmin>

Dim glassColor : glassColor = RGB(127,255,191 )

 Dim a0 : a0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)))

 Dim f0 : f0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(j)))

 Dim a5 : a5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(vDiv)))

Dim c0 : c0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(xTilt)), vVal(j)))

 Dim e0 : e0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-offset)), vVal(j)))

Dim a1 : a1 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)+vVal(1)*(offset)))

Dim a2 : a2 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)+vVal(1)*(yTilt)))

 Dim b2 : b2 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(offset)) , vVal(j)+vVal(1)*(yTilt)))

Dim b5 : b5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(offset)) , vVal(vDiv)))

 Dim d5 : d5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-xTilt)) , vVal(vDiv)))

Dim e3 : e3 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-offset)), vVal(vDiv-1)+vVal(1)*(-yTilt)))

 Dim f3 : f3 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(vDiv)+vVal(1)*(-yTilt)))

 Dim f4 : f4 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(vDiv)+vVal(1)*(-offset)))

Dim f5 : f5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(vDiv)))

Dim cc1 : cc1 = Rhino.SurfaceCurvature(sourceSurface(k), Array(uVal(i)+(uVal(1)*(xTilt)), vVal(j)+(vVal(1)*offset)))

 Dim cd4 : cd4 = Rhino.SurfaceCurvature(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-xTilt)), vVal(vDiv)+vVal(1)*(-offset)))

'based on width height

ap1(i,j) = offsetCalc(cc1,  height*2)

 ap2(i,j) = offsetCalc(cd4,  height*2)

CheckLayerParent "construction"

 Dim a0c0 : a0c0 = Rhino.AddLine(a0 , c0)

 Dim a1ap1 : a1ap1 = Rhino.AddLine(a1, ap1(i,j))

 Dim c0ap1 : c0ap1 = Rhino.AddLine(c0, ap1(i,j))

 Dim a0a1 : a0a1 = Rhino.AddLine(a0 , a1)

 Dim a2b2 : a2b2 = Rhino.AddLine(a2 , b2)

 Dim a2a5 : a2a5 = Rhino.AddLine(a2 ,a5)

 Dim b2b5 : b2b5 = Rhino.AddLine(b2 , b5)

 Dim d5ap2 : d5ap2= Rhino.AddLine(d5,ap2(i,j))

 Dim b2ap2 : b2ap2  = Rhino.AddLine(b2,ap2(i,j))

 Dim b5d5 : b5d5 =  Rhino.AddLine(b5 , d5)

 CheckLayer"Component" , componentColor

 edgeSurface a0c0,a1ap1

 edgeSurface a1ap1,a2b2

 edgeSurface a2a5,b2b5

 edgeSurface b2ap2,b5d5

 CheckLayerParent "construction"

 Dim d5f5 : d5f5 = Rhino.AddLine(d5 , f5)

 Dim e3f3 : e3f3 = Rhino.AddLine(e3 , f3)

 Dim e0f0 : e0f0 = Rhino.AddLine(e0 , f0)

 Dim e0e3 : e0e3 = Rhino.AddLine(e0 , e3)

 Dim f0f3 : f0f3 = Rhino.AddLine(f0 , f3)

 Dim c0e0 : c0e0 = Rhino.AddLine(c0 , e0)

 Dim f4ap2 : f4ap2 = Rhino.AddLine(f4 , ap2(i,j))

 Dim e3ap1 : e3ap1 = Rhino.AddLine( ap1(i,j), e3)

 CheckLayer"Component" , componentColo

 edgeSurface f4ap2,e3f3

 edgeSurface e0e3,f0f3

 edgeSurface f4ap2,d5f5

 edgeSurface c0e0,e3ap1

 CheckLayerParent "construction"

 Dim ap1ap2 : ap1ap2 = Rhino.AddLine(ap1(i,j) , ap2(i,j))

 Dim e3ap2 : e3ap2 = Rhino.AddLine( ap2(i,j), e3)

 Dim b2ap1 : b2ap1  = Rhino.AddLine(b2,ap1(i,j))

 CheckLayer "Component Glass",glassColor

 Rhino.AddPlanarSrf(Array(ap1ap2,e3ap2,e3ap1))

 Rhino.AddPlanarSrf(Array(ap1ap2,b2ap2,b2ap1))

End Function

Function edgeSurface(edge1,edge2)

Dim f : f = Rhino.CurveDirectionsMatch(edge1,edge2)

 Dim rEdge

If f = False Then

 	rEdge=	Rhino.ReverseCurve(edge2)

 End If

 Rhino.AddEdgeSrf(Array(edge1, edge2 ))

End Function

Function RandomNumber(nMin, nMax)

 RandomNumber = vbNull

 If Not IsNumeric(nMin) Then Exit Function

 If Not IsNumeric(nMax) Then Exit Function

 If nMin &gt;= nMax Then Exit Function

 Randomize

 RandomNumber = Int((nMax - nMin + 1) * Rnd + nMin)

End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

 	'This fucntion finds the coordinate of a point normal to, and at a <height> from, a point on the surface

Function offsetCalc(oData, height)

 Dim vscaled

 vscaled = VectorScale(oData(1),height)

 offsetCalc = VectorAdd(vscaled,oData(0))

End Function</height>

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

 	'function by RMA, "vectors.rvb"

Function VectorAdd(v1, v2)

VectorAdd = Null

 'If Not IsArray(v1) Or (UBound(v1) &lt;&gt; 2) Then Exit Function

 'If Not IsArray(v2) Or (UBound(v2) &lt;&gt; 2) Then Exit Function

 VectorAdd = Array(v1(0) + v2(0), v1(1) + v2(1), v1(2) + v2(2))

End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

 	'function by RMA, "vectors.rvb"

Function VectorScale(v, d)

VectorScale = Null

 'If Not IsArray(v) Or (UBound(v) &lt;&gt; 2) Then Exit Function

 'If Not IsNumeric(d) Then Exit Function

 VectorScale = Array(v(0) * d, v(1) * d, v(2) * d)

End Function

'--------------------------------------------------------------------------------------------------------------------

 	'This function checks if the current layer is <layername> and if it isn't, makes it so. If the layer <layername> doesn't

 	'     exist then it creates it with the name <layername>.

Function CheckLayerParent(layername)

 If Rhino.IsLayer(layername) Then

 	Rhino.CurrentLayer(layername)</layername></layername></layername>

Else

 	Rhino.AddLayer layername,RGB(Cint(parentLayer*5),125,125)

 	Rhino.CurrentLayer(layername)

 End If

End Function

Function CheckLayer(layername,color)

 If Rhino.IsLayerChildOf(parentLayer, layername+"_"+parentLayer) Then

 	Rhino.CurrentLayer(layername+"_"+parentLayer)

Else

 	Rhino.AddLayer layername+"_"+parentLayer,color,,,parentLayer

 	Rhino.CurrentLayer(layername+"_"+parentLayer)

 End If

End Function

Function mesh()

 Rhino.Command "SelNone"

 Rhino.Command "Sellast"

 Rhino.Command "_mesh           Enter"

End Function</pre>
<ol class="footnotes"><li id="footnote_0_404" class="footnote">uDiv-1),(vDiv-1</li><li id="footnote_1_404" class="footnote">uDiv-1),(vDiv-1</li><li id="footnote_2_404" class="footnote">uDiv-1),(vDiv-1</li><li id="footnote_3_404" class="footnote">uDiv-1),(vDiv-1</li><li id="footnote_4_404" class="footnote">uDiv-1),(vDiv-1</li><li id="footnote_5_404" class="footnote">uDiv-1),(vDiv-1</li><li id="footnote_6_404" class="footnote">uDiv-1),(vDiv-1</li><li id="footnote_7_404" class="footnote">uDiv-1),(vDiv-1</li><li id="footnote_8_404" class="footnote">uDiv-1),(vDiv-1</li><li id="footnote_9_404" class="footnote">uDiv-1),(vDiv-1</li><li id="footnote_10_404" class="footnote">uDiv-1),(vDiv-1</li><li id="footnote_11_404" class="footnote">uDiv-1),(vDiv-1</li></ol>]]></content:encoded>
			<wfw:commentRss>http://cwwang.com/2007/04/19/seroussi-pavillion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
