Forgot password?

Create an account!

Forum

« back

RhinoScript – Rhino.CurveDirectionsMatch?

Messages

Please log in to write a message.

  • 10. Johannes (Aug 29, 2009 01.07):

    i have rhino with sr6... and its a new function in that sr. so you need to have at least sr6 to run that function...

  • 9. Johannes (Aug 29, 2009 01.06):

    i have rhino with sr6... and its a new function in that sr. so you need to have at least sr6 to run that function...

  • 8. drape (Aug 29, 2009 00.01):

    cool. but i can't test it. Rhino.ClosedCurveOrientation isn't supported. i have v4 sr5. What are you running?

  • 7. Johannes (Aug 28, 2009 00.10):

    i tried closedcurveorientation(). it seems to work... but it just work with closed planar curves.

    Option Explicit

    Call CrvDir()
    Sub CrvDir()

            Dim  strParent  : strParent = Rhino.GetObject("Pick parent")
            Dim  arrChilds  : arrChilds = Rhino.GetObjects("Pick childs")
           
            Dim i   
            Dim blncompare
           
            For i = 0 To Ubound(arrChilds) 

                    blnCompare = Rhino.ClosedCurveOrientation (arrChilds(i))

                    If blnCompare = 1 Then

                            Rhino.Print "Curves are in the same direction"
                            rhino.ObjectColor arrChilds(i), rgb(0,255,0)
                    Else

                            Rhino.Print "Curve are not in the same direction"
                            rhino.ObjectColor arrChilds(i), rgb(255,0,0)
                    End If
                   
            Next

    End Sub
  • 6. Johannes (Aug 27, 2009 18.44):

    i tried out with an array of 5x5 circles (planar on xy-plane)... and -like you told me- sometimes it works and sometimes not... hmmm.... i have no answer for that. but i will try out some more options...

  • 5. drape (Aug 27, 2009 17.31):

    Johannes,

    In my first post I posted the scripts I'm using showing that curve direction matching doesn't seem to work consistently in Rhino. I also described the file I was testing it on ( a simple 5x5 array of circles or any closed curve (except hexagons!) is good for a test). I am using simple planar curves.

    It will take you a minute to try out my test and see that it doesn't work.

    My steps:
    - make array of closed curves
    - randomize directions of curves - 1st script: RandomizeCurveDir()
    - (try to) match curve directions - 2nd script: MatchCurveDirs()

  • 4. Johannes (Aug 26, 2009 22.41):

    oh... i don't know your project so its difficult to give an answer. it depends on what you expect of your script... its quiet difficult to orient curves in a 3d-dimansional space in the same direction. Do two curves with the same startpoint have the same direction?
    i think thats the reason why the curvedirectionmatch sometimes work like you want.

  • 3. drape (Aug 26, 2009 19.39):

    That's the thing - I have tried out the sample script extensively. It always seems to work using GetObject but not in a loop....except if you are working with pentagons! That's right, with an array of pentagons my scripts work. With any other shape or curves they don't work consistently. Very strange.

    Anyway, I was going to write my own before I found Rhino.CurveDirectionsMatch. What would you do to write your own function?

  • 2. Johannes (Aug 26, 2009 15.20):

    Hi,

    try out the sample script for Rhino.CurveDirectionsMatch. You will see that this function doesn't work like you want....and thats the reason why your script doesn't work.

    I think the best way would be, if you write your own CurveDirectionsMatch function....

    Johannes

  • 1. drape (Aug 26, 2009 09.14):

    I am having trouble making "Rhino.CurveDirectionsMatch" work.

    First I make an array of closed curves (say 5x5) and apply this dir randomization script:

    ' //

    Option Explicit

    Call RandomizeCurveDir()
    Sub RandomizeCurveDir()

    Dim arrObjects, strObject, selObject

    arrObjects = Rhino.GetObjects ("Select curves to randomize")

    Rhino.EnableRedraw vbFalse

    For Each strObject In arrObjects
    If Rhino.IsCurve(strObject) Then
    selObject = rnd*1
    If selObject > .5 Then
    Rhino.ReverseCurve strObject
    End If

    End If
    Next

    Rhino.EnableRedraw vbTrue

    End Sub

    '
    //

    That works. Then I apply this script to make each curve in the array the same dir as one reference curve:

    ' //

    Option Explicit


    Call MatchCurveDirs()
    Sub MatchCurveDirs()

    Dim refCurve, arrCurves, strObject
    Dim CurveCount, blnCompare
    Dim i

    refCurve = Rhino.GetObject ("Select Reference Curve", 4)
    arrCurves = Rhino.GetObjects ("Select Curves to match to Reference Curve", 4)

    For i = 0 To Ubound (arrCurves)
    blnCompare = Rhino.CurveDirectionsMatch(refCurve, arrCurves(i))

    If blnCompare = False Then
    Rhino.ReverseCurve arrCurves(i)
    End If

    Next

    End Sub
    '
    //

    This does not work. I can't figure out why it doesn't.

    It is changing the dir of _some_ curves each time. Why some and not all I don't know.

Recommend

Why are these buttons gray?