
! script name: nurbs.d/nurbtocubic
! topic: Sample - convert all nurbs to cubic splines

!A
!A NAME:
!A
!A 	Convert Nurbs to Cubic Spline
!A
!A DESCRIPTION:
!A
!A 	This script converts all nurbs to cubic splines.  A cubic spline
!A 	is a polynomial spline of 3rd degree.
!A
!B INSTRUCTIONS:
!B
!B 	TOLERANCE: Enter the tolerance to be used for the calculations
!B 		of the cubic spline.
!B
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: convert nurbs to cubic spline ")

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


DeActivateUndo
Units= CurrentUnits
Tol= .001
IF Units= WsMetric THEN Tol= 0.01


stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Tol)
Tol= GetValue("TOLERANCE",Answer$)
IF (ExitScript(Destination$)) THEN Leave


Nurb_group= GrpByEntType(WsBSplineEnt)

Number_nurbs= GroupCount(Nurb_group)

FOR I= 1 TO Number_nurbs

	E1= GroupElement(Nurb_group,I)

	Group=ConvToCspline(E1,Tol)

	stat= DeleteEntity(Group)

NEXT I

stat= DeleteGroup(Nurb_group)


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