
! script name: 3dcpaths.d/delcpathcut
! 3dtopic: deletes a single cut from a 3D cutterpath

!A
!A NAME:
!A
!A 	3D Modify: Delete Cut
!A
!A DESCRIPTION:
!A
!A 	This script allows a single cut on a 3D cutter path to be deleted.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CURVE TO BE DELETED, Undo, Clear, Delete: Pick the curve to be
!B 		deleted.
!B
!B 		U - Undo works in a recursive manner.  The curves will be
!B 		    undeleted in the reverse order in which they were selected.
!B 		C - Clear means that the highlighted curves will not be deleted
!B 		    and the script will start over.  If Delete has been used,
!B 		    those elements are still gone.
!B 		D - Delete finalizes the deletion process for all the curves
!B 		    presently highlighted.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: delete 3d cutter path cut")

DIM Destination$[256]
DIM Answer$[256]
REAL cuts(0:500)

DeActivateUndo
Highlight_color=2

Start:!
Ncuts=0

Ploop:!
Stat=SetPickMask(WsPickGeometry)
Stat=SetInputFormat("a1",",D,U,C,")
E1=PickEntity("PICK CURVE TO BE DELETED, Undo, Clear, Delete ", Answer$)
IF ExitScript(Destination$) THEN Leave
SELECT Answer$
    CASE "D" 
	GOTO Del_cpaths
    CASE "U"
	Ncuts=Ncuts-1
	IF Ncuts<0 THEN Ncuts=0
	IF ValidGeometry(Cutterpath) THEN 
		Pen1=GetColor(Cutterpath)
		Stat=PlotEntity(Cutterpath,pen1)
		Stat=HighlightCpath(Cutterpath,Cuts,Ncuts,Highlight_color)
	END IF
	GOTO Ploop
    CASE "C"
	IF ValidGeometry(Cutterpath) THEN 
		Pen1=GetColor(Cutterpath)
		Stat=PlotEntity(Cutterpath,pen1)
	END IF
	GOTO Start
END SELECT
IF NOT ValidGeometry(E1) THEN Ploop

Etype=EntityType(E1)
IF Etype=WsCPathFileEnt THEN
	IF Ncuts=0 THEN Cutterpath=E1
	T=LastPickPara
	Path=INT(T)
	Cuts(Ncuts)=Path
	Ncuts=Ncuts+1
	Stat=HighlightCpath(Cutterpath,Cuts,Ncuts,Highlight_color)
END IF
GOTO Ploop

Del_cpaths:!
IF ValidGeometry(Cutterpath) THEN 
	IF Ncuts>0 THEN
		Stat=DeleteCpathCuts(Cutterpath,Cuts,Ncuts)
	END IF
END IF

GOTO Start

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