Forgot password?

Create an account!

Forum

« back

RhinoScript – unroll curve on surface not working - why?

Messages

Please log in to write a message.

  • 2. Hanno (Apr 26, 2011 10.08):

    Hi Andy,

    it looks like the line you mention is supposed to be:

    strCurves = ""

    That's clearly an error in McNeel's script. You might want to give them a hint...

    Regards

    Hanno

  • 1. Andy70182 (Apr 25, 2011 13.30):

    ' Description:
     '   Unroll a surface or polysurface.
     ' Parameters:
     '   strSurface - String, The identifier of the surface or polysurface to unroll.
     '   arrCurves  - Array, The identifiers of one or more curves to unroll.
     '   blnExplode - Boolean, Explode the resulting objects.
     '   blnLabels  - Boolean, Label the resulting objects with numbered dots.
     ' Returns:
     '   Array, The identifiers of the unrolled objects if successful.
     '   Null on error

     Option Explicit
     
    Function RhinoUnrollSurface(strSurface, arrCurves, blnExplode, blnLabels)
     
            Rhino.Print "Hello Rhino!"


           
            ' Default return value  
            RhinoUnrollSurface = Null
     
            ' For speed, turn of screen redrawing
            Call Rhino.EnableRedraw(False)
     
            ' Save any selected objects
            Dim arrSaved : arrSaved = Rhino.SelectedObjects
     
            ' Unselect all objects
            Rhino.UnSelectAllObjects
     
            ' Select the surface to unroll
            Rhino.SelectObject strSurface
     
            ' Format curve string
            Dim i : i = 0
            Dim strCurves : strCurves = " _Enter"
            If IsArray(arrCurves) Then
         ***'strCurves = ***

                            For i = 0 To UBound(arrCurves)
                    strCurves = strCurves & " _SelId " & arrCurves(i)
                    Next
                    strCurves = strCurves & " _Enter"
            End If
     
            ' Format explode string
            Dim strExplode : strExplode = " _Explode=_Yes"
            If (blnExplode = False) Then strExplode = " _Explode=_No"
     
            ' Format labels string
            Dim strLabels : strLabels = " _Labels=_No"
            If (blnLabels = True) Then strLabels = " _Labels=_Yes"
     
            ' Script the command
            Dim strCommand : strCommand = "_-UnrollSrf" & strExplode & strLabels & strCurves
            Call Rhino.Command(strCommand, 0)
     
            ' Return the results
            RhinoUnrollSurface = Rhino.LastCreatedObjects
     
            ' Unselect all objects
            Rhino.UnSelectAllObjects
     
            ' If any objects were selected before calling
            ' this function, re-select them
            If IsArray(arrSaved) Then Rhino.SelectObjects(arrSaved)
     
            ' Don't forget to turn redrawing back on
            Call Rhino.EnableRedraw(True)
     
    End Function


    Sub TestRhinoUnrollSurface()
     
            Dim strSurface : strSurface = Rhino.GetObject("Select surface or polysurface to unroll", 8 + 16)
            If IsNull(strSurface) Then Exit Sub
     
            Dim strPrompt : strPrompt = "Select curves on polysurface to unroll"
            If Rhino.IsSurface(strSurface) Then strPrompt = "Select curves on surface to unroll"
     
            Dim arrCurves : arrCurves = Rhino.GetObjects(strPrompt, 4)
     
            Dim i, arrResults : arrResults = RhinoUnrollSurface(strSurface, arrCurves, False, True)
            If IsArray(arrResults) Then
                    For i = 0 To UBound(arrResults)
                            Call Rhino.Print(arrResults(i))
                    Next
            End If
     
    End Sub

    TestRhinoUnrollSurface

    whats wrong with this script?
    i found it as an example on mcneel.org wiki
    link here: wiki.mcneel.com/developer/scriptsamples/unrollsrf

    and theres even that wrong line it, which i commented, bold now...

    any idea? i really need some curves to be unrolled with...

    if i do it in the console it works perfectly...

Recommend

Why are these buttons gray?