
! script name: nurbs.d/blendbspline
! topic: construct bspline between two points on two entities

!A
!A NAME:
!A
!A 	NURBS Blend
!A
!A DESCRIPTION:
!A
!A 	This script constructs a bspline between two points on two entities.
!A 	A bspline is a rational function of fixed degree and it offers the
!A 	option of non-uniform parameterization.
!A
!A~ image location - images/nurbblend.jpg
!B INSTRUCTIONS:
!B
!B 	PICK FIRST ENTITY: Pick the entity that will be the start of the
!B 		blend.  The point picked will be used to determine directions
!B 		for the blend.
!B
!B 	STARTING POINT ON FIRST ENTITY ABS X,Y: Enter the X,Y coordinates
!B 		of the point on the first entity to be used for the blend.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B 	PICK SECOND ENTITY: Pick the entity that will be the end of the
!B 		blend.  The point picked will be used to determine directions
!B 		for the blend.
!B
!B 	ENDING POINT ON SECOND ENTITY ABS X,Y: Enter the X,Y coordinates
!B 		of the point on the second entity to be used for the blend.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: nurbs blend ")

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

ActivateUndo
Highlight_color= 3
Stat= SetDefaults(WsSelectedEntPen,Highlight_color)
Spline_loop:!

E1=PickEntity("PICK FIRST ENTITY")
IF (ExitScript(Destination$)) THEN Leave
T1=LastPickPara
Stat= SetSelectedFlag(E1,WsTrue)
Stat= PlotEntity(E1)

Ps=XyzInput("STARTING POINT ON FIRST ENTITY",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

E2=PickEntity("PICK SECOND ENTITY")
IF (ExitScript(Destination$)) THEN Leave
T2=LastPickPara
Stat= SetSelectedFlag(E2,WsTrue)
Stat= PlotEntity(E2)

Stat=SetLastPoint(Ps)
Pe=XyzInput("ENDING POINT ON SECOND ENTITY",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave


Dirpt1=ParameterPt(E1,T1)
Dirpt2=ParameterPt(E2,T2)

Dist=DistTwoPts(Ps,Pe)

Weight=Dist/3

S1=BSplineTwoEnt(E1,Ps,Dirpt1,Weight,E2,Pe,Dirpt2,Weight)

Stat=SetLastPoint(Pe)
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
Stat=DeleteEntity(Dirpt1)
Stat=DeleteEntity(Dirpt2)
Stat= SetSelectedFlag(E1,WsFalse)
Stat= PlotEntity(E1)
Stat= SetSelectedFlag(E2,WsFalse)
Stat= PlotEntity(E2)

ActivateUndo
Stat= AdvanceUndoNumber("nurb curve")
Stat= AddItemToUndo(WsUBCreateMode,S1)
GOTO Spline_loop

Leave:!

Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
Stat=DeleteEntity(Dirpt1)
Stat=DeleteEntity(Dirpt2)
Stat= SetSelectedFlag(E1,WsFalse)
Stat= PlotEntity(E1)
Stat= SetSelectedFlag(E2,WsFalse)
Stat= PlotEntity(E2)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
