
! script name: points.d/contourpts
! topic: generate points along contour

!A
!A NAME:
!A
!A 	Points Along Contour
!A
!A DESCRIPTION:
!A
!A 	This script will generate points along a contour by distance,
!A	by total number of points, or by chordal tolerance.
!A 	
!A
!A~ image location - images/arclenpts.jpg
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR: Pick the contour to generate the points along.
!B
!B 	TOLERANCE: Input the tolerance, this is the chord length between
!B 		a line joining consecutive points and the contour.
!B

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

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


ActivateUndo
Start:!
stat= SetInputFormat("a1=",",T,D,N,")
stat= SetEqualsValue(0,"D")
Stat= GetValue("METHOD by: Distance, Number, Tolerance ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "D"
	Method=1
CASE "N"
	Method=2
CASE "T"
	Method=3
END SELECT


Pick_loop:!
Contour=PickGroupEnt("PICK CONTOUR")
IF (ExitScript(Destination$)) THEN Leave
Stat=Highlight(Contour,WsPickPen,WsDirArrowsOff)
IF Method=1 THEN By_distance
IF Method=2 THEN By_number
IF Method=3 THEN By_tolerance
GOTO Start

By_tolerance:!
stat= SetInputFormat("n4=","")
stat= SetEqualsValue(0.001)
Tolerance= GetValue("TOLERANCE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Group=ContourPoints(Contour,Tolerance)

ActivateUndo
Stat= AdvanceUndoNumber("points along contour")
Stat= AddGroupToUndo(WsUBCreateMode,Group,WsFalse,WsFalse)

stat= DeleteEntity(Group)
GOTO Pick_loop


By_number:!
stat= SetInputFormat("n0=","")
stat= SetEqualsValue(Num_pts)
Num_pts= GetValue("NUMBER OF POINTS",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Group=ArcLengthPts(Contour,Num_pts)

ActivateUndo
Stat= AdvanceUndoNumber("arclength points")
Stat= AddGroupToUndo(WsUBCreateMode,Group,WsFalse,WsFalse)

stat= DeleteEntity(Group)
GOTO Pick_loop

By_distance:!
IF Dist< 0.00001 THEN Dist= 0.25
stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Dist)
Dist= GetValue("DISTANCE BETWEEN POINTS",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Group=ArcLengthPts(Contour,1,Dist)

ActivateUndo
Stat= AdvanceUndoNumber("arclength points")
Stat= AddGroupToUndo(WsUBCreateMode,Group,WsFalse,WsFalse)

stat= DeleteEntity(Group)
GOTO Pick_loop






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