
! script name: lines.d/ptdistangle
! topic: construct line at specified angle and distance from point

!A
!A NAME:
!A
!A 	Point: Dist: Angle
!A
!A DESCRIPTION:
!A
!A 	This script constructs a line at a specific angle and a specific
!A 	distance from a point.
!A
!A~ image location - images/ptdistangle.gif
!A
!B INSTRUCTIONS:
!B
!B 	INPUT ABS X,Y: Enter the X,Y coordinates of the point to be used
!B 		as the reference for the construction of the line.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B 	PERPENDICULAR DISTANCE: Enter the distance that the line
!B 		should be constructed from the point.
!B
!B 	ANGLE OF LINE: Enter the angle of the line to be constructed.
!B
!B 	PICK LEFT/RIGHT OF LINE: This indicates which side of the
!B 		point the line will be constructed on.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: point: dist: angle ")

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

DEG
ActivateUndo
Line_loop:!
stat= SetInputFormat("n4","")
Pt=XyzInput("INPUT",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pt) THEN Line_loop

Distr=NamedVarVal("parallel distance",WsSystemVars,0.5)
Stat=SetEqualsValue(Distr)
Stat=SetInputFormat("n4=","")

Distance=GetValue("PERPENDICULAR DISTANCE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Distr=Distance
Vdist=CreateVariable("parallel distance",WsSystemVars,Distr)

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

L1=PointAngle(Pt,Angle,WsUNTRIMMED)

Pickpt=InputFreePoint("PICK LEFT/RIGHT OF LINE")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pickpt) THEN Line_loop

S1=PtLeftRight(L1,Pickpt)

Dist=S1*Distance

Ln1=PtDistAngle(Pt,Dist,Angle)

Stat=DeleteEntity(Pt)
Stat=DeleteEntity(L1)
Stat=DeleteEntity(Pickpt)

ActivateUndo
Stat= AdvanceUndoNumber("line")
Stat= AddItemToUndo(WsUBCreateMode,Ln1)
GOTO Line_loop

Leave:!
Stat=SetXyzInput(WsXyzInput)
Stat=DeleteEntity(Pt)
Stat=DeleteEntity(L1)
Stat=DeleteEntity(Pickpt)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
