
! script name: delete.d/delfixplane
! topic: delete fixture workplane

!A
!A NAME:
!A
!A 	Delete Fixture Workplane
!A
!A DESCRIPTION:
!A
!A 	This script will delete an unwanted fixture workplane.
!A
!B INSTRUCTIONS:
!B
!B 	NAME OF FIXTURE PLANE TO BE DELETED: 
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: delete fixture plane ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Namelist$[32000]
DIM A$[256]
DIM B$[256]

DeActivateUndo
Start:!

Group= GrpOfUserProps(WsFixtureWorkplane,WsFixtureWorkplane)
IF NOT ValidGeometry(Group) THEN Leave
Stat= AlphabetizePropGrp(Group)

Pick_prop:!
IF NOT ValidGeometry(Group) THEN Leave
Namelist$=""
FOR I=1 TO GroupCount(Group)
        E1= GroupElement(Group,I)
        A$= UserDataStr(E1,"Name:")
        Namelist$= Namelist$&VAL$(I)&")  "&A$&","
NEXT I
Stat=GeneralListBox("FIXTURE PLANES","Fixture plane selected",Namelist$)

Stat=SetInputFormat("a99","")
Stat=GetValue("INPUT FIXTURE PLANE NAME",Name$)
IF (ExitScript(Destination$)) THEN Leave
IF Name$= "CANCEL" THEN
        Stat= DeleteEntity(Group)
        GOTO Leave
END IF

N1= POS(Name$,")")
IF N1<2 AND N1< LEN(Name$) THEN Pick_prop
A$= Name$[1,N1-1]
Name$= Name$[N1+1]
IF NOT IsStringNumeric(A$) THEN Pick_prop
Num1= VAL(A$)
PlaneInfo= GroupElement(Group,Num1)

IF ((ValidGeometry(PlaneInfo))) THEN
	LowerSelectBox
	Stat=SetInputFormat("a1=",",Y,N,")
	Stat= SetEqualsValue(0,"Y")
	Stat=GetValue("Delete: "&Name$&"  Yes or No ", Answer$)
	IF (ExitScript(Destination$)) THEN Leave
	IF Answer$= "Y" THEN
		Group1= GrpByProp(PlaneInfo,WsFixtureWorkplane)
		Stat= UnLink(Group1)
		Stat= DeleteGroup(Group1,WsTrue)
		Stat=DeleteEntity(PlaneInfo)
	END IF
END IF
Stat=DeleteEntity(Group)

GOTO Start

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