
! script name: vdraftedit.d/extlineoff
! var_topic: extension line on/off

!A
!A NAME:
!A
!A 	EXTENSION LINE ON/OFF    VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows extension line to be turned on or off.
!A
!A~ image location - images/editdimdata.gif
!A
!B INSTRUCTIONS:
!B
!B 	PICK EXTENSION LINE : Pick one of the dimension lines
!B 		near the line that is to be modified.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: ext line on/off ")

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

Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave
DEG

Calc=1
No_Calc=0
Toggle_sw=2
Turn_on=1

ActivateUndo
Element_loop:!
stat= SetInputFormat("n4","")

Element_loop:E1=PickEntity("PICK EXTENSION LINE")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(E1) THEN Element_loop
E2= ParentDimEnt(E1)
IF NOT ValidDependency(E2) THEN Element_loop
Stat= EntityNameCheck(E2,Element$)
T1=LastPickPara
Pick_point= ParameterPt(E1,T1)
which_end= ComDimSelectPt(E2,Pick_point)

SELECT Which_end
CASE WsStart
	ActivateUndo
	Stat= AdvanceUndoNumber("ext line")
	Stat= AddDimToUndo(WsUBModifyMode,Element$)

	RecordFunctionOn
	Stat= RecordDescr("DIMENSION: Ext line")
	Stat=EditDraftSetting(Element$,WsExtensionOn,Turn_on,No_Calc)
	Stat=EditDraftSetting(Element$,WsLeftExtOn,Toggle_sw,Calc)
	RecordFunctionOff
	Curr_record= CurrentVarRecord
	CloseVarRecord
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
CASE WsEnd
	ActivateUndo
	Stat= AdvanceUndoNumber("ext line")
	Stat= AddDimToUndo(WsUBModifyMode,Element$)

	RecordFunctionOn
	Stat= RecordDescr("DIMENSION: Ext line")
	Stat=EditDraftSetting(Element$,WsExtensionOn,Turn_on,No_Calc)
	Stat=EditDraftSetting(Element$,WsRightExtOn,Toggle_sw,Calc)
	RecordFunctionOff
	Curr_record= CurrentVarRecord
	CloseVarRecord
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
CASE 2
	ActivateUndo
	Stat= AdvanceUndoNumber("ext line")
	Stat= AddDimToUndo(WsUBModifyMode,Element$)

	RecordFunctionOn
	Stat= RecordDescr("DIMENSION: Ext line")
	Stat=EditDraftSetting(Element$,WsLeftExtOn,Turn_on,No_Calc)
	Stat=EditDraftSetting(Element$,WsRightExtOn,Turn_on,No_Calc)
	Stat=EditDraftSetting(Element$,WsExtensionOn,Toggle_sw,Calc)
	RecordFunctionOff
	Curr_record= CurrentVarRecord
	CloseVarRecord
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END SELECT

Stat=DeleteEntity(Pick_point)
GOTO Element_loop

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