
! script name: draft.d/autodim
! topic: label dimensions using reference point

!A
!A NAME:
!A
!A 	Auto Dimension
!A
!A DESCRIPTION:
!A
!A 	This script labels dimensions using a specified reference point
!A 	(datum point) for points and lines within a specified graphics box.
!A
!B INSTRUCTIONS:
!B
!B 	DIMENSION ANGLE: Enter the angle the
!B 		dimension label should be oriented at.
!B
!B 	DATUM ABS X,Y: Enter the X,Y coordinates
!B 		of the datum point, or reference point, to be
!B 		used for calculating the dimensions.
!B
!B 	DIM LOCATION: PICK FREE POINT: Pick the location
!B 		for the dimensions to be printed at.  The dimensions
!B 		will all be located parallel to a line passing through
!B 		this point, at the dimension angle.
!B
!C NOTE:
!C
!C 		Style= 0   lines stretched to fit close dimensions. Skip too close.
!C 		Style= 1   lines stretched to fit close dimensions.
!C 		Style= 2   lines staggered to fit close dimensions.
!C
!# see also - points.d/xyzinput.hlp

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

DIM Destination$[256]
DIM Answer$[256]
DIM Textflags$[256]

DEG

Style=2

DeActivateUndo
Group_loop:!
Dim_type= WsRunningDim
Textflags$= "FO"
! Textflags$= "FOB"     text follows with text box on
! Textflags$= "FOU"     text follows with text underline on


Angle= InputAngle("DIMENSION ANGLE")
IF (ExitScript(Destination$)) THEN Leave

Pdatum=XyzInput("DATUM ",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pdatum) THEN Dim_loop

Stat=SetLastPoint(Pdatum)

Input_method= CurrInputMethod
stat= SetXyzInput(WsFreePoint)
Ploc=XyzInput("DIM LOCATION",WsXyOnly)
stat= SetXyzInput(Input_method)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Ploc) THEN Dim_loop


Group=CreateGroup("TEMPGROUP")
Vnum=PickView("SELECT VIEW FOR SELECTION BOX")
IF (ExitScript(Destination$)) THEN Leave

Stat=PickBox(Group,Vnum,WsPickPen)
IF (ExitScript(Destination$)) THEN Leave


Dim_group= AutoDimGroup(Dim_type,Group,Pdatum,Ploc,Angle,Style,Textflags$)

Stat= DeleteEntity(Dim_group)
Stat=DeleteEntity(Pdatum)
Stat=DeleteEntity(Ploc)

GOTO Group_loop

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