
! script name: vcircles.d/orientcircle
! var_topic: orients the circle starting angle

!A
!A NAME:
!A
!A 	Orients a circles starting angle VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script orients a circles starting angle.
!A
!B INSTRUCTIONS:
!B	PICK CIRCLE - Pick the circle to orient.
!B
!B	ANGLE - Enter the angle or pick a line to describe it.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: orient circle ")

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

Var_object= CheckVarObject
IF ExitScript(Destination$) THEN Leave

ActivateUndo
Pick_circle:Stat=SetInputFormat("n4","")
E1=PickEntity("PICK CIRCLE")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_point
Stat= EntityNameCheck(E1,Element$)

Angle_ques:Angle=InputAngle("ANGLE")
IF (ExitScript(Destination$)) THEN Leave
No_angle_var= LastVariableInput(Angle_var$)
L1= LastPickEnt
IF ValidGeometry(L1) THEN
        IF NOT ValidDependency(L1) THEN Angle_ques
        Stat= EntityNameCheck(L1,Angle_var$)
        No_angle_var=0
END IF

ActivateUndo
Stat= AdvanceUndoNumber("orient circle")
Stat= AddItemToUndo(WsUBModifyMode,Element$)

RecordFunctionOn
Stat= RecordDescr("CIRCLE: orient circle")
IF No_angle_var THEN
        V1= FreeParameter("Angle",Angle)
	Stat= OrientCircle(Element$,V1)
ELSE
	Stat= OrientCircle(Element$,Angle_var$)
END IF
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(Element$)

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Pick_circle

Leave:!
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END

