
! script name: project.d/projectgroup
! topic: Sample - project group of elements

!A
!A NAME:
!A
!A 	Project Group
!A
!A DESCRIPTION:
!A 	This script allows a group of elements to be projected.  The elements
!A 	may be selected 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 the variable.)  The data selected
!A 	will be projected into the current workplane.
!A
!B INSTRUCTIONS:
!B
!B 	SELECT VIEW FOR SELECTION BOX: Pick the view that elements are to be
!B 		projected in.  This question is for SELECTION BOX mode only.
!B
!B 	PICK ELEMENT, PROCEED: Pick one of the elements to be projected.
!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 projected.
!B
!B 	PICK GROUP TO BE ROTATED: Pick an element on the group to be
!B 		projected.  This question is for a PICK A GROUP mode only.
!B
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: project group ")

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

stat= SetInputFormat("n4","")
Group=CreateGroup("TEMP")

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

Start: !
ActivateUndo

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 ELEMENTS, 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 PROJECTED")
    IF (ExitScript(Destination$)) THEN Leave
    Stat=AddToGroup(Group,Grp1)

  CASE ELSE

    Pick_type=1
    GOTO Start

END SELECT

stat= SetInputFormat("n4=","")
stat= SetEqualsValue(0)
Zconst=GetValue("Z CONSTANT",Answer$)
IF (ExitScript(Destination$)) THEN Leave

IF (ValidGeometry(Group)) THEN
	G1= ProjectEntity(Group,Zconst)
	IF (ValidGeometry(G1)) THEN
		stat= DelMatchingEnts(G1)
	END IF
	
	ActivateUndo
	Stat= AdvanceUndoNumber("project")
	Stat= AddGroupToUndo(WsUBCreateMode,G1,0,WsTrue)
END IF

Leave:!
stat= SetInputFormat("n4","")
Stat=DeleteEntity(Group)
Stat=DeleteEntity(G1)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END


