
! script name: draft.d/2ptalignruler
! topic: align ruler

!A
!A NAME:
!A
!A 	Align Ruler with two points.
!A
!A DESCRIPTION:
!A
!A 	This script allows the ruler to be aligned using two points
!A
!B INSTRUCTIONS:
!B
!B 	PICK RULER ORIGIN: Pick the ruler origin point.
!B
!B 	PICK ALIGNMENT POINT: Pick the alignment point.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: two point align ruler ")

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


Ruler_loop:!

stat= SetInputFormat("n4","")
Ps=XyzInput("RULER ORIGIN",WsXyInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Ps) THEN Ruler_loop

Pe=XyzInput("ALIGNMENT POINT",WsXyInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pe) THEN Ruler_loop

PlotOff
L1=LineTwoPoints(Ps,Pe,WsTRIMMED)
Angle= LineAngle(L1)
Stat=RulerCenter(Ps,Angle)
Stat=DeleteEntity(L1)
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
PlotOn

Stat= RulerToggle(1)

GOTO Ruler_loop

Leave:!
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
Stat=DeleteEntity(L1)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
