[R_script] fabrication script

오랫만에 올리는 스크립트

fabrication 용으로 만든겁니다.

객체를 알아써 쪼개고 부재를 알아서 drafting 해 줍니다.


Option Explicit
'Script written by Woong Ki Sung
'Script copyrighted by Noclew
'Script version 1.0

Call Main()


Sub Main()
    Dim strObj, arrPoint, ptCenter
    Dim arrValue
       
    strObj = rhino.GetObject("select cutting object",8+16)
    If isnull(strObj) Then
        Exit Sub
    End If
   
    'strObject = Rhino.GetObjects("Select curvse",4)
    ptCenter = rhino.GetPoint("select center point")
   
    arrValue = Rhino.PropertyListBox(array("slice number","Tile Spacing","textHeight"),array(20,5,5))
    If Not isarray(arrValue) Then
        Exit Sub
    End If
   
   
    Call rhino.EnableRedraw(False)
             
    If isnull(ptCenter) Then
        Dim bBox, la, lb
        bBox = rhino.BoundingBox(strObj)
        la = rhino.AddLine(bBox(0), bBox(2))
        lb = rhino.addline(bBox(1), bBox(3))
        ptCenter = rhino.CurveCurveIntersection(la,lb)(0,1)
        rhino.DeleteObject(la)
        rhino.DeleteObject(lb)
        'rhino.AddPoint(ptCenter)
    End If
   
    '----------------------------------------
    Dim Cline        
    Cline = cutProfile(strobj, ptcenter, arrvalue(0))
    Call CrvOrient(Cline ,CInt(arrvalue(1)),CInt(arrvalue(2)))
   
    Call rhino.EnableRedraw(True)
   
   
End Sub

Function cutProfile(strObj, ptCenter, intNum)
    cutProfile = Null
       
    Dim dblLength
    Dim tBbox
    tBbox = rhino.BoundingBox(strObj)
    dblLength = 2 * rhino.Distance(BoundingBox(strObj)(0),BoundingBox(strObj)(4))
   
    Dim i
   
    Dim cLine
    Dim bLine 'basic line
    ReDim bline(0)
    bLine(0) = rhino.AddLine(ptCenter,array(0,dblLength,0))       
   
    For i=1 To intNum-1 Step 1
        ReDim Preserve bline(i)
        bline(i) = rhino.RotateObject(bline(i-1),ptCenter,360/intNum,array(0,0,1),True)
    Next

    Call rhino.AddLayer("_cut line",rgb(128,57,234))
    cline = Rhino.ProjectCurveToSurface (bline, strobj, array(0,0,1))
    Call rhino.ObjectLayer(cline,"_cut line")
    Call rhino.DeleteObjects(bline)
   
    cutProfile = cline       
   
End Function
   
Function CrvOrient(arrCrvs,intSpacing,Theight)
    Dim i,j
    Dim cPlane, wPlane
    Dim tCrvs()
    Dim rPoint
    Dim strDot
       
    Dim bBox
    Dim distX : distX = 0
    Dim intNum
   
    'drafting layer creation
    Call rhino.AddLayer("_drafting",rgb(128,255,255))
    Call rhino.AddLayer("_r_dot",rgb(255,255,255))
    Call rhino.AddLayer("_numbering",rgb(77,78,128))

    'orienting
    For i=0 To ubound(arrCrvs) Step 1
                'extract cplane of each objs
        cplane = rhino.CurvePlane(arrCrvs(i))
        ReDim Preserve tCrvs(i)
        'reference point of crv
        rPoint = array(cplane(0),rhino.PointAdd(cplane(0),cPlane(1)),rhino.PointAdd(cPlane(0),cPlane(2)))
        'objects orient
        tCrvs(i) = rhino.OrientObject(arrCrvs(i),rpoint, rhino.WorldXYPlane(),1)
        'dot mark
        strDot = rhino.addtextdot(i,rhino.CurveendPoint(arrcrvs(i)))
        Call rhino.ObjectLayer(strDot,"_r_dot")
       
    Next           
   
    i=0
   
    'arrangement
    For i=0 To ubound(tCrvs) Step 1
        bBox = rhino.BoundingBox(tCrvs(i))
       
        'distribution
        Call rhino.MoveObject(tCrvs(i),bBox(0),array(distX,0,0))
       
        'numbering
        'intNum = rhino.AddText(i,bbox(0),Theight,"isoct",1)
        intNum = rhino.AddText(i,rhino.CurveStartPoint(tcrvs(i)),Theight,"isoct",1)
        Call Rhino.ObjectLayer(intNum,"_numbering")
       
        '-------->spacing point
        ''Call rhino.MoveObject(intNum,bBox(0),array(distX+1,1,0))
       
        distX = rhino.Distance(bBox(0),bBox(1)) + distX + intSpacing   
    Next
   
    Call Rhino.ObjectLayer(tCrvs,"_drafting")
End Function

Function reparameterize(strCurveID)
    If Rhino.IsCurve(strCurveID) = True Then
        Call rhino.SelectObject(strCurveID)
        Call rhino.Command("reparameterize 0 1")
        Call rhino.UnselectAllObjects()
    End If
    If Rhino.IsSurface(strCurveID) = True Then
        Call rhino.SelectObject(strCurveID)
        Call rhino.Command("reparameterize 0 1 0 1")
        Call rhino.UnselectAllObjects()
    End If
End Function

저작자 표시
신고
Designed by CMSFactory.NET