
! script name: lines.d/bvchntwopts
! topic: construct bivectorchain through two points with vectors

!A
!A NAME:
!A
!A 	BiVectorChain Two Points
!A
!A DESCRIPTION:
!A
!A 	This script constructs a bivector chain between two points.
!A	A bivector chain is a special entity that is used to create
!A	cutterpaths for five axis motion. Each point also has two
!A	vectors associated with in, usually a tangent vector and a
!A	vector which will represent the tool axis line.
!A
!B INSTRUCTIONS:
!B
!B 	FIRST POINT: Pick the starting point for the bivector chain.
!B
!B 	FIRST VECTOR HEAD: Pick the head of the first vector.
!B
!B 	SECOND POINT: Pick the second point.
!B
!B 	SECOND VECTOR HEAD: Pick the head of the second vector.
!B
!B NOTES:
!B
!B	Bivector chains created by this function may be linked into
!B	a contour and then used as leadin moves for five axis cuts.
!B

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

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

Tol=NamedVarVal("3D Cutting Tol",Ws3DSystemVars,0.005)

ActivateUndo
stat= SetInputFormat("n4","")
Line_loop:Ps=XyzInput("FIRST POINT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Ps) THEN Line_loop
Stat=SetLastPoint(Ps)

Ps1=XyzInput("FIRST VECTOR HEAD",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Ps1) THEN Line_loop


Stat=SetLastPoint(Ps)
Pe=XyzInput("SECOND POINT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pe) THEN Line_loop

Stat=SetLastPoint(Pe)
Pe1=XyzInput("SECOND VECTOR HEAD",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pe1) THEN Line_loop


Bv1=BiVectorChTwoPts(Ps,Ps1,Pe,Pe1,WsTrue,Tol)

Stat=SetLastPoint(Pe)
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
Stat=DeleteEntity(Ps1)
Stat=DeleteEntity(Pe1)

ActivateUndo
Stat= AdvanceUndoNumber("bivector chain")
Stat= AddItemToUndo(WsUBCreateMode,Bv1)
GOTO Line_loop

Leave:!

Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
Stat=DeleteEntity(Ps1)
Stat=DeleteEntity(Pe1)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
