V6 Join different to V5

I started a thread in the script forum because a script i’ve used for a while doesn’t work in v6, after some testing I traced the problem to join. In v5 if I join 2 curves into a closed curve the start point will be at the end of the first curve selected but in V6 it’s moved to a random place. See attached screencast and file. Any workarounds will be appreciated.

Thanks Mark

temp.3dm (33.2 KB)

Mark, that clip is impossible to follow - but looking at your files and running Join I see the difference - looks like running SimplifyCrv first helps in V6.

-Pascal

At what point are you running simplify? If you look at the thread in the script forum you’ll see I’m trying to split a closed curve and set a start point. The script works fine in V5 but the start point is moved to random places.

The screencast was supposed to show that joining in V6 moves the startpoint to a point not where either curve started or ended, in V5 the start is always at the end of the first curve selected.

Thanks Mark

Hi Mark - I do see the difference in Join - for now, I’d say your script could check the version of Rhino running and direct the flow to one or the other accordingly.

-Pascal

The reverse trick doesn’t work on the curve in this post. I tried simplify but it still moves the start to the wrong place.

I can get the start in either of the black circles below but not the red one where I need it. I need to set where the start point is needed then a pause point just before it so can’t really pick the points in the opposite order.

Thanks mark

Hi Mark - see if something like this gets you going - I’m not sure that I know where to click and how to use your script -but it may help.


            if newCurve:
                if rs.ExeVersion() > 5:
                    for crv in newCurve:
                        rs.SimplifyCurve(crv,0)
                curve = rs.JoinCurves(newCurve, True)
                

Hm - no, it still winds up in a different place sometimes.

@Hughes_Tooling - Mark, what is determining where that seam point should fall? - is it a point that the user sets at any point in the process?

-Pascal

Sorry didn’t explain very well.
You start with a closed curve and need to move start to a more convenient place so the first pick is where the start is needed then the second in a pause point just before. The script can handle one or 2 closed curves, if only one just hit enter after the first selection. I’ve attached the original curve and a screencast done in V5. I’ve experimented with simplify and reversing the list of curves but can’t get the start of the curve correct in V6. I’ve attached my original script and one for V6 I’ll look at combining when the V6 one works.temp.3dm (33.5 KB)
SplitCurveV6.py (3.4 KB)
SplitCurve.py (3.1 KB)



Thanks Mark

EDIT Might not be clear in the screencast, when I click the adjust curve seam the second time I right click to run my script.

Hi Mark - I’d force the issue and set the seam point explicitly, then you don’t have to care what Rhino does.


            param = rs.CurveClosestPoint(curve2, point[1]) 
            newCurve += rs.SplitCurve( curve2, param )
            rs.AddPoint(point[1])
            if newCurve:
                joinedCrv = rs.JoinCurves(newCurve, True)[0]
                if joinedCrv:
                    if rs.IsCurveClosed(joinedCrv):
                        crvGeo = sc.doc.Objects.Find(joinedCrv).Geometry #<<< Import scriptcontext as sc at the top of the script
                        crvGeo.ChangeClosedCurveSeam(point[1]) #<<< or whatever point works for the process
                        sc.doc.Objects.Replace(joinedCrv,crvGeo) 

@Hughes_Tooling - Mark, Any luck doing it this way?

-Pascal

Hi Pascal
Not sure if I’m missing something. Just testing on a single closed curve with the script below and getting an error from ChangeClosedCurveSeam, I think it’s expecting a domain not a point but not sure?

import rhinoscriptsyntax as rs
import scriptcontext as sc

def SetStartStop(curve):

    if curve and rs.IsCurve(curve):
        if rs.IsCurveClosed(curve):
            rs.Command('_CrvSeam _selid ' + str(curve) + ' _Enter')
        else:
            rs.Command('_dir _selid ' + str(curve) + ' _Enter')
        stpoint = rs.CurveStartPoint(curve)
        stpointid = rs.AddPoint(stpoint)
        point = rs.GetPointOnCurve(curve, "Pick stop point")

        if point:
            #rs.AddPoint(point)
            param = rs.CurveClosestPoint(curve, point)
            #print "Curve parameter:", param
            newCurve = rs.SplitCurve( curve, param )
            if newCurve:
                joinedCrv = rs.JoinCurves(newCurve, True)[0]
                if joinedCrv:
                    if rs.IsCurveClosed(joinedCrv):
                        crvGeo = sc.doc.Objects.Find(joinedCrv).Geometry #<<< Import scriptcontext as sc at the top of the script
                        crvGeo.ChangeClosedCurveSeam(stpoint) #<<< or whatever point works for the process
                        sc.doc.Objects.Replace(joinedCrv,crvGeo)
        rs.DeleteObject(stpointid)
        return(joinedCrv)

Hi Pascal Ok figured it out, addad CurveClosestPoint to get the parameter for rvGeo.ChangeClosedCurveSeam

Thanks for your help with this

                        param = rs.CurveClosestPoint(joinedCrv, stpointid)
                        crvGeo.ChangeClosedCurveSeam(param) #<<< or whatever point works for the process
```

Yeah, sorry - haste making waste, again - you’re right, it takes a param not a point. Glad you figured it out…

-Pascal