
! script name: turbopost.d/cpathgroup

!A
!A NAME:
!A
!A 	PICK SURFACES
!A
!A DESCRIPTION:
!A
!A 	This script allows the user to select surfaces to be used for the
!A 	command file.
!A
!B INSTRUCTIONS:
!B
!B 	PICK 3D CUTTER PATH, Proceed: Pick a path to be cut.  Proceed will
!B 		return the user to the command menu.  This question will
!B 		repeat, depending upon the pick type, until Proceed is selected.
!B
!# see also - htdocs/help.d/millturbo.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: pick surfaces ")

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


DeActivateUndo
Paths_group= CreateGroup("TEMPGROUP")
Stat= SetDefaults(WsSelectedEntPen,WsPickPen)
Pick_loop:!

Stat=MakeActiveCurr

Stat=CurrActionName(Command$)
Command_type=CurrActionTyp

Pick_path:Stat=SetInputFormat("a6",",P,CANCEL,")
Path=PickEntity("PICK 3D CUTTER PATH,  Proceed",Answer$)
IF (ExitScript(Destination$)) THEN Leave

SELECT Answer$
CASE "CANCEL"
	GOSUB Unset_group
	Stat=SetPickMask(WsPickAll)
	LOAD "turbopost.d/turbocmd"
CASE "P","p"
	GOTO New_command
END SELECT

Etype= EntityType(Path)
IF NOT (Etype = WsCPathFileEnt) THEN Pick_path


IF NOT ElementGrpNum(Paths_group,Path) THEN
	Group= ParentGroup(Path,0)
	IF ValidGeometry(Group) THEN
		Number= GroupCount(Group)
	ELSE
		Number= 1
	END IF
	Stat= AddToGroup(Paths_group,Path)
	Stat= SetSelectedFlag(Path,WsTrue)
	Stat= PlotEntity(Path)
ELSE
	Group= 0
END IF

Output_path:!
FOR J= 1 TO Number
	IF ValidGeometry(Group) THEN Path= GroupElement(Group,J)
	Stat= CPathFileName(Path,Name$)
	A$="ASSIGN: Cutter_file= "&CHR$(34)&Name$&CHR$(34)&";" 
	Stat=OutputCmdBuff(A$,0)
	Stat=OutputCmdBuff(Command$,0)
NEXT J

IF Command_type=TpSurface THEN New_command
GOTO Pick_loop


New_command:!
	UpdateCmdFile
	Stat=SetPickMask(WsPickAll)
	Stat=SetInputFormat("n4=","")
	GOSUB Unset_group
	LOAD "turbopost.d/turbocmd"

Leave:!
GOSUB Unset_group
Stat=SetPickMask(WsPickAll)
IF (NOT LEN(Destination$)) THEN
	  LOAD "typecontrol"
ELSE
	  LOAD Destination$
END IF

Unset_group:!
	Stat= SetSelectedFlag(Paths_group,WsFalse)
	Stat= PlotEntity(Paths_group)
	Stat= DeleteEntity(Paths_group)
	RETURN
END
