
! script name: nurbs.d/convtocirclesinbox
! topic: Sample - convert entity to circles

!A
!A NAME:
!A
!A 	Convert to Circles in Box
!A
!A DESCRIPTION:
!A
!A 	This script allows an entity to be converted into circles.  
!A	This function is valid for: 
!A
!A			Ellipses
!A			Cubic Splines
!A			Nurbs
!A			Point Chains
!A
!B INSTRUCTIONS:
!B
!B 	TOLERANCE: Enter the tolerance to be used for calculating the circles.
!B
!B 	PICK ELEMENT TO BE CONVERTED: Pick the element to be converted.
!B
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: convert to circles ")

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


Ploop:!
Stat= SetInputFormat("n4","")
Group=CreateGroup("TEMP")

Stat= PickBox(Group,Vnum,WsPickPen)
IF (ExitScript(Destination$)) THEN Leave

N1= GroupCount(Group)
FOR I=1 TO N1
	E1= GroupElement(Group,I)
	G1=ConvToCircles(E1,Tol)
	IF ValidGeometry(G1) THEN
		Stat=DeleteEntity(E1)
		Stat=DeleteEntity(G1)
	END IF 
NEXT I
stat= DeleteEntity(Group)

GOTO Ploop

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