
! script name: macros.d/notch
! EXAMPLE: create notch of specified length and width on circle

!A
!A NAME:
!A
!A 	Notch
!A
!A DESCRIPTION:
!A
!A 	This script will create a notch of specified length and width
!A 	on a circle.  The notch will be created at the top of the circle.
!A
!B INSTRUCTIONS:
!B
!B 	CIRCLE CENTER ABS X,Y: Enter the X,Y coordinates of the center of
!B 		the circle to have a notch.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	CIRCLE RADIUS: Enter the radius of the circle to be notched.
!B
!B 	X LENGTH OF NOTCH: Enter the length of the notch oriented in X.
!B
!B 	Y WIDTH OF NOTCH: Enter the width of the notch oriented in Y.
!B
!B 	CORNER RADIUS: Enter the corner radii to be used for the notch;
!B 		this includes the blend to the original circle.
!B
!# see also - points.d/xyzinput.hlp

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

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

DeActivateUndo
Circle_loop:!
Stat=SetInputFormat("n4=","")
Pc=XyzInput("CIRCLE CENTER ",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave

Radius=InputRadius("CIRCLE RADIUS")
IF (ExitScript(Destination$)) THEN Leave

Xlen=GetValue("X LENGTH OF NOTCH",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Ywid=GetValue("Y WIDTH OF NOTCH",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Corner=InputRadius("CORNER RADIUS")
IF (ExitScript(Destination$)) THEN Leave

Stat=SetRadiusEquals(Radius)

Xcen=XPointValue(Pc)
Ycen=YPointValue(Pc)

X0=Xcen
Y0=Ycen+Radius-Ywid

X1=Xcen+Xlen/2-ABS(Corner)
Y1=Y0+ABS(Corner)

X2=Xcen-Xlen/2+ABS(Corner)
Y2=Y0+ABS(Corner)


Tp1=Type3(3,X0,Y0,X1,Y1,0,-Corner)
IF (NOT ValidGeometry(Tp1)) THEN Leave
Tp2=Type5(5,X1,Y1,Xcen,Ycen,-Corner,Corner,Radius,90,WsTo)
IF (NOT ValidGeometry(Tp2)) THEN Leave
Stat=JoinTypes(Tp1,Tp2)
Tp3=Type5(5,Xcen,Ycen,X2,Y2,Radius,Corner,-Corner,-90,WsFrom)
IF (NOT ValidGeometry(Tp3)) THEN Leave
Stat=JoinTypes(Tp2,Tp3)
Tp4=Type3(3,X2,Y2,X0,Y0,-Corner,0)
IF (NOT ValidGeometry(Tp4)) THEN Leave
Stat=JoinTypes(Tp3,Tp4)
Stat=CloseType(Tp4)
Contour=TypesContour(Tp4,1)

Stat=DeleteEntity(Pc)

GOTO Circle_loop

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


