
! script name: vrotate.d/axisrotatecont
! var_topic: rotate contour about an axis line

!A
!A NAME:
!A
!A 	Single Group: Axis Duplicate	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a contour to be  rotated about an axis.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR TO BE ROTATED: Pick the contour
!B 		to be rotated.
!B
!B
!B 	ROTATION ANGLE: Enter the angular amount
!B 		the entities should be rotated.
!B
!B 	PICK AXIS LINE: Pick the axis line for the
!B 		entities to be rotated around.
!B
!B 	NUMBER OF TIMES: Enter the number of times
!B 		the rotation process should be repeated.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: axis rotate contour ")

DIM Answer$[256]
DIM Destination$[256]
DIM Contour$[256]
DIM Name$[256]
DIM Axis_line$[256]
DIM Angle_var$[256]
DIM Ntimes_var$[256]
DEG

Var_object= CheckVarObject
IF ExitScript(Destination$) THEN Leave

Highlight_color= 3
Stat= SetDefaults(WsSelectedEntPen,Highlight_color)
Start: !
ActivateUndo
Contour=PickGroupEnt("PICK CONTOUR TO BE ROTATED")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Contour) THEN Start
Stat= EntityNameCheck(Contour,Contour$)
Stat=Highlight(Contour,Highlight_color,WsDirArrowOff)
IF NOT ValidGeometry(Contour) THEN
        GOTO Start
ELSE
        IF NOT GroupCount(Contour) THEN Start
END IF


Angle_ques:Angle=InputAngle("ROTATION 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
        No_angle_var=0
        Stat= EntityNameCheck(L1,Angle_var$)
END IF

Axis_line:Axis_line=PickSpecificEnt("PICK AXIS LINE ",WsPickLines)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Axis_line) THEN Axis_line
Stat= EntityNameCheck(Axis_line,Axis_line$)


Stat=SetEqualsValue(1)
Stat=SetInputFormat("n0=","")
Number=GetValue("NUMBER OF TIMES",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Number=0 THEN Start
No_times_var= LastVariableInput(Ntimes_var$)


Num_elements= GroupCount(Group)
Stat= GenerateVarName(WsVarRecordEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("ROTATE: axis rotate contour")
Stat= SetRecDelLastExec
Stat= NullReference(Contour$)
V3= FreeParameter("Total shift along axis",0.0)
IF no_times_var THEN
    V2= FreeParameter("Number",Number)
    IF No_angle_var THEN
	V1= FreeParameter("Angle",Angle)
        G1= RotGrpAboutAxis(Contour$,Axis_line$,V1,V2,WsTrue,V3)
    ELSE
        G1= RotGrpAboutAxis(Contour$,Axis_line$,Angle_var$,V2,WsTrue,V3)
    END IF
ELSE
    IF No_angle_var THEN
	V1= FreeParameter("Angle",Angle)
        G1= RotGrpAboutAxis(Contour$,Axis_line$,V1,Ntimes_var$,WsTrue,V3)
    ELSE
        G1= RotGrpAboutAxis(Contour$,Axis_line$,Angle_var$,Ntimes_var$,WsTrue,V3)
    END IF
END IF
Stat= AutoNameGroup(G1,Name$)
Stat= SetNoPathFlag(G1,WsTrue)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

ActivateUndo
Stat= AdvanceUndoNumber("rotate contour")
Stat= AddGroupToUndo(WsUBCreateMode,G1,1,WsTrue)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Start

Leave: !
stat= SetInputFormat("n4","")

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

