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

!A
!A NAME:
!A
!A 	Edit End Points		VARIATIONAL
!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
!B 		of the connecting elements near the end
!B 		point that is to be modified.
!B
!B 	INPUT NEW ABS X,Y: Enter the X,Y
!B 		coordinates of the new end point location.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!# see also - htdocs/help.d/vdminfo.htm
!# see also - points.d/xyzinput.hlp

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

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

DeActivateUndo
Stat=LineNumberIncr(1)
Start_obj=0

Element_loop:!
Stat=SetInputFormat("n4","")
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

Stat=SetWorkplane(E1)

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)

Stat= DisplayMessage("CALCULATING CHANGES")
Stat= CleanNonVarGrps
Output_script=0
Stat=OutputAllObjects("tempscript","vedit.d/chconnectents",Start_obj,Output_script)
IF Stat=1 THEN Leave

LOAD "tempscript"

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
