
! script name: draft.d/angle2lines
! topic: construct angle 2 lines  dimension

!A
!A NAME:
!A
!A 	Angular Dimension Between Two Lines.
!A
!A DESCRIPTION:
!A
!A 	This script constructs an angular dimension.  The angular dimension
!A 	is the angle between two lines.
!A
!A~ image location - images/ang2lines.gif
!A
!B INSTRUCTIONS:
!B	PICK FIRST LINE: Pick the first line.
!B
!B	PICK SECOND LINE: Pick the second line.
!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: angle 2 lines dimension ")

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

ActivateUndo
Start:!
Dynamic_position=1
Dim_type= WsAngleDim


Dim_loop:! 
L1=PickSpecificEnt("PICK FIRST LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(L1) THEN Dim_loop
Parameter1= LastPickPara

L2=PickSpecificEnt("PICK SECOND LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(L2) THEN Dim_loop
Parameter2= LastPickPara

Vertex= Intersect(L1,L2)
IF NOT ValidGeometry(Vertex) THEN Dim_loop
Pstart= ParameterPt(L1,Parameter1)
Pend=   ParameterPt(L2,Parameter2)

D1= DistTwoPts(Pstart,Pend)
IF D1< Delta THEN 
	Stat=DeleteEntity(Vertex)
	Stat=DeleteEntity(Pstart)
	Stat=DeleteEntity(Pend)
	GOTO Dim_loop
END IF
	

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
