2009年9月17日星期四

Multi-Curve random extrusion for building blocks

master plan

you need to prepare the footprint of the building blocks. feature:

  • tolerance set up
  • auto fix unclosed curve, count shows in command
  • random heights controlled by 'step' method, for the easy control of floor amount
  • failed block-making geometries will be highlighted by selecting at the end of procedure

 

Call Main()
Sub Main()
    Dim objs:objs=rhino.GetObjects("select curves",4,True,True)
    If isnull(objs) Then Exit Sub
    rhino.Command "selnone"
    Dim minpre,maxpre,steppre,closepre
    'Rhino.DeleteDocumentData "data"
    If isnull(rhino.GetDocumentData("data")) Then
        rhino.setdocumentdata "data","min","0"
        rhino.setdocumentdata "data","max","0"
        rhino.setdocumentdata "data","step1","0"
        rhino.setdocumentdata "data","close","0"
    End If

    minpre=str2real(rhino.GetDocumentData("data","min"))
    maxpre=str2real(rhino.GetDocumentData("data","max"))
    steppre=str2real(rhino.GetDocumentData("data","step1"))
    closepre=str2real(rhino.GetDocumentData("data","close"))
    Dim min,max,step1,close
    close=rhino.Getreal("close curve tolerrence? (0=keep as it)",closepre,0)
    If isnull(close) Then Exit Sub
    min=rhino.getreal("min height?",minpre,0)
    If isnull(min) Then Exit Sub
    max=rhino.getreal("max height?",maxpre,min)
    If isnull(max) Then Exit Sub
    step1=rhino.getinteger("How Many Step? (0 = no step)",steppre)
    If isnull(step1) Then Exit Sub
    rhino.setdocumentdata "data","min",min
    rhino.setdocumentdata "data","max",max
    rhino.setdocumentdata "data","step1",step1
    rhino.setdocumentdata "data","close",close
    Dim n:n=ubound(objs)
    Dim i,edge,btm,top,height,ngm,ng
    ngm=0
    ng=0
    For i=0 To n
        rhino.EnableRedraw False

        height=min*(1+rhino.Floor(rnd*(step1+1))/step1)
        Dim gap: gap=rhino.Distance(rhino.CurveStartPoint(objs(i)),rhino.CurveEndPoint(objs(i)))
        If Not(close=0) And (rhino.IsCurveClosable(objs(i),close)=True)Then
            rhino.Print "system-fixable gap found.."
            objs(i)=rhino.CloseCurve (objs(i),close)   
            ng=ng+1
            rhino.Print "system-fixable gap fixed!!--No."&ng
        ElseIf gap<close And gap>0 Then           
            rhino.print "gap needs to be fixed manally.."
                Dim line:line=rhino.AddLine(rhino.CurveStartPoint(objs(i)),rhino.CurveEndPoint(objs(i)))
            objs(i)=rhino.JoinCurves(array(objs(i),line),True)(0)
            ngm=ngm+1
            rhino.print "gap needs to be fixed manally has been fixed!!--No."&ngm
        End If       
        edge=rhino.ExtrudeCurveStraight( objs(i),array(0,0,0),array(0,0,height))
        If (rhino.IsCurveClosed(objs(i))=True) And (rhino.IsCurvePlanar(objs(i))=True) Then
            btm=rhino.AddPlanarSrf(array(objs(i)))(0)
            top=rhino.CopyObject(btm,array(0,0,0),array(0,0,height))
            rhino.JoinSurfaces array(btm,edge,top),True
        Else
            rhino.SelectObject objs(i)
            rhino.SelectObject edge
        End If
    Next
    rhino.EnableRedraw True
End Sub

Function str2real(str)
    str2real=rhino.Str2Pt(str&",0,0")(0)   
End Function

2009年9月6日星期日

digital project shortcut and alias list

Took me 8 hours to setup, you guys should be happy now…enjoy!

sample

note:

catia system is capital sensitive. be aware your caps lock…

2009年9月3日星期四

xScatter plugin final

 

attachment

Snap2

new feature:

    • clone based on points,lines,surfaces
    • auto guess object center or manually assign center to seeds
    • orientation related to camera or selected point
    • scattering within selected camera’s viewport to save system memory

 

Snap1