! script name: contrib/ascript/tsm.d/changestartpt
! topic: change start point of contour
! Version_270423.a

!A
!A NAME:
!A
!A      Change Start Point
!A
!A DESCRIPTION:
!A
!A      This script allows the start point of a contour to be changed.
!A
!B INSTRUCTIONS:
!B
!B      PICK CONTOUR: Pick an element on the contour that will
!B              have its start point changed.
!B
!B      START POINT ABS X,Y: Enter the X,Y coordinates of the
!B              new start point of the contour.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: change startpt ")

DIM Answer$[256]
DIM Destination$[256]
DIM Name$[256]



ActivateUndo
Change_loop:!

Contour=PickGroupEnt("PICK CONTOUR ")
IF (ExitScript(Destination$)) THEN Leave

Stat=Highlight(Contour,WsHighlightPen,WsDirArrowOn)


Pt= XyzInput("NEW START POINT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

Contour1= CopyGroup(Contour)
ActivateUndo
Stat= AdvanceUndoNumber(" change start point ")
Stat= AddGroupToUndo(WsUBDeleteMode,Contour,1,WsTrue)

Stat= ChangeStartPt(Contour1,Pt)
stat= GroupName(Contour,Name$)
Stat=DeleteGroup(Contour,WsTrue)
stat= ChangeGrpName(Contour1,Name$)

Stat=Highlight(Contour1,WsAutoseqPen,WsDirArrowOn)
Stat= AddGroupToUndo(WsUBCreateMode,Contour1,1,WsTrue)

Stat= DeleteEntity(Pt)

Stat=Highlight(E1,WsHighlightPen,WsDirArrowOn)


GOTO Change_loop

Leave:!
IF Active_workplane THEN
        Stat=SetWorkplane(Work)
ELSE
        StdWorkplane
END IF
IF (NOT LEN(Destination$)) THEN
         LOAD "typecontrol"
ELSE
         LOAD Destination$
END IF
Stat=Highlight(Contour,WsAutoseqPen,WsDirArrowOn)
END
