
dim srf

srf = Rhino.getObject("selecciona una superficie!", 8)

call contourSrf(srf)


'----
function contourSrf(srf)
'crear variables
	dim BoxArray
	dim CurveColeccion1
	dim CurveColeccion2
	
	BoxArray = Rhino.BoundingBox(srf)
	
	
	'Crear bounding box of superficie	
	for i = 0 to UBound(BoxArray)
		Rhino.AddPoint(BoxArray(i))
		'call Rhino.AddLine(BoxArray(0), BoxArray(1))	
	next

	'se encontraron puntos de contenedor para los ejes
		
	'CURVE IN FIRST DIRECTION
	'Crear contours "secciones" para superficie en dos direcciones	
	Rhino.SelectObject(srf)
	Rhino.Command "_Contour " & Pt2Str(BoxArray(0)) & " " & Pt2Str(BoxArray(1)) & " 2.0 Enter "
	'Unselect objects
	Rhino.UnSelectAllObjects()
	'Collect all of the curves
	CurveColeccion1 = Rhino.ObjectsByType (4)
	'bloquear coleccion 1
	'Rhino.HideObjects (CurveColeccion1)
	
	'make truss with first set of curves
	call makeTrussXDirection(CurveColeccion1)
	'Delete first set of curves
	Rhino.DeleteObjects(Rhino.ObjectsByType(4))
	
	
	
	'CURVE IN OTHER DIRECTION
	Rhino.SelectObject(srf)
	Rhino.Command "_Contour " & Pt2Str(BoxArray(0)) & " " & Pt2Str(BoxArray(3)) & " 2.0 Enter "
	'Collect all of the curves
	Rhino.UnSelectAllObjects()
	CurveColeccion2 = Rhino.ObjectsByType (4)
	
	'desbloquear coleccion 1
	'Rhino.lockObjects (CurveColeccion2)
	
	'make truss with Second set of curves
	call makeTrussYDirection(CurveColeccion2)
	'Delete second set of curves
	Rhino.DeleteObjects(Rhino.ObjectsByType(4))
	
	
end function   
'------------


'This function creates the truss ribs
function makeTrussXDirection(Curves)

	dim pathA
	dim pointA
	dim pathB
	dim pathC
	dim numeroDeCurves
	redim pointB(2)
	redim pointC(2)
	redim pointD(2)
	
	'Get number of curves
	numeroDeCurves = UBound(Curves)
	
	
	'CREAR COLECCION
	
	redim coleccionsurface1(numeroDeCurves) 
	
	
	for i = 0 to UBound(Curves)
		Rhino.SelectObject Curves(i)
		'Get end point of curve
		pointA = Rhino.CurveEndPoint(Curves(i))
		'Add point to scence
		Rhino.AddPoint pointA
		
		'Create new point for path
		pointB(0) = pointA(0)
		pointB(1) = pointA(1)
		pointB(2) = pointA(2) + 1
		
		pointC(0) = pointA(0)+ .15
		pointC(1) = pointA(1) 
		pointC(2) = pointA(2)
		
		pointD(0) = pointA(0)- .15
		pointD(1) = pointA(1) 
		pointD(2) = pointA(2)
		
		
		'Create path to extrude rib
		pathA = Rhino.AddLine(pointA, pointB)
		pathB = Rhino.AddLine(pointA, pointD)
		pathC = Rhino.AddLine(pointA, pointC)
		

		'Create extrude for curve
		coleccionsurface1(i) = Rhino.ExtrudeCurve (Curves(i), pathA)		

       next
		
		redim  solidsribs(UBound(coleccionsurface1))

		for i = 0 to UBound(coleccionsurface1)

			Rhino.ExtrudeSurface  coleccionsurface1(i),pathB
			Rhino.ExtrudeSurface  coleccionsurface1(i),pathC 
     
			'solidsribs= Rhino.ExtrudeSurface  (coleccionsurface1(i),pathB )
     
		
		next
		
		'Delete all paths
		'Rhino.DeleteObjects(Array(pathA, pathB, pathC))
	
end function 





'This function creates the truss ribs
function makeTrussYDirection(Curves)

	dim pathA
	dim pointA
	dim pathB
	dim pathC
	dim numeroDeCurves
	redim pointB(2)
	redim pointC(2)
	redim pointD(2)
	
	
	
	'Get number of curves
	numeroDeCurves = UBound(Curves)
	
	
	'CREAR COLECCION
	
	redim coleccionsurface1(numeroDeCurves) 
	
	
	for i = 0 to UBound(Curves)
		Rhino.SelectObject Curves(i)
		'Get end point of curve
		pointA = Rhino.CurveEndPoint(Curves(i))
		'Add point to scence
		Rhino.AddPoint pointA
		
		'Create new point for path
		pointB(0) = pointA(0)
		pointB(1) = pointA(1)
		pointB(2) = pointA(2) + 1
		
		pointC(0) = pointA(0)
		pointC(1) = pointA(1)-.15 
		pointC(2) = pointA(2)
		
				
		pointD(0) = pointA(0)
		pointD(1) = pointA(1)+.15 
		pointD(2) = pointA(2)
		
				
		
		'Create path to extrude rib
		pathA = Rhino.AddLine(pointA, pointB)
		pathB = Rhino.AddLine(pointA, pointD)
		pathC = Rhino.AddLine(pointA, pointC)

		
		'Create extrude for curve
		coleccionsurface1(i) = Rhino.ExtrudeCurve (Curves(i), pathA)		

       next
		
		redim  solidsribs(UBound(coleccionsurface1))

		for i = 0 to UBound(coleccionsurface1)

			Rhino.ExtrudeSurface  coleccionsurface1(i),pathB
			Rhino.ExtrudeSurface  coleccionsurface1(i),pathC 
     
			'solidsribs= Rhino.ExtrudeSurface  (coleccionsurface1(i),pathB )
     
		
	next

	'Delete all paths
	'Rhino.DeleteObjects(Array(pathA, pathB, pathC))
	
end function 



'--------------



