Forgot password?

Create an account!

Forum

« back

RhinoScript – OffsetCurve

Messages

Please log in to write a message.

  • 3. maxofa (Nov 17, 2009 16.09):

    Thanks Johannes for your precious help!

    The Rhino.CurvePoints() function worked on a test object but it seems that the Dim membA for my OffsetCurve is not working properly. I can not pass this line... string required... any clue on this one? Thank you so much in advance!

    Call Main()
    Sub Main()

    Dim i, j, k
    Dim x, y, z
    Dim imax, jmax, kmax

    imax = Rhino.GetInteger ("max number of point in x", 4)
    jmax = Rhino.GetInteger ("max number of point in y", 4)
    kmax = Rhino.GetInteger ("max number of point in z", 2)

    imax = imax - 1
    jmax = jmax - 1
    kmax = kmax - 1

    ReDim arrPtsMatrix(imax, jmax, kmax)

    Call Rhino.EnableRedraw(False)

    For i = 0 To imax
    For j = 0 To jmax
    For k = 0 To kmax

    x = i * 1200
    y = j * 1200
    z = k * 600

    arrPtsMatrix(i,j,k) = array(x,y,z)

    If i>0 And j>0 And k>0 Then

    Dim polyBottom
    polyBottom = Rhino.AddPolyline (array (arrPtsMatrix(i,j-1,k-1),arrPtsMatrix(i,j,k-1),arrPtsMatrix(i-1,j,k-1),arrPtsMatrix(i,j-1,k-1)))

    Dim polyCentroid
    polyCentroid = Rhino.CurveAreaCentroid (polyBottom)
    Dim ptCentroid
    ptCentroid = Rhino.AddPoint (polyCentroid(0))
    ptCentroid = Rhino.PointCoordinates (ptCentroid)

    Dim plateThickness : plateThickness = 12
    Dim membThickness : membThickness = 25

    Dim membA, arrPointsA, arrPointA
    membA = Rhino.OffsetCurve (polyBottom, ptCentroid, plateThickness)

    arrPointsA = Rhino.CurvePoints(membA)
    For Each arrPointA In arrPointsA
    Call Rhino.AddPoint (arrPointA)
    Next

    Dim membAA : membAA = Rhino.OffsetCurve (polyBottom, ptCentroid, membThickness + plateThickness)

    End If

    Next
    Next
    Next

    Call Rhino.EnableRedraw(True)

    End Sub

  • 2. Johannes (Nov 17, 2009 08.59):

    hi,

    if you run the script with one polyline or curve the result of the Rhino.OffsetCurve will be also one polyline or curve. (membA(0))

    try the Rhino.CurvePoints() function to get the edge points of the polyline. the result is an array with all curvepoints. then you can add the points with rhino.addpoints() (start and end point will be duplicatet) or add the points in a loop from 0 to Ubound(result)-1 (no duplicatet points).

    johannes

  • 1. maxofa (Nov 17, 2009 06.00):

    Hi guys,

    I am trying to create 1 points at the end of each line of a triangle that have been previously offset. I tried to put points at he end or start of the curve but I only have one point instead of 3. It is probably because The OffsetCurve returns an array so anybody have an idea on how to resolve that?


    Here is my code

    Call Main()
    Sub Main()



    Dim polyBottom
    polyBottom = Rhino.GetObject("curve",4)

    Dim polyCentroid
    polyCentroid = Rhino.CurveAreaCentroid (polyBottom)
    Dim ptCentroid
    ptCentroid = Rhino.AddPoint (polyCentroid(0))
    ptCentroid = Rhino.PointCoordinates (ptCentroid)

    Dim plateThickness : plateThickness = 12
    Dim membThickness : membThickness = 25

    Dim membA : membA = Rhino.OffsetCurve (polyBottom, ptCentroid, plateThickness)
    Dim arrStartPtA : arrStartPtA = Rhino.CurveStartPoint(membA(0))
    Call Rhino.AddPoint (arrStartPtA)

    Dim membAA : membAA = Rhino.OffsetCurve (polyBottom, ptCentroid, membThickness + plateThickness)
    Dim arrStartPtAA : arrStartPtAA = Rhino.CurveStartPoint(membAA(0))
    Call Rhino.AddPoint (arrStartPtAA)

    Call Rhino.AddLine (arrStartPtA, arrStartPtAA)


    End Sub

Recommend

Why are these buttons gray?