
! script name: 3dcpaths.d/scutstrtmvs
! 3dtopic: add cutterpath start moves to a single curve

!A
!A NAME:
!A
!A 	3D Modify: Add Cut Start Moves
!A
!A DESCRIPTION:
!A
!A 	This script adds start moves to a Single Curve on a 3D Cutterpath.
!A
!B INSTRUCTIONS:
!B
!B 	PICK STARTHOLE GROUP: Pick the group of holes or points to be used
!B 		as startholes.
!B
!B 	PICK CURVE TO BE MODIFIED: Pick the cutterpath curve to be modified.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: add cutterpath curve start moves")

DIM Destination$[256]
DIM Answer$[256]
REAL Cuts(0:400)

Highlight_color=2

DeActivateUndo
Active_workplane=0
Work=CurrentWorkplane
IF ValidGeometry(Work) THEN Active_workplane=1

Stat=SetInputFormat("n4","")

Group_loop:!
Hold_group=CreateGroup("TEMPGROUP")
Stat=SetInputFormat("n4","")

Pick_holes:!
H1=PickSpecificEnt("PICK STARTHOLE",WsPickHoles)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(H1) THEN Pick_holes
Stat=AddToGroup(Hold_group,H1)

StdWorkplane

Pick_loop:!
StdWorkplane
N=GroupCount(Hold_group)
IF N<1 THEN 
	Stat=DeleteEntity(Hold_group)
	GOTO Group_loop
END IF

Pick_path:!
Ncuts=0

Ploop:!
Stat=SetInputFormat("a1",",M,U,C,")
E1=PickEntity("PICK CURVE TO BE MODIFIED, Undo, Clear, Modify ", Answer$)
IF ExitScript(Destination$) THEN Leave
SELECT Answer$
    CASE "M"
	GOTO Modify_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

Modify_cpaths:!

Checkz=1
Stat=CPathStartMoves(Hold_group,Cutterpath,Checkz,Cuts,Ncuts)
Stat=PlotEntity(Cutterpath)
Stat=DeleteEntity(Hold_group)

GOTO Group_loop

Leave:!
Stat=DeleteEntity(Hold_group)
IF Active_workplane THEN
	Stat=SetWorkplane(Work)
ELSE
	StdWorkplane
END IF
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
