
! script name: 3dcpaths.d/combinecpaths
! 3dtopic: combines two 3d cutterpaths or a group of cpaths

!A
!A NAME:
!A
!A 	Combine two 3d cutterpaths or a group of cutterpaths
!A
!A DESCRIPTION:
!A
!A 	This script combines two cutterpaths or combines a group 
!A      of cutterpaths into a single cutterpath.
!A
!B INSTRUCTIONS:
!B
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: combine 3d cutter paths ")

DIM Destination$[256]
DIM Answer$[256]
DIM Cpath1_name$[256]
DIM Cpath2_name$[256]
DIM Group_name$[256]

Ploop:!
Highlight_pen=2

Pick_1:Stat=SetPickMask(WsPickGeometry)
E1=PickEntity("PICK CUTTER PATH #1")
IF ExitScript(Destination$) THEN Leave
Etype=EntityType(E1)
IF Etype<>WsCPathFileEnt THEN Pick_1
Group= ParentGroup(E1,0)
IF ValidDependency(Group) THEN
     Stat= PlotEntity(Group,Highlight_pen)
     Stat=SetEqualsValue(0,"G")
     Stat=SetInputFormat("a1=",",C,G,")
     Stat=GetValue("COMBINE: Cutterpath or Group of cutterpaths",Answer$)
     IF (ExitScript(Destination$)) THEN Leave
     IF Answer$="C" THEN Combine_paths
     Stat= EntityNameCheck(Group,Group_name$)
     Stat=SetInputFormat("n4","")
     GOTO Combine_group
END IF

	

Combine_paths:!
Stat= EntityNameCheck(E1,Cpath1_name$)
Stat= PlotEntity(E1,Highlight_pen)

Pick_2:Stat=SetPickMask(WsPickGeometry)
E2=PickEntity("PICK CUTTER PATH #2")
IF ExitScript(Destination$) THEN Leave

Stat= EntityNameCheck(E2,Cpath2_name$)
Etype=EntityType(E2)
IF Etype<>WsCPathFileEnt THEN Pick_2
Stat= PlotEntity(E2,Highlight_pen)

DeActivateUndo
RecordFunctionOn
Stat= RecordDescr("CUTTERPATH: Combine ")
E2= CombineCPaths(Cpath1_name$,Cpath2_name$)
Stat= DeleteEntity(Cpath2_name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(E1)
DeActivateUndo
GOTO Ploop

Combine_group:!
DeActivateUndo
RecordFunctionOn
Stat= RecordDescr("CUTTERPATH: Combine cpath group")
E1= CombineCPaths(Group_name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
Stat= PlotEntity(E1)
DeActivateUndo
GOTO Ploop

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