

! script name: vsplines.d/bsplinegroup
! var_topic: construct bspline curve between existing group of points

!A
!A NAME:
!A
!A 	NURBS: Control points group   VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script constructs a bspline curve using a group of points
!A	as control points.
!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/NurbCurve.jpg
!B INSTRUCTIONS:
!B
!B 	PICK GROUP OF POINTS: Pick the group of points.
!B 		The spline curve will use the points in the
!B 		order they appear in the group.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: nurbs: control points group")

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

Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

ActivateUndo
Group_loop:!
Group= PickGroupEnt("PICK GROUP OF POINTS")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Group) THEN Group_loop
Stat= EntityNameCheck(Group,Group$)

Stat= GenerateVarName(WsBSplineEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("SPLINE: nurb curve ")
Stat= SetRecDelLastExec
Group1=PtsInGroup(Group$,WsPickPoints)
Ps= GroupElement(Group1,1)
Pe= GroupElement(Group1,GroupCount(Group1))
Spline_ent=BSplinePtGrp(Group1,3,3)
Stat=DeleteEntity(Group1)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(Spline_ent) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("nurb curve")
	Stat= AddItemToUndo(WsUBCreateMode,Spline_ent)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Group_loop


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

