
! script name: draft.d/angledim
! topic: construct angular dimension

!A
!A NAME:
!A
!A 	Angular Dimension
!A
!A DESCRIPTION:
!A
!A 	This script constructs an angular dimension.  The angular dimension
!A 	is the angle between the lines formed by the vertex point and the
!A 	start point and the vertex point and the end point.
!A
!A~ image location - images/angledim.gif
!A
!B INSTRUCTIONS:
!B
!B 	VERTEX POINT ABS X,Y: Enter the X,Y coordinates of the vertex of the
!B 		angle.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	DIM START ABS X,Y: Enter the X,Y coordinates of the start dimension.
!B
!B 	DIM END ABS X,Y: Enter the X,Y coordinates of the ending dimension.
!B
!B 	DIM LOCATION: PICK FREE POINT: Pick the location for the dimension
!B 		label to be printed.
!B
!# see also - htdocs/help.d/dynamicdim.htm
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: angular dimension ")

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

ActivateUndo
Start:!
Dynamic_position=1
Dim_type= WsAngleDim


Dim_loop:! 
Vertex=XyzInput("VERTEX POINT",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Vertex) THEN Dim_loop


Pstart=XyzInput("DIM START",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pstart) THEN Dim_loop

Pend=XyzInput("DIM END",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pend) THEN Dim_loop

IF Dynamic_position THEN
        P1= SubtractVectors(Pstart,Pend)
        Ploc= AddVectors(Pstart,P1)
        Stat=DeleteEntity(P1)
ELSE
        Input_method= CurrInputMethod
        stat= SetXyzInput(WsFreePoint)
        Stat=SetLastPoint(Pstart)
        Ploc=XyzInput("DIM LOCATION",WsXyOnly)
        stat= SetXyzInput(Input_method)
        IF (ExitScript(Destination$)) THEN Leave
        IF NOT ValidGeometry(Ploc) THEN Dim_loop
END IF


PlotOff
E1= AngleDim(Dim_type,Vertex,Pstart,Pend,Ploc,"","")
PlotOn

Stat=DeleteEntity(Vertex)
Stat=DeleteEntity(Pstart)
Stat=DeleteEntity(Pend)
Stat=DeleteEntity(Ploc)
IF NOT ValidGeometry(E1) THEN Dim_loop
IF Dynamic_position THEN
        Which_end=2
        Vnum= LastPickView
        Stat= DynamicDimEdit(Vnum,E1,Which_end,"PICK DIM LOCATION",WsFalse)
	IF (ExitScript(Destination$)) THEN
                Stat= DeleteEntity(E1)
                GOTO Leave
        END IF
END IF
ActivateUndo
Stat= AdvanceUndoNumber("angle dim")
Stat= AddDimToUndo(WsUBCreateMode,E1)

GOTO Dim_loop

Leave:!

Stat=DeleteEntity(Vertex)
Stat=DeleteEntity(Pstart)
Stat=DeleteEntity(Pend)
Stat=DeleteEntity(Ploc)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
         IF Destination$= "SCRIPTSTART" THEN Start
         IF Destination$= "BACKUP" THEN Start
	 LOAD Destination$
END IF
END
