
! script name: contours.d/orientcontour
! topic: orient a closed contour clockwise or counterclockwise.

!A
!A NAME:
!A
!A 	Orient Contour
!A
!A DESCRIPTION:
!A
!A 	This script automatically orients a closed contour in a clockwise
!A	or counterclockwise orientation. Should be applied in the
!A	workplane of the contour.
!A
!B INSTRUCTIONS:
!B
!B	ORIENTATION (1) CW or (2) CCW.
!B
!B 	PICK CONTOUR : Pick the contour.
!B

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

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


ActivateUndo
Ploop:!
Stat= SetInputFormat("n4","")
Contour=PickGroupEnt("PICK CONTOUR ")
IF (ExitScript(Destination$)) THEN Leave

Stat=SetInputFormat("a1",",1,2,")
Stat=GetValue("ORIENTATION ( 1 ) CW or ( 2 ) CCW ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "1"
	Direction= WsCW
CASE "2"
	Direction= WsCCW
END SELECT

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

Stat= OrientContour(Contour,Direction)
Stat=Highlight(Contour,WsPickPen,WsDirArrowOn)

GOTO Ploop

Leave:!
Stat= SetInputFormat("n4","")
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
