
! script name: fouraxisturn.d/setsyncpoint
! topic: set a sync point on an element.
!A
!A NAME:
!A
!A	Set Sync Point 
!A
!A DESCRIPTION:
!A
!A	Set a sync point on a entity.
!A
!B INSTRUCTIONS:
!B
!B	PICK PATH FOR SYNC POINTS: Pick the path that the 
!B				sync points are on.
!B
!B	PICK THE ENTITY THE SYNC POINT WILL BE ON: Pick the entity on the
!B			path on which the sync point will be placed. This
!B			entity must be on the same path as the rest of the
!B			sync points.
!B			
!B	SYNC POINT LOCATION: Input or pick the location of the sync point.
!B
!B	SYNC NUMBER:  Number assigned to sync point. For reference only.
!B		      The order of the sync points is determined by their
!B		      occurance along the contour.
!B
!C NOTE:
!C
!C	Sync points are locations on a contour which are used in
!C	four axis dual turret turning. The sync points are places 
!C	where the tool motion for each of the turrets are coordinated. 
!C	The contours for the two turrets must 
!C	have the same number of sync points. 
!C	Some sync points may be multiple at the same location when
!C	one of the turrets is to be stationary.
!C	The Sync numbers are for reference only. The actual numbers
!C	(if required) for the machine tool are generated by the turbo post.
!C
!# see also - htdocs/help.d/fouraxisturn.htm


stat=ChangeLabelStr("ScriptNameStatus","Function: set sync point ")

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

stat= SetInputFormat("n4","")

Sync_number=1
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)

ActivateUndo
Pick_loop: !
Stat=SetInputFormat("n4a1",",N,")
Element=PickEntity("PICK ENTITY THE SYNC POINT WILL BE ON  New contour",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="N" THEN Pick_contour
N1= ElementGrpNum(Contour,Element)
IF NOT N1 THEN
        Stat= MessageStringBox("Entity must be on path","Error")
        GOTO Pick_loop
END IF

Pick_point:!
Stat=SetInputFormat("n4","")
Pt=XyzInput("SYNC POINT LOCATION",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pt) THEN Pick_point

Stat=SetEqualsValue(Sync_number)
Stat=SetInputFormat("n4=","")
Sync_number=GetValue("SYNC NUMBER",Answer$)
IF (ExitScript(Destination$)) THEN Leave

ActivateUndo
Stat= AdvanceUndoNumber("set sync pt")
Stat= AddItemToUndo(WsUBModifyMode,Element)

Stat= SetSyncPoint(Element,Pt,Sync_number)
Stat= DeleteEntity(Pt)

Stat= DeleteGroup(Syncpts,WsTrue)
Syncpts= ContourSyncPoints(Contour)
Stat= SetForceVisible(Syncpts,WsTrue)
Stat= SetColor(Syncpts,Pen_color)
GOTO Pick_loop

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


