08 October 2011

rh TowerContour

This script creates planar surfaces and puts a tag with the area value for each floor of the tower.

Option Explicit
'Script written by davide del giudice
'Script copyrighted by www.co-de-it.com
'Script version Saturday, 09 Oct 2011

Call Contour()
Sub Contour()
Dim srf1,arrcrvs,startpt,endpt,arrst,arrend, int,crv,counter,counter2
srf1=rhino.GetObject("select surface",8+16)
int= rhino.GetInteger ("select height floor",10,1,100)
startpt=rhino.getobject("select start point",1)
endpt=rhino.Getobject("select end point",1)

arrst=rhino.PointCoordinates (startpt)
arrend=rhino.PointCoordinates (endpt)
arrcrvs=Rhino.AddSrfContourCrvs (srf1, arrst, arrend,int)
rhino.HideObject srf1
counter=0
counter2=0
For Each crv In arrcrvs
If rhino.iscurveclosed(crv) Then
Dim centroid:centroid=Rhino.CurveAreaCentroid (crv)
Dim area:area=rhino.curveArea (crv)
Call rhino.ObjectColor (crv, rgb (((counter*10)+50),((counter*10)+50),((counter*10)+50)))

Dim area1:area1=Rhino.Ceil (area(0))
Dim arrBox:arrBox=Rhino.BoundingBox (crv)
Dim arrpoint
Dim dot:dot= rhino.AddTextDot ("floor#"&counter, arrBox(3))
Dim plansrf:plansrf=rhino.AddPlanarSrf (array(arrcrvs(counter)))
Call rhino.ObjectColor (plansrf, rgb (((counter*10)+50),((counter*10)+50),((counter*10)+50)))
Call rhino.ObjectColor (dot, rgb (((counter*10)+10),((counter*10)+50),((counter*10)+50)))
If counter
rhino.addpoint array(counter*50,0,0)
Call rhino.MoveObject (crv,centroid(0),array(counter*50,50,0))
Dim txt1:txt1=rhino.AddText ("A"&counter&"_"&area1&"mq",array(counter*50,0,0),5)
Dim txt3:txt3=rhino.AddText ("n"&counter,array(counter*50,50,0),5)
Call rhino.ObjectColor (txt1, rgb (((counter*10)+50),((counter*10)+50),((counter*10)+50)))
Call rhino.ObjectColor (txt3, rgb (((counter*10)+50),((counter*10)+50),((counter*10)+50)))
Else
rhino.addpoint array(counter2*50,-150,0)
Call rhino.MoveObject (crv,centroid(0),array(counter2*50,-100,0))
Dim txt2:txt2= rhino.AddText ("A"&counter&"_"&area1&"mq",array(counter2*50,-150,0),5)
Dim txt4:txt4= rhino.AddText ("n"&counter,array(counter2*50,-100,0),5)
Call rhino.ObjectColor (txt2, rgb (((counter*10)+50),((counter*10)+50),((counter*10)+50)))
Call rhino.ObjectColor (txt4, rgb (((counter*10)+50),((counter*10)+50),((counter*10)+50)))
counter2=counter2+1
End If
End If
counter=counter+1
Next

End Sub

0 commenti: