
! script name: draft.d/pointdimension
! topic: construct point dimension

!A
!A NAME:
!A
!A 	Point Dimension
!A
!A DESCRIPTION:
!A
!A 	This script constructs a point dimension.
!A
!A~ image location - images/pointdim.gif
!A
!B INSTRUCTIONS:
!B
!B 	POINT LOCATION ABS X,Y: Enter the X,Y coordinates to be used for the
!B 		start of the leader. An arrow will be placed at this point.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B 	LEADER END ABS X,Y: Enter the X,Y coordinates to be used for the
!B 		end point of the leader.
!B
!B
!# see also - htdocs/help.d/dynamicdim.htm
!# see also - points.d/xyzinput.hlp

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

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

ActivateUndo
Start:!
Dynamic_position=1
Dim_type= Ws2DPointDim

Dim_loop:! 
stat= SetInputFormat("n4","")
Pstart=XyzInput("POINT LOCATION ",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pstart) THEN Dim_loop

Input_method= CurrInputMethod
IF CurrInputMethod= WsLatheInput THEN
        Dim_type= Ws2DLathePointDim
ELSE
        Dim_type= Ws2DPointDim
END IF


IF Dynamic_position THEN
	Pend= PointXYZ(0,0,0)
ELSE
	Pend=XyzInput("LEADER END",WsXyOnly)
	IF (ExitScript(Destination$)) THEN Leave
	IF NOT ValidGeometry(Pend) THEN Dim_loop
END IF


PlotOff
E1= PointDimension(Dim_type,Pstart,Pend,Pstart)
PlotOn
Stat=SetLastPoint(Pend)
Stat=DeleteEntity(Pstart)
Stat=DeleteEntity(Pend)

IF Dynamic_position THEN
        Which_end=1
        Vnum= LastPickView
        Stat= DynamicDimEdit(Vnum,E1,Which_end,"PICK LEADER END LOCATION",WsFalse)
	IF (ExitScript(Destination$)) THEN
                Stat= DeleteEntity(E1)
                GOTO Leave
        END IF
END IF

ActivateUndo
Stat= AdvanceUndoNumber("point dim")
Stat= AddDimToUndo(WsUBCreateMode,E1)

GOTO Dim_loop

Leave:!
stat= SetInputFormat("n4","")
Stat=DeleteEntity(Pstart)
Stat=DeleteEntity(Pend)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	IF Destination$= "SCRIPTSTART" THEN Start
        IF Destination$= "BACKUP" THEN Start
	 LOAD Destination$
END IF
END

