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

!A
!A NAME:
!A
!A 	Explode: Single 3d cutter path  VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a path on a 3D cutter path to be exploded into
!A 	ordinary geometry elements.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CURVE TO BE EXPLODED: Pick the curve to be exploded
!B

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

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 CURVE ON CUTTERPATH")
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
T=LastPickPara
Path=INT(T)

Stat= GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("CUTTERPATH: Explode cut")
Stat= SetRecDelLastExec
V1= FreeParameter("Path number",Path)
G1=ExplodeCPath(Cpath_name$,V1)
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 cut")
Stat= AddGroupToUndo(WsUBCreateMode,G1,1,WsTrue)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Pick_loop


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