
! script name: holes.d/dynamichole
! topic: create hole using dynamic mode 

!A
!A NAME:
!A
!A 	Dynamic Hole
!A
!A DESCRIPTION:
!A
!A 	This script creates holes dynamic positioning mode.
!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,Z: Enter the X,Y,Z coordinates of the hole.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!# see also - points.d/xyzinput.hlp

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

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

DEG

ActivateUndo

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

Start:!
Stat=SetInputFormat("n4b=","")
Dia=InputRadius("HOLE DIAMETER",WsDiaInput)
IF (ExitScript(Destination$)) THEN Leave
Diar=Dia

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

Stat=SetInputFormat("n4b=","")
Depth=InputDepth("FINISH DEPTH")
IF (ExitScript(Destination$)) THEN Leave
Depthr=Depth


Hole_loop:!
PlotOff
Pc= PointXYZ(0.0,0.0,0.0)
H1=Hole(Pc,Dia,Depth)
Stat= MakeInvisible(Pc)
PlotOn

Vnum= LastPickView
Stat=SetInputFormat("n4b","")
Stat=DynamicEntity(Vnum,H1,Pc,Pc,WsDynamicCenter)
IF (ExitScript(Destination$)) THEN
        Stat=DeleteEntity(H1)
        GOTO Leave
END IF
PlotOff
Pt= ParameterPt(H1,0.0)
Stat=SetLastPoint(Pt,WsXyzInput)
Stat=DeleteEntity(Pc)
Stat=DeleteEntity(Pt)
PlotOn

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

GOTO Hole_loop


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

Stat=DeleteEntity(Pt)
Stat=DeleteEntity(Pc)

IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 IF Destination$= "SCRIPTSTART" THEN Start
         IF Destination$= "BACKUP" THEN Start
	 LOAD Destination$
END IF
END
