
! script name: vcontours.d/reversecontour
! var_topic: reverse direction of contour

!A
!A NAME:
!A
!A 	Reverse Contour		VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script automatically reverses the direction of a selected contour.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR TO BE REVERSED: Pick an element
!B 		on the contour that will be reversed.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: reverse contour ")

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

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

ActivateUndo
Pick_contour:!
Contour=PickGroupEnt("PICK CONTOUR TO BE REVERSED")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Contour) THEN Pick_contour
Stat=EntityNameCheck(Contour,Contour$)
IF NOT IsEntVariational(Contour) THEN
   Stat=SetInputFormat("a1",",Y,N,")
   Stat= GetValue("NON-VDM ENTITY. LOAD NON-VDM? Yes or No ",Answer$)
   IF Answer$="N" THEN Pick_contour
   Destination$= "contours.d/reversecontour"
   Stat=SetInputFormat("n4","")
   GOTO Leave
END IF

ActivateUndo
Stat= AdvanceUndoNumber("reverse contour")
Stat= AddGroupToUndo(WsUBModifyMode,Contour$,1,WsTrue)

RecordFunctionOn
Stat=RecordDescr("CONTOUR: Reverse")
Stat=ReverseContour(Contour$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
Stat=Highlight(Contour,WsPickPen,WsDirArrowOn)

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Pick_contour

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

