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

!A
!A NAME:
!A
!A 	3D Surface group limit points
!A
!A DESCRIPTION:
!A
!A 	This script makes two points from a group of surfaces.
!A	One point is at xmin,ymin,zmin of the surface group
!A	The other  point is at xmax,ymax,zmax of the surface group
!A
!B INSTRUCTIONS:
!B
!B 	PICK SURFACE GROUP: Pick the group of surfaces.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: part limit points ")

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)

L1=PartMaxMinLimits(Part_group,Tol)
IF NOT ValidGeometry(L1) THEN Pick_loop

Ps= ParameterPt(L1,0.0)
Pe= ParameterPt(L1,1.0)
Stat= DeleteEntity(L1)

ActivateUndo
Stat= AdvanceUndoNumber("limit points")
Stat= AddItemToUndo(WsUBCreateMode,Ps)
Stat= AddItemToUndo(WsUBCreateMode,Pe)

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
