Forgot password?

Create an account!

Forum

« back

RhinoScript – brain about to explode needs help...

Messages

Please log in to write a message.

  • 5. S_Man (May 11, 2010 10.37):

    It works! Thank you very much Hanno!

    I was that obsessed with the "point" that I forgot about the answer!!

    thank you very very much!!!

  • 4. Hanno (May 11, 2010 10.28):

    When writing

    rhino.MoveObject(polygon,pt0,intpt)

    you are mixing up geometrical 3d-points and rhino point object IDs. Try using int(0) instead of intpt.

  • 3. S_Man (May 11, 2010 10.22):

    Hi Hanno!

    Thx for trying to help me...I've already tryied that...

    when using
    intpt = Rhino.addpoint(int(0))

    instead of
    intpt = Rhino.addpoint(int)

    stills give me the error...that's why I'm about to eat my computer...

  • 2. Hanno (May 11, 2010 10.05):

    Hi,

    you have to be careful about the return value of rhino methods. Often when there can be more than one results, methods return an array. So in your case, Rhino.ProjectPointToSurface returns an Array of points.
    So if you want to access the first point in your array (which might also be the only one), you can simply use int(0) to access it.
    However, for stability reasons I always recommend checking return values first, like If not isarray(int) Then print something and exit.

    Hope that helps!

    Hanno

  • 1. S_Man (May 11, 2010 09.57):

    Hi guys!
    I'm kinda noob in scripting and after some days squeezing my brain to solve the problem...I need some help...

    In that script, I give some surfaces (tile) and need to find the centroid the projection of it onto a topographic surface and move the previous surface at that high.
    I even get the point projectet in the surface and just need to do the "move" command...but always crashes when using the projected point...

    Here's the code...and let's hope somebody sees the light!!
    Btw, the error output is "type mismatch in parameter. one-dimensional array"
    Thx!!



    Option Explicit
    'Script written by
    'Script copyrighted by
    'Script version Monday, 10 May 2010 09:55:50

    Call Main()
    Sub Main()
    Dim arrPolygons : arrPolygons=Rhino.GetObjects("select polygons for panel creation ",8)
    Dim srfExterior : srfExterior=Rhino.GetObject("Select now the boundary Surface LĂ­mit",0)

    If isNull (arrPolygons) Then Exit Sub

    Dim polygon
    For Each polygon In arrPolygons
    Call cushion(polygon,srfexterior)

    Next
    End Sub
    Sub cushion(polygon,srfexterior)

    Dim arrsrf, srf

    Dim centerpt, center

    center= Rhino.SurfaceAreaCentroid(polygon)

    If IsArray(center) Then
    Rhino.AddPoint center(0)
    End If



    Dim path
    Dim pt0, pt1, pt2
    pt0 = array (center(0)(0),center(0)(1), center(0)(2))
    pt1 = array (center(0)(0),center(0)(1), center(0)(2)+25)
    pt2 = array (center(0)(0),center(0)(1), center(0)(2)-25)
    path = rhino.addline (pt1,pt2)

    Call rhino.Command("_sellast")
    Call rhino.Command("_delete")

    Dim int, intpt()

    int = Rhino.ProjectPointToSurface(pt0, srfexterior, Array(0,0,1))
    intpt = Rhino.addpoint(int) <----HERE'S WHERE I GET THE ERROR!!!

    Call rhino.MoveObject(polygon,pt0,intpt)
    End Sub

Recommend

Why are these buttons gray?