Forgot password?

Create an account!


« back

RhinoScript – String to number?


Please log in to write a message.

  • 4. ledisnomad (May 19, 2011 00.45):

    So quick! Thank you Johannes. I'll test this out ASAP.

  • 3. Johannes (May 19, 2011 00.11):

    take a look on the return of the function.
    Rhino.GetObject gives you the object id... so you got no value...
    but you can read the value of an text object with another function:

            Dim strTxtID  : strTxtID  = Rhino.GetObject("txt object",,False)
            Dim strTxt    : strTxt    = Rhino.TextObjectText(strTxtID)
            Dim dblHeight : dblHeight = CDbl(strTxt)
            Call Msgbox(dblHeight)
  • 2. ledisnomad (May 18, 2011 23.22):

    Quick update: I tried CDbl(strTxt), but I get a type mismatch error. I checked the properties of the text object and this is what it looks like:

    ID: f61d8510-2984-4ae5-b304-ff2427b066d4 (134648)
    Layer name: \U+5C45\U+6C11\U+5730\U+548C\U+57A3\U+6805
    Render Material:
    source = from layer
    index = -1
    Valid annotation.
    Text object
    Text height in model units: 0.875
    Text: "238.90"
    Font index: 2

  • 1. ledisnomad (May 18, 2011 23.10):

    I thought this would be simple: given a text object with just numbers, like "293.82", convert it to a number. I'd like to specify a move based on text in my model.

    Here's what I have so far:

    Call MoveVerticallyByText()
    Sub MoveVerticallyByText()

            Dim strObj : strObj = Rhino.GetObject("Select the object to move",,False)
            If IsNull(strObj) Then Exit Sub
            Dim strTxt : strTxt = Rhino.GetObject("Select the height text",,False)
            If IsNull(strTxt) Then Exit Sub

            'Rhino.Print "strTxt is of type " & TypeName(strTxt)
            Dim height : height = 'convert strTxt to number here
            Dim arrStart, arrEnd
            arrStart = Array(0,0,0)
            arrEnd = Array(0,0,height)
            Call Rhino.MoveObject(strObj,arrStart,arrEnd)
    End Sub

    Any help?


Why are these buttons gray?