Forgot password?

Create an account!

Forum

« back

RhinoScript – type mismatch parameter. string required.

Messages

Please log in to write a message.

  • 2. Johannes (Dec 14, 2011 09.19):

    hi. the rhinoscript method Rhino.GetPoints() returns an array of 3d points an no array of strings. that's the reason why you get that message. try xyzPt = attArr(i) instead of xyzPt = Rhino.PointCoordinates(attArr)... or try instead of the whole loop attXYZArr = attArr. if you do so... you can replace attXYZArr with
    attArr because they are equal.
    take a look at the two functions Rhino.GetPoints() and Rhino.GetObjects()...

    johannes

  • 1. kylieanne (Dec 14, 2011 01.28):

    Very new to Scripting. I am trying to create a simple point attractor and when it gets to the line "xyzPt = Rhino.PointCoordinates(attArr)" it says "type mismatch parameter. string required." I have been trying several different things but my knowledge of this program is very limited. Any help would be great, thank you!

    Call Main()
    Sub Main()

            Dim arrCenter, dblRadius
            Dim x, y
            dblRadius = Rhino.GetReal("Radius of Circle", 5)
           
            For x = 0 to 100 step 10
                    For y = 100 to 0 step -10
                           
                           
                            arrCenter = Array(x, y)
                            dblRadius = 5
                           
                            Rhino.AddCircle arrCenter, dblRadius
                                   
                    Next
            Next

           
            Dim attArr, objArr, attXYZArr(), i, xyzPt, thresholdDistance
           
            attArr = Rhino.GetPoints(True, True, "Add Points, then hit Enter")
            If IsArray(attArr) Then
                    Rhino.AddPoints attArr
            End If
           
            objArr = Rhino.GetObjects("Select the Objects to Scale", 12)
            thresholdDistance = Rhino.GetReal("Threshold Distance", 100)
           
            ' loop through all the attractors
            For i = 0 To UBound(attArr)
                    ' extract xyz coords
                    xyzPt = Rhino.PointCoordinates(attArr)
                   
                    ' add xyz's to an array
                    ReDim Preserve attXYZArr(i)
                    attXYZArr(i) = xyzPt
                   
            Next


            Dim centerPt, closestPtIndex, dist
            ' loop through all the objects
            For i = 0 To UBound(objArr)
                    ' find the center point
                    centerPt = bBoxCenter(objArr(i))
                   
                    ' find the closest attractor
                    closestPtIndex = Rhino.PointArrayClosestPoint(attXYZArr, centerPt)
                   
                    ' find distance to closest attractor
                    dist = Rhino.Distance(attXYZArr(closestPtIndex), centerPt)
                   
                    ' scale the obj
                    Dim adjAmount
                   
                    If (dist < thresholdDistance) Then

                            adjAmount = 1 - ( (thresholdDistance - dist) / thresholdDistance )
                            Rhino.ScaleObject objArr(i), centerPt, Array(adjAmount, adjAmount, adjAmount)
                           
                    End If
            Next
           
    End Sub


    Function bBoxCenter(obj)

            Dim bbox
           
            ' get the bounding box
            bbox = Rhino.BoundingBox(obj)
           
            ' return the center
            bBoxCenter = Array((bbox(0)(0) + bbox(6)(0)) / 2, (bbox(0)(1) + bbox(6)(1)) / 2, (bbox(0)(2) + bbox(6)(2)) / 2)
           
    End Function
Recommend

Why are these buttons gray?