
! script name: holes.d/hintersect
! topic: create hole at intersection of two elements

!A
!A NAME:
!A
!A 	Intersection
!A
!A DESCRIPTION:
!A
!A 	This script creates a hole at the intersection of two elements.
!A
!B INSTRUCTIONS:
!B
!B 	HOLE DIAMETER: Enter the diameter of the hole to be constructed.
!B
!B 	FINISH DIAMETER: Enter the depth of the hole to be constructed.
!B
!B 	PICK FIRST ELEMENT OF INTERSECTION: Pick one of the
!B 		elements that is to be used to determine the hole location.
!B
!B 	PICK SECOND ELEMENT OF INTERSECTION: Pick the element
!B 		that intersects the first element picked.
!B 	

stat=ChangeLabelStr("ScriptNameStatus","Function: intersection ")

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

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

Vdia=CreateVariable("hole diameter",WsPointVars,Diar)

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

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

Vdepth=CreateVariable("hole depth",WsPointVars,Depthr)

Stat=SetPickReturn(WsHoleXYZ)

Ploop:Stat=SetXyzInput(WsIntersect)
Pc=XyzInput("INPUT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

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

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

GOTO Ploop

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