
! script name: move.d/imagegroup
! topic: Sample - move group of elements

!A
!A NAME:
!A
!A 	IMAGE GROUP  test routine
!A
!A DESCRIPTION:
!A
!A 	This script allows a group of elements to be moved.  The elements
!A 	may be moved in one of three ways:
!A
!A 		1) SELECTION BOX
!A 		2) PICK INDIVIDUAL ELEMENTS
!A 		3) PICK A GROUP
!A
!A 	The mode may be changed by editing the named variable "pick type".
!A 	To edit a named variable select the "EDIT USER DATA" option in the
!A 	"Edit" subdirectory, then select the "NAMED VARIABLES" option.  The
!A 	variable "pick type" should be one of the choices.  ( The numbers
!A 	above are the ones associated with this variable ).
!A
!B INSTRUCTIONS:
!B
!B 	SELECT VIEW FOR SELECTION BOX: Pick the view that elements are to be
!B 		moved in.  This question is for SELECTION BOX mode only.
!B
!B 	PICK ELEMENT, PROCEED: Pick one of the elements to be moved.
!B 		This question is for PICK INDIVIDUAL ELEMENTS mode only.
!B 		The question will repeat until "PROCEED" is answered.
!B 		All elements picked will then be moved.
!B
!B 	PICK GROUP TO BE MOVED: Pick an element on the group to be moved.
!B 		This question is for PICK A GROUP mode only.
!B
!B 	X MOVE: Enter the amount the elements are to be moved in X.
!B
!B 	Y MOVE: Enter the amount the elements are to be moved in Y.
!B
!B 	Z MOVE: Enter the amount the elements are to be moved in Z.
!B
!B 	NUMBER OF TIMES: Enter the number of times the move sequence should
!B 		be repeated.
!B
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: image group test routine ")

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

DeActivateUndo
stat= SetInputFormat("n4","")
Active_workplane=0
Work=CurrentWorkplane
IF (ValidGeometry(Work)) THEN Active_workplane=1

StdWorkplane

Group=CreateGroup("TEMP")

Pick_type=NamedVarVal("pick type",WsSystemVars,1.0)

Start: !

SELECT Pick_type

  CASE 1    ! PICK BOX

    Vnum=PickView("SELECT VIEW FOR SELECTION BOX")
    IF (ExitScript(Destination$)) THEN Leave

    Stat=PickBox(Group,Vnum,WsPickPen)
    IF (ExitScript(Destination$)) THEN Leave

  CASE 2    ! PICK ELEMENTS

    LOOP
      Stat=SetInputFormat("a7",",PROCEED,")
      E1= PickEntity("PICK ELEMENT, PROCEED",Answer$)
      IF (ExitScript(Destination$)) THEN Leave
      Stat=SetInputFormat("n4"," ")
    EXIT IF Answer$="PROCEED"
      Stat=AddToGroup(Group,E1)
    END LOOP

  CASE 3    ! PICK GROUP

    Grp1=PickGroupEnt("PICK GROUP TO BE MOVED")
    IF (ExitScript(Destination$)) THEN Leave
    Stat=AddToGroup(Group,Grp1)

  CASE ELSE

    Pick_type=1
    GOTO Start

END SELECT

Xmove=GetValue("X MOVE ",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Ymove=GetValue("Y MOVE ",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Zmove=GetValue("Z MOVE ",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetInputFormat("n0","")
Number=GetValue("NUMBER OF TIMES",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Move_group:! 
FOR I=1 TO Number
	X=Xmove*I
	Y=Ymove*I
	Z=Zmove*I
	Pr=PointXYZ(X,Y,Z)
	T1=AngleTransform(Pr,0,0,0)
	stat= PlotGroupImage(Group,T1,1.0,1.5,2.0)
	Stat=DeleteEntity(T1)
	Stat=DeleteEntity(Pr)
NEXT I
PlotAll

Leave:!
IF Active_workplane THEN
	Stat=SetWorkplane(Work)
ELSE
	StdWorkplane
END IF
stat= SetInputFormat("n4","")
Stat=DeleteEntity(Pr)
Stat=DeleteEntity(T1)
Stat=DeleteEntity(Group)

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


