
! script name: nurbs.d/bspchnintrp
! topic: Sample - interpolate a pointchain by a bspline curve

!A
!A NAME:
!A
!A 	NURBS: Interpolate Pointchain
!A
!A DESCRIPTION:
!A
!A 	This script constructs a bspline curve through a point chain entity.
!A
!B INSTRUCTIONS:
!B
!B	PICK POINTCHAIN: Pick the pointchain to be interpolated.
!B
!C NOTES:
!C
!C	This script is designed to convert pointchains generated by 3D
!C	options into nurb curves. The point chain curve is interpolated
!C	in groups of points controlled by the script variables.
!C
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: nurbs: interpolate point chain ")

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

ActivateUndo
Group_loop:!
PDeg= 3       	! degree of interpolating polynomials 
Number_pts= 8 	! each spline passes through this many points
Control_sw= 0 	! 0 pass through points, 1 use points as control points.
Spline_form= 0 	! 0 GeneralNurb  1 Lines  7 BezierCurve.



Pchain= PickEntity("PICK POINT CHAIN ")
IF (ExitScript(Destination$)) THEN Leave
Etype= EntityType(Pchain)
IF (Etype<> WsPtChainEnt) THEN Group_loop

Spline_group=InterpolatePtGrp(Pchain,Spline_form,PDeg,Number_pts,Control_sw)


ActivateUndo
Stat= AdvanceUndoNumber("nurb curve")
Stat= AddGroupToUndo(WsUBCreateMode,Spline_group,1,WsFalse)
GOTO Group_loop

Leave:!
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
