
! script name: vdelete.d/deleteentity
! var_topic: hide a single entity. 

!A
!A NAME: 
!A
!A 	Delete Entity. VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a single element to be deleted.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ELEMENT TO BE DELETED: Pick the element to be deleted.
!B
!B NOTES:
!B
!B 	This is a variational delete function. The delete operation becomes
!B 	part of the variational object. This function should only be used when
!B 	entities which are created variationally are no longer needed and there
!B 	presence in the variational program is not desireable. Normally extra
!B 	elements should just be hidden.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: delete entity ")

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

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

ActivateUndo
Pick_entity:!

Element=PickEntity("PICK ELEMENT TO BE DELETED ")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Element) THEN Pick_entity
Stat=EntityNameCheck(Element,Element$)

Var_record=VarRecordParent(Element)
IF NOT ValidGeometry(Var_record) THEN Pick_entity

ActivateUndo
Stat= AdvanceUndoNumber("delete entity")
Stat= AddItemToUndo(WsUBDeleteMode,Element$)

RecordFunctionOn
Stat=RecordDescr("DELETE: Entity")
Stat=DeleteEntity(Element$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Pick_entity

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