
! script name: pksolids.d/pktoolalongcont
! solids: test

!A
!A NAME:
!A
!A
!A DESCRIPTION:
!A
!A
!A
!B INSTRUCTIONS:
!B
!B
!C NOTES:
!C
!C
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: test")

DIM Destination$[256]
DIM Answer$[256]
DIM Holder_name$[256]
DIM Group_name$[256]

ActivateUndo

Units= CurrentUnits
IF Units= WsMetric THEN
        Holder_name$="/usr/weber/util/tooldata/holders/bt40.met.s"
ELSE
        Holder_name$="/usr/weber/util/tooldata/holders/bt40.inch.s"
END IF

Stat= WorkDialogToggle(WsFalse)
stat= SetInputFormat("n4","")
Active_workplane=0
Work=CurrentWorkplane
IF (ValidGeometry(Work)) THEN Active_workplane=1

Start:!
Stat= SetEqualsValue(0,"M")
Stat=SetInputFormat("a1=",",S,M,T,")
Stat=GetValue("ANIMATION METHOD: Slow, Medium, Tool off",Answer$)
IF ExitScript(Destination$) THEN Leave
SELECT Answer$
CASE "S"
        Mode= 1
CASE "M"
        Mode= 2
CASE "T"
        Mode= 3
END SELECT



Pick_body:!
E1=WPKPickEntity("PICK STARTING BODY")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Pick_body

Pkbody= WPKParentBody(E1)


Pick_contour:!
Contour=PickGroupEnt("PICK CONTOUR ")
IF (ExitScript(Destination$)) THEN Leave


StdWorkplane
Tool= GetAssocTool(Contour)
PlotOff
Hldr_grp=ReadFileGeometry(Group_name$,WsToolImage,Holder_name$)
IF ValidGeometry(Hldr_grp) THEN
	Stat= StripNonGeometry(Hldr_grp)
        Stat= MakeInvisible(Hldr_grp)
        Tip_to_hold=GetUserValue(Tool,"Tip to holder:")
        Pr= PointXYZ(0,0,Tip_to_hold)
        T4=AngleTransform(Pr,0,0,0)
        Tool_holder= TransformGroup(Hldr_grp,T4,"Tool holder")
        Stat= DeleteEntity(Pr)
        Stat= DeleteGroup(Hldr_grp)
END IF
PlotOn


ActivateUndo
Stat= GLPlotOn(3)
WPKClearErrorFlag

Stat= WPKSetupMachining(Mode,Tool,Tool_holder,Pkbody)
Stat= WPKMachineGroup(Contour)
Stat= DeleteGroup(Tool_holder)

Finished:!
ActivateUndo
Stat= AdvanceUndoNumber("tool along contour")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
StdWorkplane
PlotOn
GOTO Pick_contour

Leave:!
PlotOn
Stat=SetPickMask(WsPickGeometry)
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
