
! script name: v3dcpaths.d/explodecpaths
! var_topic: explodes a 3D cutterpath into geometry

!A
!A NAME:
!A
!A 	Explode: Multiple 3d cutter paths
!A
!A DESCRIPTION:
!A
!A 	This script allows a 3D cutter path to be exploded into a group
!A 	of paths.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CUTTER PATH TO BE EXPLODED: Pick the cutter path to be exploded
!B

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


DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Cpath_name$[256]

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

ActivateUndo
Ploop:!

Pick_loop:!
Stat=SetPickMask(WsPickGeometry)
Cpath=PickEntity("PICK CUTTERPATH TO BE EXPLODED ")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Cpath) THEN Pick_loop
Stat= EntityNameCheck(Cpath,Cpath_name$)
Etype=EntityType(Cpath)
IF Etype<>WsCPathFileEnt THEN Pick_loop

Stat= GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("CUTTERPATH: Explode ")
Stat= SetRecDelLastExec
V1= FreeParameter("Path number",Path)
G1=ExplodeCPaths(Cpath_name$)
Stat= AutoNameGroup(G1,Name$)
Stat= SetNoPathFlag(G1,WsTrue)
Tool= GetAssocTool(Cpath_name$)
Stat= AssociateTool(G1,Tool)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

ActivateUndo
Stat= AdvanceUndoNumber("explode cpath")
Stat= AddGroupToUndo(WsUBCreateMode,G1,1,WsTrue)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Ploop

Leave:!
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
