
! script name: contours.d/changestartpt
! topic: change start point of contour

!A
!A NAME:
!A
!A 	Change Start Point
!A
!A DESCRIPTION:
!A
!A 	This script allows the start point of a contour to be changed.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR: Pick an element on the contour that will
!B 		have its start point changed.
!B
!B 	START POINT ABS X,Y: Enter the X,Y coordinates of the
!B 		new start point of the contour.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: change startpt ")

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

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

ActivateUndo
Pick_contour: !
Contour=PickGroupEnt("PICK CONTOUR ")
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/changestartpt"
   Stat=SetInputFormat("n4","")
   GOTO Leave
END IF


Stat=SetInputFormat("n4","")

Pick_start: !
E1=PickEntity("PICK START POINT")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(E1) THEN Pick_start
IF NOT ValidDependency(E1) THEN Pick_start
T1=LastPickPara
Pick_return=CurrPickReturn
Stat=EntityNameCheck(E1,Point$)


Stat=GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat=RecordDescr("CONTOUR: Change start point")
Stat= SetRecDelLastExec
SELECT Pick_return
    CASE WsGeometryEnd
	Ps=ParameterReturnPt(Point$,T1,WsGeometryEnd)
    CASE WsGeometryMid
	Ps=ParameterReturnPt(Point$,T1,WsGeometryMid)
    CASE WsGeomCenter
	Ps=ParameterReturnPt(Point$,T1,WsGeomCenter)
END SELECT
Contour1= CopyGroup(Contour$)
Stat= ChangeStartPt(Contour1,Ps)
RecordFunctionOff
ActivateUndo
Stat= AdvanceUndoNumber(" change start point ")
Stat= AddGroupToUndo(WsUBDeleteMode,Contour,1,WsTrue)
RecordFunctionOn
Stat= ChangeStartPt(Contour1,Ps)
Stat= AutoNameGroup(Contour1,Name$)
Stat= DeleteGroup(Contour$,WsTrue)
Stat=DeleteEntityList(Ps)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat=Highlight(Contour1,WsAutoseqPen,WsDirArrowOn)
Stat= AddGroupToUndo(WsUBCreateMode,Name$,1,WsTrue)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Pick_contour

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