
! script name: vdelete.d/deleteobject
! var_topic: delete variational object

!A
!A NAME:
!A
!A 	DELETE VARIATIONAL OBJECT
!A
!A DESCRIPTION:
!A	
!A 	Deletes a variational object along with all of the geometry
!A 	that is not referenced by other variational objects.
!A
!B INSTRUCTIONS:
!B
!B 	PICK OBJECT TO BE DELETED: Pick the variational object to be
!B 		deleted or enter N to allow the name of the object to
!B 		be entered.
!B
!B 	BROKEN DEPENDENCY, Delete anyway, Exit: This message will
!B 		appear if the delete can not be executed because of
!B 		dependency.  Exit returns to the PICK OBJECT TO BE DELETED
!B 		question.
!B		Delete anyway will delete the object regardless.
!B
!B 	DELETE OBJECT ? Yes or No:
!B
!B 		Y - This will delete the object.
!B 		N - This will cancel the delete process for this object
!B 		    and allow the selection of a different object.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: delete variational object")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Descr$[256]
DIM A$[256]

Highlight_color=2

DeActivateUndo
Start:!
Pick_object:!
Var_object=PickVarObject("PICK OBJECT TO BE DELETED")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Var_object) THEN Pick_object
Stat=VarObjectName(Var_object,Name$)
Stat=Highlight(Var_object,Highlight_color,0)
Stat= DisplayMessage("CHECKING FOR OBJECT DEPENDENCIES")
No_delete=VObjDeleteCheck(Var_object)
IF No_delete THEN
	Stat=SetInputFormat("a1",",D,E,")
	Stat=GetValue("BROKEN DEPENDENCY, Delete anyway, Exit",Answer$)
	IF ExitScript(Destination$) THEN Leave
	IF Answer$="D" THEN Delete_object
	GOTO Pick_object
END IF

Delete_object:!
Stat=SetInputFormat("a1",",Y,N,")
Stat=GetValue("DELETE OBJECT "&Name$&"  Yes or No",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$="N" THEN Pick_object

Vgroup=VObjectRefGroup(Var_object,WsVariableRef)
Stat=DeleteEntity(Var_object)
Stat= DelStrgyVarsInGrp(Vgroup)
Stat= DeleteEntity(Vgroup)

GOTO Pick_object

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