
! script name: vmove.d/2drptmovecont
! var_topic: 2D move contour by reference points

!A
!A NAME:
!A
!A     2D  Reference	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a contour to be moved.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR TO BE COPIED: Pick the contour to be moved.
!B
!B 	REFERENCE POINT: Pick the point to be used as the reference for
!B 		the move.
!B
!B 	DESTINATION POINT: Pick the point to be used as the destination
!B 		for the move.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: 2D Reference")

DIM Answer$[256]
DIM Destination$[256]
DIM Which$[16]
DIM Contour$[256]
DIM Name$[256]
DIM Point1$[256]
DIM Point2$[256]
DEG


Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave
Highlight_color= 3
Start: !
ActivateUndo
stat= SetInputFormat("n4","")
Contour=PickGroupEnt("PICK CONTOUR TO BE MOVED")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Contour) THEN Start
IF IsEntityDependent(Contour)= WsFalse THEN
	stat= SetInputFormat("a99","")
	Stat= GetValue("NOT A VARIATIONAL CONTOUR, Proceed ",Answer$)
	IF ExitScript(Destination$) THEN Leave
	GOTO Start
END IF


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


Ref_pt:P1=PickEntity("REFERENCE POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(P1) THEN Ref_pt
T1= LastPickPara
Pick_return1= CurrPickReturn
Stat= EntityNameCheck(P1,Point1$)
Ps= ParameterReturnPt(P1,T1,Pick_return1)

Dest_pt:!
Stat=SetLastPoint(Ps)
P2=PickEntity("DESTINATION POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(P2) THEN Dest_pt
T2= LastPickPara
Pick_return2= CurrPickReturn
Stat= EntityNameCheck(P2,Point2$)
Pe= ParameterReturnPt(P2,T2,Pick_return2)
Stat=SetLastPoint(Pe)

Stat= DeleteEntityList(Ps,Pe)
Stat= EraseEntity(Contour)

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

RecordFunctionOn
Stat= RecordDescr("MOVE: ref move contour")
Stat= NullReference(Contour$)
SELECT Pick_return1
CASE WsGeometryEnd
        Ps= ParameterReturnPt(Point1$,T1,WsGeometryEnd)
CASE WsGeometryMid
        Ps= ParameterReturnPt(Point1$,T1,WsGeometryMid)
CASE WsGeomCenter
        Ps= ParameterReturnPt(Point1$,T1,WsGeomCenter)
END SELECT
SELECT Pick_return2
CASE WsGeometryEnd
        Pe= ParameterReturnPt(Point2$,T2,WsGeometryEnd)
CASE WsGeometryMid
        Pe= ParameterReturnPt(Point2$,T2,WsGeometryMid)
CASE WsGeomCenter
        Pe= ParameterReturnPt(Point2$,T2,WsGeomCenter)
END SELECT
Ps1= ProjectEntity(Ps,0.0)
Pe1= ProjectEntity(Pe,0.0)
Pm= VectorTwoPts(Ps1,Pe1)
Trans=AngleTransform(Pm,0,0,0,WsWorkplaneVals)
Stat=TransGroupTrans(Contour$,Trans,0,1)
Stat= DeleteEntityList(Ps,Pe,Pm,Ps1,Pe1)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
Stat= PlotEntity(Point1$)
Stat= PlotEntity(Point2$)
Stat= DeleteEntityList(Ps,Pe,Pm)
GOTO Start

Leave: !
stat= SetInputFormat("n4","")
Stat= DeleteEntityList(Ps,Pe)

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

