[rhino script] Brick Formation

이런거 만들어서 써먹어 봐야지.. 생각만 하고 있다가..

얼마전에 올라온 bring tectonic을 보고는 충격.. 흐미..

더 늦기전에 만들어 봤씁니다.





Option Explicit

Call Main()
Sub Main()
    dim strObjs : strObjs= rhino.GetObjects("",8+16,true,true,false)
    dim strSrf : strSrf = rhino.GetObject("srf?",8+16)
    dim bPt_S : bPt_S = rhino.GetPoint("Srf base?")
    dim bPt_B : bPt_B = rhino.GetPoint("Block base?")
   
    if isnull(strObjs) or isnull(strSrf) then
        exit sub
    End If
   
    call rhino.Enableredraw(false)
    'dim x : x = rhino.GetInteger("x")
    'dim y : y = rhino.GetInteger("y")
   

    '--------bounding box base point------------       
    dim arrCpts : arrCpts = cBbox(strobjs, strSrf)
       
    '----------pt transfer------------------   
    dim dVec : dVec = rhino.vectorcreate(bPt_S,bPt_B)
    dim i
    for i = 0 to ubound(arrCpts)
        arrCpts(i) = rhino.PointAdd(arrCpts(i),dvec)
    Next
    '------------test------------------
    'call rhino.addpoints(arrCpts) 'temp
   
    '----------- pt project -----------------
    dim projPts : ProjPts = PointProject(strsrf,arrCpts)
   
    'call rhino.addpoints(ProjPts) 'temp

    '---------object Move!------------------------
    dim j
    for j=0 to ubound(projPts)
       call rhino.MoveObject(strObjs(j), arrCpts(j),projPts(j))           
 Next
   
    call rhino.Enableredraw(true)
End Sub



Function cBbox(strObjs, strSrf)
    dim i
    dim Bbox
    dim arrCp()
    dim delta : delta = rhino.BoundingBox(strSrf)(0)(1) - rhino.BoundingBox(strobjs(0))(0)(1)
   
    for i=0 to ubound(strObjs)
        Bbox = rhino.BoundingBox(strObjs(i))
               
        if  delta < 0 then
            redim preserve arrCp(i) : arrCp(i) = array( (Bbox(0)(0)+Bbox(5)(0))/2, (Bbox(0)(1)+Bbox(5)(1))/2, (Bbox(0)(2)+Bbox(5)(2))/2)
        else
            redim preserve arrCp(i) : arrCp(i) = array( (Bbox(3)(0)+Bbox(6)(0))/2, (Bbox(3)(1)+Bbox(6)(1))/2, (Bbox(3)(2)+Bbox(6)(2))/2)
        End If
       
    Next
       
    cBbox = arrCp
    'call rhino.addpoints(arrCp) 'temp   
End Function


function PointProject(arrSrf, Pts)
    pointProject = null
    PointProject = Rhino.ProjectPointToSurface (Pts, arrSrf, array (0,1,0))
End Function
저작자 표시
신고

'틔움디자인(tium) > 스터디' 카테고리의 다른 글

[ 5osa ] coconn bench  (4) 2010.08.26
[ 5osA ] 스타벅스 공모전  (4) 2010.04.20
[rhino script] Brick Formation  (1) 2010.04.11
[R_script] fabrication script  (2) 2010.04.07
[ 5osA ] EX-Change Light Box  (0) 2009.10.19
[ 5osA ] Event Generator _ Competition in Bodø  (0) 2009.10.08
Designed by CMSFactory.NET