Shortcut to set start point? Script to set start point?



  • Is there a shortcut (or a way to set one) that would set a start point as the currently-selected node?

    I haven't been able to find it, but I'd like it to be quick to do, so I've tried scripting something simple. However, I'm not quite getting it right, just yet...

    # NOT YET WORKING
    
    glyph = CurrentGlyph()
    
    for contour in glyph:
        for segment in contour:
            for point in segment:
                if point.selected == True:
                    startSegment = segment.index
                    print(startSegment)
                # check if startSegment was set
                if 'startSegment' in vars():
                    contour.setStartSegment(startSegment)
    

    I see that point.index is read-only So, am I correct in thinking that contour.setStartSegment is the appropriate way to set a start point in script? Am I simply making a dumb mistake in my Python? Or, is there some other approach that I'm missing entirely?

    Thanks for any insight!



  • You can set that shortcut under Preferences > Glyph View > Hot Keys > Set Start Point.


  • admin

    hi @ThunderNixon. this version seems to work:

    glyph = CurrentGlyph()
    
    if len(glyph.selectedPoints) == 1:
        for contour in glyph:
            for segment in contour:
                for point in segment:
                    if point.selected == True:
                        startSegment = (segment.index + 1) % len(contour) 
                        contour.setStartSegment(startSegment)
                        point.selected = False
    else:
        print('please select one point!')
    

    this will do the same as choosing Set Start Point from the contextual menu (right-click on point):

    Screen Shot 2019-04-11 at 07.20.14.png



  • You can set that shortcut under Preferences > Glyph View > Hot Keys > Set Start Point.

    Oh god. Haha, I've found that in the past, and just managed to forget. Thanks for pointing out the obvious!



  • @gferreira

    Awesome, thanks for showing the correct code, as well! It's helpful as I get my head into RoboFont scripting again. I didn't anticipate a modulo being part of the answer ... I need to go back to YouTube to relearn when to reach for that


  • admin



  • @gferreira Amazing, thanks! Hmm, I was only aware of the even/odd use case. This is cool!