While I am studying tensegrity structure for my thesis (http://en.wikipedia.org/wiki/Tensegrity), and building weird models like the one up here, I have written a simple script you can implement in my last post collection (just adding another "case" to the nine alredy there, so they are ten now!).
The scripts takes a surface and tesselates it with x-elements (I consider these as tensioned elements) and pipe elements (compressed ones). X-elements are scaled in proximity to an attractor point.
It is very simple so here it is
' CASE 10 SURFSTARS
Sub surfstars(strsurf,upar,vpar)
upar = upar*5
vpar = vpar*5
Dim dblheight : dblheight = rhino.getreal("extrusion height?" ,.05)
If isnull (dblheight) Then Exit Sub
Dim attrpoint : attrpoint = rhino.getobject("point attractor",1)
Dim arrpoint : arrpoint = rhino.PointCoordinates(attrpoint)
Call rhino.enableredraw(False)
Dim i, j
Dim uvalone(1), uvaltwo
Dim arrUone, arrVone
Dim arrpttemp, pointtwo
Dim pt1, pt2, pt3, pt4, pt5, pt6, PT7, Pt8, pt5b, pt6b, pt7b, pt8b, ptc1, ptc2
ReDim matrix (upar, vpar)
Dim tempt
arruone = array (0,0)
arrVone = array (0,0)
Dim strcell, arrct, arrptsurf, arrnorm, arrnormend,arrnormenddown, arrline, strcell2
If rhino.IsSurface(strsurf) Then
arruone = rhino.surfacedomain(strsurf,0)
arrVone = rhino.surfacedomain(strsurf,1)
End If
For i=0 To upar
For j=0 To vpar
uvalone(0)= ((arruone(1)-arruone(0))/upar)*i
uvalone(1) = ((arrVone(1)-arrVone(0))/vpar)*j
arrpttemp = rhino.EvaluateSurface(strsurf,uvalone)
matrix(i,j) = arrpttemp
Next
Next
Dim oct1, oct2, oct3, oct4, arrlinehuge, arrel1, arrel2
Dim rn, crvtemp, dbldist
For i = 1 To upar-1
For J=0 To vpar-1
pt1 = matrix(i,j)
pt2 = matrix(i+1,j)
pt3 = matrix(i,j+1)
pt4 = matrix(i+1,j+1)
pt5 = array( (pt1(0)+pt2(0))/2,(pt1(1)+pt2(1))/2,(pt1(2)+pt2(2))/2)
pt6 = array( (pt2(0)+pt4(0))/2,(pt2(1)+pt4(1))/2,(pt2(2)+pt4(2))/2)
pt7 = array( (pt3(0)+pt4(0))/2,(pt3(1)+pt4(1))/2,(pt3(2)+pt4(2))/2)
pt8 = array( (pt1(0)+pt3(0))/2,(pt1(1)+pt3(1))/2,(pt1(2)+pt3(2))/2)
ptc1 = array( (pt5(0)+pt7(0))/2,(pt5(1)+pt7(1))/2,(pt5(2)+pt7(2))/2)
ptc2 = array( (pt6(0)+pt8(0))/2,(pt6(1)+pt8(1))/2,(pt6(2)+pt8(2))/2)
dbldist = rhino.Distance(ptc1,arrpoint)
dbldist = Rhino.Log10 (dbldist*7)
If dbldist<1.1 dbldist="">
pt5b = array( pt5(0)+(ptc1(0)-pt5(0))/(dbldist),pt5(1)+(ptc1(1)-pt5(1))/(dbldist),pt5(2)+(ptc1(2)-pt5(2))/(dbldist))
pt6b = array( pt6(0)+(ptc2(0)-pt6(0))/(dbldist),pt6(1)+(ptc2(1)-pt6(1))/(dbldist),pt6(2)+(ptc2(2)-pt6(2))/(dbldist))
pt7b = array( pt7(0)+(ptc1(0)-pt7(0))/(dbldist),pt7(1)+(ptc1(1)-pt7(1))/(dbldist),pt7(2)+(ptc1(2)-pt7(2))/(dbldist))
pt8b = array( pt8(0)+(ptc2(0)-pt8(0))/(dbldist),pt8(1)+(ptc2(1)-pt8(1))/(dbldist),pt8(2)+(ptc2(2)-pt8(2))/(dbldist))
Call rhino.AddCurve(array(pt1,pt2,pt4,pt3,pt1),1)
strcell = rhino.addcurve(array(pt1,,pt5b, pt2,pt6b, pt4, pt7b,pt3,pt8b,pt1),1)
arrct = array( (pt4(0)+pt1(0))/2,(pt4(1)+pt1(1))/2,(pt4(2)+pt1(2))/2)
arrptsurf = rhino.SurfaceClosestPoint(strsurf,arrct)
arrnorm = rhino.SurfaceNormal(strsurf,arrptsurf)
arrnorm = rhino.VectorScale(arrnorm, dblheight)
arrnormend = rhino.PointAdd(arrct,arrnorm)
arrnormenddown = rhino.Pointsubtract(arrct,arrnorm)
crvtemp = rhino.AddSrfPt(array(pt1,arrnormend,pt5b))
crvtemp = rhino.AddSrfPt(array(pt5b,arrnormend,pt2))
crvtemp = rhino.AddSrfPt(array(pt2,arrnormend,pt6b))
crvtemp = rhino.AddSrfPt(array(pt6b,arrnormend,pt4))
crvtemp = rhino.AddSrfPt(array(pt4,arrnormend,pt7b))
crvtemp = rhino.AddSrfPt(array(pt7b,arrnormend,pt3))
crvtemp = rhino.AddSrfPt(array(pt3,arrnormend,pt8b))
crvtemp = rhino.AddSrfPt(array(pt8b,arrnormend,pt1))
crvtemp = rhino.AddSrfPt(array(pt1,arrnormenddown,pt5b))
crvtemp = rhino.AddSrfPt(array(pt5b,arrnormenddown,pt2))
crvtemp = rhino.AddSrfPt(array(pt2,arrnormenddown,pt6b))
crvtemp = rhino.AddSrfPt(array(pt6b,arrnormenddown,pt4))
crvtemp = rhino.AddSrfPt(array(pt4,arrnormenddown,pt7b))
crvtemp = rhino.AddSrfPt(array(pt7b,arrnormenddown,pt3))
crvtemp = rhino.AddSrfPt(array(pt3,arrnormenddown,pt8b))
crvtemp = rhino.AddSrfPt(array(pt8b,arrnormenddown,pt1))
arrline = rhino.AddLine(pt1,pt2)
Call rhino.selectobject (arrline)
rhino.Command "_pipe " & ".02 " & ".02 " & " _enter " & " _enter "
rhino.UnselectAllObjects
arrline = rhino.AddLine(pt3,pt4)
Call rhino.selectobject (arrline)
rhino.Command "_pipe " & ".02 " & ".02 " & " _enter " & " _enter "
rhino.UnselectAllObjects
Next
Next
Call rhino.deleteobject(strsurf)
Call rhino.EnableRedraw(True)
End Sub
Nice work Vink!
ReplyDeletePlease check the link on last picture, it seems not pointing to the larger version (as I supposed).
Please notice one thing: I still have to verify the script, but from the small picture it seems to me that you'll have to build a prototype to verify tensegrity properties on your tessellated surface since I feel there's something not exactly correct from the structural point of view (but maybe is the very small picture that misleads me).
One general comment after seeing your scripts in action (the ones in your previous post, not really this one, see below): you rely very much on the rhino.command. This is not that bad if you need it rarely, but it's slower than script methods. More important, there are 2 basic ways of using tools:
ReplyDelete. brute force: relying only on computational power (like using a fan to blow a candle)
. thinking like the tool: understanding the way the tool operates and profit of that.
Bulding geometry in scripting is not the same as building it manually in Rhino, so be aware of this and think on how to exploit Rhinoscript methods for your strategies. For the same reason please try to avoid using patches (in your case there are better solutions).
Please check also this condition:
If dbldist < dbldist =" 1.1">
what did you mean here?
The structure tessellated is not correct on the other side, you can see it in the upper right part (it was mean to be just a try) .
ReplyDeleteApart from that the x elements are mean to be stretched up-down (so because of the fact they are longer horizontally this can be confusing).
About the rhino.commands I noticed that they slow down the script but I cannot find a way to pipe lines inside the rhinoscript command. I will try to improve it.
About dbldist I think there was a mistake in copying the script, I meant
"If dbldist < 1.1 then dbldist = 1.1"
it was a way to control the influence of the attractor point
I'll fix it now, and also the picture.
What do you mean about "using patches"? In this or in the other scripts?
It is not my fault, everytime I correct the mistake blogger turn
ReplyDelete"If dbldist < 1.1 then dbldist = 1.1"
into another thing like
If dbldist < 1.1 dbldist ="1.1
I think it takes it like an html code.. don't know what to do ;(
Anyway about rhino.patch I really can't find another way to cover with a surface a non-planar border curve
ReplyDeleteThe patch is always an approximate solution (as its name suggests...), very useful for quick modeling in Rhino but it's HIGHLY unaccurated, especially if you need precise connections in the edges when capping a hole or filling a void. You have several alternatives in the Surface methods (check them out).
ReplyDeleteMaybe the thing that tricks you is the single non-planar border curve: no problem about it, you can just split it into 2 curves and use AddEdgeSrf.
About the "<" problem... have you tried editing HTML directly? See also here: http://www.utexas.edu/learn/html/spchar.html
About structural properties of your tessellated surface... we'll discuss them in a while. ;-)
Cheers!
PS: one last thing... please help me in making that word cloud in the upper right corner of the blog a little nicer... put some keywords whenever you post.