
! script name: v4axisturn.d/grpsetsyncpts
! var_topic: set a group of sync point on a path

!A
!A NAME:
!A
!A	Group Set Sync Points VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	Set a group of sync points on a path.
!A
!B INSTRUCTIONS:
!B
!B	PICK PATH FOR SYNC POINTS: Pick the path that the 
!B				sync points are on.
!B
!B	PICK PATH
!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
!C      This script is not set up to allow the Sync Number to be
!C      a variable. This may be done after the record is created by
!C      changing the free parameter into a variable.
!C
!C	This script is variational is should only be used on paths
!C	created variationally. Failure to do this will result in
!C	multiple occurances of the sync points.
!C	
!# see also - htdocs/help.d/fouraxisturn.htm

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

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

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

stat= SetInputFormat("n4","")
Stat=SetXyzInput(WsLatheInput)

Sync_number=1
Pen_color= 3


Pick_contour: !
ActivateUndo
Stat=SetInputFormat("n4","")
Contour=PickGroupEnt("PICK PATH FOR SYNC POINTS")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Contour) THEN Pick_contour
IF IsEntVariational(Contour)= WsFalse THEN
        Stat= MessageStringBox("Path must be variational","Error")
        GOTO Pick_contour
END IF
Stat= EntityNameCheck(Contour,Contour$)
IF NOT LEN(Contour$) THEN Pick_contour

Pick_group: !
ActivateUndo
Stat=SetInputFormat("n4","")
Group=PickGroupEnt("PICK GROUP OF POINTS")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Group) THEN Pick_group
Stat= EntityNameCheck(Group,Groupname$)
IF NOT LEN(Groupname$) THEN Pick_group


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

ActivateUndo
Stat= AdvanceUndoNumber("set sync pt")
Stat= AddGroupToUndo(WsUBModifyMode,Contour$,1,WsTrue)

RecordFunctionOn
Stat=RecordDescr("FOUR AXIS TURN: Group Set Sync Points")
Stat= GrpSetSyncPts(Groupname$,Contour$)
Stat= DeleteEntity(Pt)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)

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

GOTO Pick_contour

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


