
! script name: v3dcpaths.d/cpthcontleadgp
! var_topic: contour leadin  into a group of cutterpaths

!A
!A NAME:
!A
!A 	3D Modify: Insert Contour Leadin on Cutterpath Group   VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script inserts a contour leadin  into a group of Cutterpaths.
!A      The contours are drawn in the standard workplane. It will be
!A      placed onto the workplane of the cutterpath by the routine.
!A      The leadin contour is moved so that the endpoint of the contour
!A      is attached to the cutterpath.
!A      The leadout contour is moved so that the startpoint of the contour
!A      is attached to the endpoint of the cutterpath.
!A      Rapid or Feed Factors attached to the contours will be applied to
!A      the cutterpath leadin moves.
!A
!B INSTRUCTIONS:
!B
!B 	PICK LEAD-IN CONTOUR: Pick the contour to be the leadin.
!B
!B 	PICK LEAD-OUT CONTOUR: Pick the contour to be the leadout.
!B
!B 	PICK CUTTERPATH: Pick the cutterpath. 
!B
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function:  cpath group contour leadin ")

DIM Destination$[256]
DIM Answer$[256]
DIM Scontour$[256]
DIM Econtour$[256]
DIM Group$[256]


Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

DeActivateUndo
Highlight_color=3

Scontour_pick:!
Stat=SetInputFormat("a1",",N,")
Scontour=PickGroupEnt("PICK LEAD-IN CONTOUR,  None ",0,Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$="N" THEN
	Scontour$="*****"
ELSE
	IF NOT ValidDependency(Scontour) THEN Scontour_pick
	Stat= EntityNameCheck(Scontour,Scontour$)
END IF

Econtour_pick:!
Stat=SetInputFormat("a1",",N,")
Econtour=PickGroupEnt("PICK LEAD-OUT CONTOUR,  None ",0,Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$="N" THEN
	Econtour$="*****"
ELSE
	IF NOT ValidDependency(Econtour) THEN Econtour_pick
	Stat= EntityNameCheck(Econtour,Econtour$)
END IF


Pick_loop:!
Stat=SetInputFormat("n4","")
Group=PickGroupEnt("PICK GROUP OF CUTTERPATHS",0)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Group) THEN Pick_loop
Stat= EntityNameCheck(Group,Group$)


Stat=EraseEntity(Group)
RecordFunctionOn
Stat= RecordDescr("MODIFY CUTTERPATH GROUP: Insert contour leadinout ")
Stat=CpathContLeadIn(Group$,Scontour$,Econtour$)
RecordFunctionOff
CloseVarRecord

Stat=PlotEntity(Group)
GOTO Scontour_pick

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