
! script name: vcopy.d/ptgrpcopycont
! var_topic: copy contour by group of points

!A
!A NAME:
!A
!A     Point Group Copy Contour	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a contour to be copied.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR TO BE COPIED: Pick the contour to be copied.
!B
!B 	REFERENCE POINT: Pick the point to be used as the reference for
!B 		the copy.
!B
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: point group contour ")

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


Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave
Highlight_color= 3

Start: !
ActivateUndo
Contour=PickGroupEnt("PICK CONTOUR TO BE COPIED")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Contour) THEN Start
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)
Pgroup=PickGroupEnt("PICK GROUP OF DESTINATION POINTS")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Pgroup) THEN Start
Stat= EntityNameCheck(Pgroup,Pgroup$)
Stat=Highlight(Pgroup,Highlight_color,WsDirArrowOff)
IF NOT ValidGeometry(Pgroup) THEN
        GOTO Start
ELSE
        IF NOT GroupCount(Pgroup) THEN Dest_pt
END IF
Stat= DeleteEntity(Ps)


Num_elements= GroupCount(Group)
Stat= GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("COPY: point group copy contour")
Stat= SetRecDelLastExec
Stat= NullReference(Contour$)
Stat= NullReference(Pgroup$)
SELECT Pick_return1
CASE WsGeometryEnd
        Pref= ParameterReturnPt(Point1$,T1,WsGeometryEnd)
CASE WsGeometryMid
        Pref= ParameterReturnPt(Point1$,T1,WsGeometryMid)
CASE WsGeomCenter
        Pref= ParameterReturnPt(Point1$,T1,WsGeomCenter)
END SELECT
G1= PtGroupCopyGroup(Contour$,Pref,Pgroup$)
Stat= AutoNameGroup(G1,Name$)
Stat= SetNoPathFlag(G1,WsTrue)
Stat= DeleteEntity(Pref)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= DeleteEntity(Ps)
ActivateUndo
Stat= AdvanceUndoNumber("pt group copy")
Stat= AddGroupToUndo(WsUBCreateMode,G1,1,WsTrue)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Start

Leave: !
ActivateUndo
stat= SetInputFormat("n4","")
Stat= DeleteEntity(Ps)

IF (NOT LEN(Destination$)) THEN
         LOAD "typecontrol"
ELSE
        IF Destination$= "SCRIPTSTART" THEN Start
        IF Destination$= "BACKUP" THEN Start
         LOAD Destination$
END IF
END

