
! script name: types.d/type41
! topic: type 41

!A
!A NAME:
!A
!A 	Type 41
!A
!A~ image location - images/type41.gif
!A
!A DESCRIPTION:
!A
!A 	Type 41 is a modified Type 4.  A chamfer is created connecting the
!A 	second circle to the next element. CHAMFER LENGTH is measured parallel
!A 	to the chord of the circle.  Type 41 may not be used to end a contour
!A 	description of an open contour.
!A
!# see also - htdocs/help.d/typeno.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: type 41 ")

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

DeActivateUndo
Last=FindLastType
Stat=SetInputFormat("n4=","")
IF NOT ValidGeometry(Last) THEN
	Ps=XyzInput("STARTING",WsXyOnly)
	IF (ExitScript(Destination$)) THEN Leave
	First=1
	R1=0
ELSE
	Ps=TypeEndPoint(Last,WsEnd)
	R1=TypeEndRadius(Last,WsEnd)
	First=0
END IF

Stat=SetLastPoint(Ps,WsXyOnly)

Pe=XyzInput("ENDING",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave

IF First THEN
	Stat=SetEqualsValue(0)
	R1=InputRadius("R1",WsRadiusInput,WsSigned)
	IF (ExitScript(Destination$)) THEN Leave
END IF

Stat=SetEqualsValue(R1)
R2=InputRadius("R2",WsRadiusInput,WsSigned)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetInputFormat("n4","")
Length=GetValue("CHAMFER LENGTH",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Tp=Type4(41,Ps,Pe,R1,R2,Length)
IF (NOT ValidGeometry(Tp)) THEN Leave

IF NOT First THEN
	Stat=JoinTypes(Last,Tp)
END IF

Leave:!
Stat=SetPickReturn(WsCircleCenter)
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
