
! script name: fouraxisturn.d/removesyncpts
! topic: remove sync points

!A
!A NAME:
!A	
!A	Remove sync points
!A
!A DESCRIPTION:
!A
!A	This script removes sync points from a four axis lathe path.
!A	Sync points are used to syncronize the motion of the two independent
!A	turrets on the lathe.
!A
!B INSTRUCTIONS:
!B
!B	PICK PATH FOR SYNC POINTS: Pick the contour that the 
!B				sync points are on.
!B
!B	PICK SYNC POINT,  All, Show, New, Exit: Pick the Sync point to be
!B				removed. All will remove all the sync points
!B				on that path. If an Undo/Redo is performed
!B				then Show will update the graphics.
!B				New selects a new lathe path.
!B				Exit will leave the script.
!B			
!B
!C NOTE:
!C
!C
!# see also - htdocs/help.d/fouraxisturn.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: Remove sync points ")

DIM Answer$[256]
DIM Destination$[256]
DEG

stat= SetInputFormat("n4","")

Pen_color= 3

ActivateUndo
Pick_contour: !
Stat=SetInputFormat("n4","")
Contour=PickGroupEnt("PICK PATH FOR SYNC POINTS")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Contour) THEN Pick_contour

Stat= DeleteGroup(Syncpts,WsTrue)
Syncpts= ContourSyncPoints(Contour)
Stat= SetForceVisible(Syncpts,WsTrue)
Stat= SetColor(Syncpts,Pen_color)
IF NOT ValidGeometry(Syncpts) THEN Pick_contour

Pick_loop: !
ActivateUndo
Stat=SetInputFormat("a1",",A,S,E,N,")
Element=PickEntity("PICK SYNC POINT,  All, Show, New, Exit ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "A" 
	Stat= DeleteGroup(Syncpts,WsTrue)
	ActivateUndo
	Stat= AdvanceUndoNumber("remove contour sync pts")
	Stat= AddGroupToUndo(WsUBModifyMode,Contour,1,WsTrue)

	Stat= RemoveSyncPoints(Contour)

	Syncpts= ContourSyncPoints(Contour)
	Stat= SetForceVisible(Syncpts,WsTrue)
	Stat= SetColor(Syncpts,Pen_color)
	GOTO Pick_contour
CASE "N"
	Stat= DeleteGroup(Syncpts,WsTrue)
	GOTO Pick_contour
CASE "E"
	GOTO Leave
CASE "S"
	Stat= DeleteGroup(Syncpts,WsTrue)
	Syncpts= ContourSyncPoints(Contour)
	Stat= SetForceVisible(Syncpts,WsTrue)
	Stat= SetColor(Syncpts,Pen_color)
	GOTO Pick_loop
CASE ELSE
	PlotOff
	T1= LastPickPara
	P1= ParameterPt(Element,T1)
	N= ClosestSyncPtNum(Contour,P1,1)
	Stat= DeleteEntity(P1)
	PlotOn
	IF N THEN
		Element= SyncPointEntity(Contour,N)
		Stat= DeleteGroup(Syncpts,WsTrue)
		ActivateUndo
		Stat= AdvanceUndoNumber("Remove sync pt")
		Stat= AddItemToUndo(WsUBModifyMode,Element)

		Stat= DeleteSyncPoint(Contour,N)
	END IF
END SELECT

Stat= DeleteGroup(Syncpts,WsTrue)
Syncpts= ContourSyncPoints(Contour)
Stat= SetForceVisible(Syncpts,WsTrue)
IF NOT ValidGeometry(Syncpts) THEN Pick_contour
Stat= SetColor(Syncpts,Pen_color)
GOTO Pick_loop

Leave:!
PlotOn
Stat= DeleteGroup(Syncpts,WsTrue)
stat= SetInputFormat("n4","")
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END


