Forgot password?

Create an account!

Forum

« back

RhinoScript – panels with script

Messages

Please log in to write a message.

  • 2. Hanno (Oct 19, 2009 18.33):

    Hi,

    you can solve the problem with the twisted surfaces by simply changing the point order for the AddSrfPt method to (point1, point2, point4, point3). Look at your point definition: point4 is actually opposite to point1, and you need to input the points in circular order, not crosswise.
    The thing with the red lines is a bit more tricky: these lines need to span from one panel to the next. So you need to save the midpoints in an array, so that every panel can access the midpoints from previously created panels.

    Regards

    Hanno

  • 1. mcaspers2 (Oct 17, 2009 18.06):

    Hi,

    I want te generate some panels(from surface) with a script. I have some questions about this script (see attachment);
    - how do I make lines from midpoint to other midpoint (redlines)
    - Hoe do I get the surfacenormals (not duplicates, only one line)
    - There are some twists in the surfaces, I read about it (David rutten), but I can't fix it.

    If you could help me, I would appreciate this very much.

    greetings,

    Marco.Caspers

    Option Explicit
    'Script written by <insert name>
    'Script copyrighted by <insert company name>
    'Script version maandag 5 oktober 2009 11:55:05

    Call grid()
    Sub grid()
            Dim surface
            surface=Rhino.GetObject("select surface",8)
            If IsNull(surface) Then Exit Sub
           
            Dim sections
            sections=Rhino.GetInteger("amount of sections",20,5,100)
            If IsNull(sections) Then Exit Sub
            'subdivide surface in fields U-direction
            'U-values
            '0=U
            Dim surfacedomainU, Umin,Umax,Ustep
            surfacedomainU=Rhino.surfacedomain(surface,0)
            Umin=surfacedomainU(0)
            Umax=surfacedomainU(1)
            Rhino.Print "Domain in U direction: " & CStr(surfacedomainU(0)) & " to " & CStr(surfacedomainU(1))
            Ustep=(Umax-Umin)/sections
            'subdivide surface in fields V-direction
            'V-values
            Dim surfacedomainV, Vmin,Vmax,Vstep
            SurfacedomainV=Rhino.SurfaceDomain(surface,1)
            Vmin=surfacedomainV(0)
            Vmax=surfacedomainV(1)
            Rhino.Print "Domain in V direction: "& CStr(surfacedomainV(0)) & " to " & CStr(surfacedomainV(1))
            Vstep=(Vmax-vmin)/sections
           
            Dim i,j,point1,point2,arrcolor,arrpoint1,arrpoint2,arrpoint3
            Dim point3,arrcolor2,arrpoint4,point4,arrcolor3
            Dim arrpoints,dblscale
                    For i=Umin To (Umax-Ustep) Step Ustep
                    For j=Vmin To (Vmax-Vstep) Step Vstep
                            dblscale=((ustep/5)*2)
                            'dblradius2=(Ustep/10)
                           
                            'define points
                            '--------------------------------------
                            Dim arrline1,arrline2,midpoint1
                           
                            'point 1 (0,0,0)
                            point1=Rhino.evaluatesurface(surface,Array(i,j))
                            'point 2 (0,step,0),y-richting vstep
                            point2=Rhino.evaluatesurface(surface,Array(i,j+vstep))
                            'point 3 (step,0,0),x-richting ustep
                            point3=Rhino.EvaluateSurface(surface,Array(i+ustep,j))
                            'point 4 (step,step,0),x-richting ustep,y-richting vstep
                            point4=Rhino.evaluatesurface(surface,Array(i+ustep,j+vstep))
                                           
                            arrline1=Rhino.AddLine(point1,point4)
                            arrline2=Rhino.addline(point2,point3)
                            midpoint1=Rhino.CurveMidPoint(arrline1)
                                           
                            'create 4 new lines between midpoint
                            Dim secline1,secline2,secline3,secline4
                            secline1=Rhino.addline(point1,midpoint1)
                            secline2=Rhino.addline(point2,midpoint1)
                            secline3=Rhino.addline(point3,midpoint1)
                            secline4=Rhino.addline(point4,midpoint1)
                            Rhino.deleteobject arrline1
                            Rhino.deleteobject arrline2
                           
                            'make plane of 4 points,add areacentroid and find normal
                            Dim surfaceplane,areacentroid,tempx,tempu,tempv
                            Dim tempparu,tempparv,surfacenormal,surfacenormal1
                            Dim arrdomainU,arrdomainV,dblparameterU,dblParameterV
                            Dim surfacenormal2,surfacenormal3,surfacenormal4
                            surfaceplane=Rhino.addsrfpt(Array(point1,point2,point3,point4))
                            areacentroid=Rhino.surfaceareacentroid(surfaceplane)
                            tempx=Rhino.addpoint (areacentroid(0))
                            arrdomainU=surfacedomain(surfaceplane,0)
                            ArrdomainV=surfacedomain(surfaceplane,1)
                            dblParameterU = (arrDomainU(1) + arrDomainU(0)) / 2
                            dblParameterV = (arrDomainV(1) + arrDomainV(0)) / 2
                           
                            'normal midpoint + line
                            Dim normal1,arrlinenormal,crvendpt,moveline
                            surfacenormal=Rhino.surfacenormal(surfaceplane,Array(dblparameterU,dblparameterV))
                            normal1=Rhino.vectorscale(surfacenormal,dblscale)
                            normal1=Rhino.VectorAdd(normal1,areacentroid(0))
                            arrlinenormal=Rhino.addline (areacentroid(0),normal1)
                            'move midpoint arrlinenormal to areacentroid
                            crvendpt=Rhino.CurvemidPoint(arrlinenormal)
                            moveline=Rhino.MoveObject (arrlinenormal, crvendpt, areacentroid(0))

                            'normal point1
                            surfacenormal1=Rhino.surfacenormal(surface,Array(i,j))
                            'normal point2
                            surfacenormal2=Rhino.surfacenormal(surface,Array(i,j+vstep))
                            'normal point3
                            surfacenormal3=Rhino.surfacenormal(surface,Array(i+ustep,j))
                            'normal point4
                            surfacenormal4=Rhino.surfacenormal(surface,Array(i+ustep,j+vstep))
                           
                           
                    Next
            Next
            Rhino.deleteobject surface
    End Sub
    panels with script
Recommend

Why are these buttons gray?