
! script name: zplanes.d/wplaneinbox
! topic: assign workplane to elements in box

!A
!A NAME:
!A
!A 	Workplane In Box
!A
!A DESCRIPTION:
!A
!A 	This script allows a box to be made around the elements to be
!A 	associated.  If part of an element is inside the view box, the
!A 	entire element is associated.
!A
!B INSTRUCTIONS:
!B
!B	CHOOSE TOOL TO ASSOCIATE : Pick workplane to use in the association.
!B
!B 	SELECT VIEW FOR SELECTION BOX: Pick the view that elements will be
!B 		associated in.
!B
!B 	PICK FIRST CORNER OF PICK ZONE: Pick a corner of the box.
!B
!B 	PICK SECOND CORNER OF PICK ZONE: Pick the other corner of the view box.
!B
!B OPTIONS:
!B
!B 	The selection box will automatically appear to allow a workplane to
!B 	be selected.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: workplane in box ")

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

Wp_loop:!
No_box=UserSelectBox("WORKPLANES","selected workplane",WsWorkArea,WsUserSelect)
IF No_box THEN Leave

Stat= SetInputFormat("a99","")
Stat= GetValue("CHOOSE WORKPLANE TO ASSOCIATE",Answer$)
IF ExitScript(Destination$) OR Answer$="CANCEL" THEN Leave

Wplane= FindUserData(Answer$,WsWorkArea)
IF NOT ValidGeometry(Wplane) THEN Wp_loop

Component= GetUserValue(Wplane,"Component:")
LowerSelectBox

Ploop:!
Group=CreateGroup("TEMPGROUP")

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

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

Stat=Highlight(Group,WsPickPen,WsDirArrowOff)
Stat=AssocUserData(Group,Wplane,WsWorkArea)
Stat=SetComponent(Group,Component)
Stat=DeleteEntity(Group)

GOTO Ploop

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


