
! script name: lines.d/connectents
! topic: connect two entities by joining ends

!A
!A NAME:
!A
!A 	Z Connect Elements
!A
!A DESCRIPTION:
!A
!A 	This script connects two entities by joining the ends of their
!A 	respective elements with trimmed lines.
!A
!B INSTRUCTIONS:
!B
!B 	PICK FIRST ENTITY: Pick one of the entities to be connected.
!B
!B 	PICK NEXT ENTITY: Pick the other entity to be connected.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: z connect elements ")

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

DeActivateUndo
Active_workplane=0
Work=CurrentWorkplane
IF (ValidGeometry(Work)) THEN Active_workplane=1

Blend_loop:!
stat= SetInputFormat("n4","")

StdWorkplane

E1=PickEntity("PICK FIRST ENTITY ")
IF (ExitScript(Destination$)) THEN Leave
T1=LastPickPara

E2=PickEntity("PICK NEXT ENTITY ")
IF (ExitScript(Destination$)) THEN Leave
T2=LastPickPara

Dir1=WsForward
IF (T1>0.5) THEN Dir1=WsReverse

Dir2=WsForward
IF (T2>0.5) THEN Dir2=WsReverse

Stat=LinearBlend(E1,Dir1,E2,Dir2)

GOTO Blend_loop

Leave:!
IF Active_workplane THEN
	Stat=SetWorkplane(Work)
ELSE
	StdWorkplane
END IF
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
