
! script name: zplanes.d/wplanecontour
! topic: assign workplane to contour

!A
!A NAME:
!A
!A 	Workplane Contour
!A
!A DESCRIPTION:
!A
!A 	This script allows a contour to be associated to a workplane.
!A
!B INSTRUCTIONS:
!B
!B	CHOOSE TOOL TO ASSOCIATE : Pick workplane to use in the association.
!B
!B 	PICK CONTOUR, New workplane : Pick the element that will be associated.
!B		OR, choose a new workplane
!B
!B OPTIONS:
!B
!B 	The workplane selection box will automatically appear to allow
!B	a workplane to be selected.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: workplane contour ")

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


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:!
Stat= SetInputFormat("a1",",N,")
E1=PickGroupEnt("PICK CONTOUR, New workplane",0,Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "N" THEN Wp_loop
Stat=Highlight(E1,WsPickPen,WsDirArrowOff)
Stat=AssocUserData(E1,Wplane,WsWorkArea)
FOR J= 1 TO GroupCount(E1)
	E2= GroupElement(E1,J)
	Stat=AssocUserData(E2,Wplane,WsWorkArea)
NEXT J
Stat=SetComponent(E1,Component)

GOTO Ploop

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