
! script name: 3dintersect.d/radiallimits
! 3dtopic: limit points for a 3D surface group

!A
!A NAME:
!A
!A 	3D Surface group radial limits
!A
!A DESCRIPTION:
!A	
!A	This function finds the radial limits for a group of surfaces.
!A	The function creates circles for the maximum and minimum radii
!A	of the part relative the the axis line. It also creates points
!A	which represent the maximum and minimum extend along the axis
!A	line of the part.
!A
!B INSTRUCTIONS:
!B
!B 	PICK SURFACE GROUP: Pick the group of surfaces.
!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	part makes from a rotary axis.
!C	The minimum radius can find the size of an opening in a part.
!C

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

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

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

Start:!

Pick_loop:!

Stat= SetPickMask(WsPickSurfOnly)
stat= SetInputFormat("n4a1",",N,")
Part_group=PickGroupEnt("PICK SURFACE GROUP   Name ",WsSurfaceGroup,Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="N" THEN
	GOSUB Get_named_group
END IF
IF NOT ValidGeometry(Part_group) THEN Pick_loop
Stat= SetPickMask(WsPickGeometry)

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

Group1=PartRadialLimits(Part_group,Axis_line,Tol)
IF NOT ValidGeometry(Group1) THEN Pick_loop

ActivateUndo
Stat= AdvanceUndoNumber("limit points")
Stat= AddGroupToUndo(WsUBCreateMode,Group1,0,WsTrue)

Stat= DeleteEntity(Group1)
GOTO Start


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

Get_named_group:!
Stat=ListGrpNames("SURFACE GROUPS","selected group","",WsSurfaceGroup)
IF Stat=1 THEN Leave_name
Stat=SetInputFormat("a99","")
Stat=GetValue("SURFACE GROUP NAME",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="CANCEL" THEN Leave_name
Part_group=FindNamedGrp(Answer$)
IF NOT ValidGeometry(Part_group) THEN Get_named_group
Grp_type= GroupType(Part_group)
IF Grp_type <> WsSurfaceGroup THEN Get_named_group
LowerSelectBox
Leave_name:!
Stat=SetInputFormat("n4","")
RETURN


END
