
! script name: edit.d/chconnectents
! topic: edit connecting elements end point coordinates

!A
!A NAME:
!A
!A 	End Points
!A
!A DESCRIPTION:
!A
!A	This script allows the end point coordinates of connecting
!A 	elements to be modified.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ELEMENT TO BE CHANGED: Pick one of the connecting elements
!B 		near the end point that is to be modified.
!B
!B 	INPUT NEW ABS X,Y: Enter the X,Y coordinates of the new end point
!B 		location.  NOTE: See XYZ INPUT OPTIONS.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: end points ")

DIM Answer$[256]
DIM Destination$[256]
DEG

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

Element_loop:E1=PickEntity("PICK ELEMENT TO BE CHANGED")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(E1) THEN Element_loop
IF IsTypeElement(E1) THEN Element_loop


T1=LastPickPara

IF (T1<=0.5) THEN
	Which_end=WsStart
	Pold= ParameterPt(E1,0.0)
ELSE
	Which_end=WsEnd
	Pold= ParameterPt(E1,1.0)
END IF

Stat=SetLastPoint(Pold)
Group1=ConnectGroup(E1,Which_end,1,1)
IF ValidGeometry(Group1) THEN
	Stat=Highlight(Group1,WsPickPen,WsDirArrowsOff)
	GraphicsFlush
	Multi_connects=1
ELSE
	Multi_connects=0
END IF

Stat=SetPickMask(WsPickNoSurf)
Pt=XyzInput("INPUT NEW",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
Stat=SetPickMask(WsPickAll)

IF Multi_connects THEN
	Stat=ChConnectEnts(E1,Pt,Which_end)
ELSE
	Stat=ChEndPoint(E1,Pt,Which_end)
END IF


Stat=SetLastPoint(Pt)
Stat=DeleteEntity(Pt)
Stat=DeleteEntity(Pold)
Stat=DeleteEntity(Group1)
GOTO Element_loop

Leave:!
Stat=SetPickMask(WsPickAll)
stat= SetInputFormat("n4","")
Stat=DeleteEntity(Pold)
Stat=DeleteEntity(Pt)
Stat=DeleteEntity(Group1)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
