
! script name: v3dinter.d/sradiallimits
! var_topic: limit points for a 3D surface surface

!A
!A NAME:
!A
!A 	3D Surface radial limits  VARIATIONAL
!A
!ADESCRIPTION:
!A
!A	This function finds the radial limits for a surface.
!A	The function creates circles for the maximum and minimum radii
!A	of the surface relative the the axis line. It also creates points
!A	which represent the maximum and minimum extend along the axis
!A	line of the surface.
!A
!B INSTRUCTIONS:
!B
!B	PICK SURFACE: Pick the surface.
!B
!B	PICK AXIS LINE: Pick the axis line.
!B
!C NOTE:
!C
!C	This function can be used to find the maximum radius that a
!C	surface makes from a rotary axis.
!C	The mimumum radius can find the size of an opening in a surface.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: surface radial limits ")

DIM Destination$[256]
DIM Answer$[256]
DIM Surface$[256]
DIM Axis_line$[256]
DIM Pname1$[256]
DIM Pname2$[256]
DIM Cname1$[256]
DIM Cname2$[256]


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

Tol=NamedVarVal("3D Part Limits Tol",Ws3DSystemVars,0.040)

ActivateUndo
Start:!

Pick_loop:!
Stat= SetPickMask(WsPickSurfOnly)
stat= SetInputFormat("n4","")
Surface=PickEntity("PICK SURFACE GROUP ")
IF (ExitScript(Destination$)) THEN Leave
Stat= SetPickMask(WsPickGeometry)
IF NOT ValidDependency(Surface) THEN Pick_loop
Stat= EntityNameCheck(Surface,Surface$)

Axis_line:Axis_line=PickSpecificEnt("PICK AXIS LINE",WsPickLines)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Axis_line) THEN Axis_line
Stat= EntityNameCheck(Axis_line,Axis_line$)

Stat= GenerateVarName(WsPointEnt,Pname1$)
Stat= GenerateVarName(WsPointEnt,Pname2$)
Stat= GenerateVarName(WsCircleEnt,Cname1$)
Stat= GenerateVarName(WsCircleEnt,Cname2$)
RecordFunctionOn
Stat= RecordDescr("CIRCLE: Radial limits ")
Stat= SetRecDelLastExec
Stat= NullReference(Surface$)
V1= FreeParameter("Tolerance",Tol)
G1=SurfRadialLimits(Surface$,Axis_line$,V1)
P1= GroupElement(G1,1)
P2= GroupElement(G1,2)
C1= GroupElement(G1,3)
C2= GroupElement(G1,4)
Stat= NameEntity(P1,Pname1$)
Stat= NameEntity(P2,Pname2$)
Stat= NameEntity(C1,Cname1$)
Stat= NameEntity(C2,Cname2$)
Stat= DeleteEntity(G1)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(P1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("radial limits")
	Stat= AddItemToUndo(WsUBCreateMode,P1)
	Stat= AddItemToUndo(WsUBCreateMode,P2)
	Stat= AddItemToUndo(WsUBCreateMode,C1)
	Stat= AddItemToUndo(WsUBCreateMode,C2)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Start


Leave:!
stat= SetInputFormat("n4","")
Stat= SetPickMask(WsPickGeometry)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF

END
