Forgot password?

Create an account!

Forum

« back

RhinoScript – Run a command and create a new layer

Messages

Please log in to write a message.

  • 7. Johannes (Nov 09, 2013 19.18):

    Hi,

    you need to change the loop. It needs to run to the Ubound of the array of section crvs. And the strlayer will not work like this. You can't call a variable inside a srting.

    this should work:

            'makelayer & move To'
            For i = 0 To Ubound(arrContourStr)
                    strLayer = Rhino.AddLayer("section_" & i)
                    Call Rhino.ObjectLayer(arrContourStr(i), strLayer)
            Next

    Take care of the interval in Rhino.AddSrfContourCrvs(). I crashed my Rhino twice before i regognized that it was set to 0.01. The script tried to make more then 5000 sections, layers, ...

  • 6. Uog (Nov 05, 2013 06.55):

    I changed the script as follows :

    Option Explicit
    Call Main()
    Sub Main()
    Const rhObjectSurface = 8
    Const rhObjectPolysurface = 16
    Dim strObject, arrStartPoint, arrEndPoint, arrContourStr, i, strLayer


    'make contour'
    strObject = Rhino.GetObject("Select surface", rhObjectSurface + rhObjectPolysurface)
    arrStartPoint = Rhino.GetPoint("Base point of center line")
    arrEndPoint = Rhino.GetPoint("Endpoint of center line", arrStartPoint)
    arrContourStr = Rhino.AddSrfContourCrvs(strObject, arrStartPoint, arrEndPoint, 0.01)

    'makelayer & move To'
    For i = 0 To 100
    rhino.command("_selid " & arrContourStr(i))
    strLayer = Rhino.AddLayer(i)
    Rhino.CurrentLayer("strLayer")
    rhino.command("_ChangeToCurrentLayer")
    Rhino.UnselectAllObjects()
    Next
    End Sub

  • 5. tos (Nov 04, 2013 13.49):

    Sorry!
    I mistake comment statement.
    Change "//" to "'" at Line 8,11,17.

  • 4. Johannes (Nov 04, 2013 10.12):

    Hi, the "compilation error" points on an error in the syntax of your script.
    In this case the comment syntax is wrong. "//" is used in some languages like c#,... For vbscript you need to use "'" to write a comment to your script.

    ' your comment...
    ' next comment...

    See: en.wikipedia.org/wiki/Comment_%28computer_programming%29

    You need to add another loop structure around your function if you want to work with mulitple surfaces.
    "For each surface you selected do ... "

    Johannes

  • 3. Uog (Nov 04, 2013 07.19):

    Hi,

    Many thanks for the reply. It is highly appreciated.

    When I want to run the script, it gives the error seen on the attachment.

    I have one more question to ask, if I want to do same actions with random multiple surfaces or polysurfaces not with a basic solid object, how does the script change?

    Thank you again for your help.

    Run a command and create a new layer
  • 2. tos (Nov 02, 2013 03.34):

    Hi.

    0.01mm step for 10mm is 1000 contour? ( 10mm/0.01mm=1000 )

    This is 10 Layer sample.

    Option Explicit
    Call Main()
    Sub Main()
            Const rhObjectSurface = 8
            Const rhObjectPolysurface = 16
            Dim strObject, arrStartPoint, arrEndPoint, arrContourStr, i, strLayer

            // make box
            rhino.command("_Box 0 10 10 10")

            // make contour
            strObject = Rhino.GetObject("Select box", rhObjectSurface + rhObjectPolysurface)
            arrStartPoint = Rhino.GetPoint("Base point of center line")
            arrEndPoint = Rhino.GetPoint("Endpoint of center line", arrStartPoint)
            arrContourStr = Rhino.AddSrfContourCrvs(strObject, arrStartPoint, arrEndPoint, 1)

            //makelayer & move To
            For i = 0 To 9
                    rhino.command("_selid " & arrContourStr(i))
                    strLayer = Rhino.AddLayer(i)
                    Rhino.CurrentLayer(strLayer)
                    rhino.command("_ChangeToCurrentLayer")
                    Rhino.UnselectAllObjects()
            Next
    End Sub
  • 1. Uog (Oct 31, 2013 15.00):

    Hi,

    To be honest I have never worked with the RhinoScript before however i have faced with a problem at the office and I think RhinoScript can solve this problem.

    Here it comes ;

    Imagine that there is a cube 10 by 10 by 10 mm and i want to create a spaced series of planar curves at every "0,01 mm" of this object by using "Contour" tool. this is easy to do, however i want to keep every section in a different layer by automatically. I dont want to spend my time by creating 100 layers and assigning every line to those layers one by one.

    Is there a way to solve this problem ?

    many thanks for the consideration and help in advance.

    Regards,

    Onursal - Industrial Designer

Recommend

Why are these buttons gray?