
! script name: vcontours.d/unlink
! var_topic: allow a contour to be unlinked

!A
!A NAME:
!A
!A 	Unlink Contour	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a contour (one created by Type #'s or one that was
!A 	auto linked) to be unlinked.  This means that a contour created with
!A 	Type numbers will have the type number association destroyed but the
!A 	geometry will remain intact (lines and arcs). If the contour was formed
!A 	by an auto link, the geometry remains intact.  Note, this will also
!A 	unlink any other group that is associated with this element.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ELEMENT TO BE UNLINKED: Pick an element on
!B 		the contour to be unlinked.
!B

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

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

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

DeActivateUndo
Pick_contour: !
Stat=SetInputFormat("a1",",N,")
Contour=PickGroupEnt("PICK CONTOUR     Name,",0,Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "N" THEN
	GOSUB Get_named_grp
	Contour= Group
END IF
IF NOT ValidDependency(Contour) THEN Pick_contour
Stat=EntityNameCheck(Contour,Contour$)
Stat=Highlight(Contour,WsPickPen,WsDirArrowOff)

RecordFunctionOn
Stat=RecordDescr("CONTOUR: Unlink ")
Stat=UnLink(Contour$)
Stat=DeleteEntity(Contour$)
RecordFunctionOff
CloseVarRecord

GOTO Pick_contour

Get_named_grp:!
Stat=ListGrpNames("GROUP NAMES","selected group","",0)
IF Stat=1 THEN Leave
Stat=SetInputFormat("a99","")
Stat=GetValue("GROUP NAME",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Group=FindNamedGrp(Answer$)
IF NOT ValidGeometry(Group) THEN Get_named_grp
Stat=SetInputFormat("n4","")
LowerSelectBox
RETURN

Leave:!
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
