
! script name: holes.d/holexy
! topic: create hole using XY input mode as default

!A
!A NAME:
!A
!A 	XY Hole
!A
!A DESCRIPTION:
!A
!A 	This script creates holes using the XY INPUT MODE as a default.
!A
!A~ image location - images/hole.gif
!A
!B INSTRUCTIONS:
!B
!B 	HOLE DIAMETER: Enter the diameter of the hole to be constructed.
!B
!B 	FINISH DEPTH: Enter the depth of the hole to be constructed.
!B
!B 	INPUT ABS X,Y: Enter the X,Y coordinates of the hole.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: xy hole ")

DIM Answer$[256]
DIM Destination$[256]

DEG

ActivateUndo
Stat=SetInputFormat("n4=","")
Diar=NamedVarVal("hole diameter",WsPointVars,0.0)
Stat=SetRadiusEquals(Diar/2)

Dia=InputRadius("HOLE DIAMETER",WsDiaInput)
IF (ExitScript(Destination$)) THEN Leave
Diar=Dia

Depthr=NamedVarVal("hole depth",WsPointVars,0.0)
Stat=SetDepthEquals(Depthr)

Depth=InputDepth("FINISH DEPTH")
IF (ExitScript(Destination$)) THEN Leave
Depthr=Depth

Stat=SetPickReturn(WsHoleXYZ)
Stat=SetXyzInput(WsXyzInput)


Ploop:Pt=XyzInput("INPUT",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave

H1=Hole(Pt,Dia,Depth)
Stat=SetLastPoint(Pt,WsXyzInput)
Stat=DeleteEntity(Pt)

ActivateUndo
Stat= AdvanceUndoNumber("hole")
Stat= AddItemToUndo(WsUBCreateMode,H1)

GOTO Ploop

Leave:!
Vdia=CreateVariable("hole diameter",WsPointVars,Diar)
Vdepth=CreateVariable("hole depth",WsPointVars,Depthr)

Stat=DeleteEntity(Pt)

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