
! script name: geomtol.d/profilesurf
! topic: profile surface feature box

!A
!A NAME:
!A
!A 	Profile Surface
!A
!A DESCRIPTION:
!A
!A 	This script makes a profile surface feature box.
!A
!A~ image location - images/profilesurf.gif
!A
!B INSTRUCTIONS:
!B
!B 	TOLERANCE: Enter the profile surface tolerance to be entered
!B 		in the feature box, for drafting purposes only.
!B
!# see also - geomtol.d/geominfo.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: profile surface ")

DIM Answer$[256]
DIM Destination$[256]
DIM A$[256]
DIM Toler$[256]
DIM Datum$[30]
DIM Symbol$[30]
DIM Material$[30]
DIM Point$[256]
DIM Name$[256]
DEG


ActivateUndo
Nsym= 141
Dynamic_position=1

Units= CurrentUnits
Tol= 0.005
IF Units= WsMetric THEN Tol= 0.01

Text_loop:!
Symbol$= CHR$(Nsym)

Stat= SetEqualsValue(Tol)
Stat=SetInputFormat("n4=","")
Tol= GetValue("TOLERANCE",ANSWER$)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetInputFormat("a3",",LMC,MMC,RFS,N,")
stat= GetValue("MATERIAL CONDITION  LMC , MMC , RFS , None ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "N", "None", "NONE"
        Material$= ""
CASE  "RFS"
        Material$= CHR$(138)
CASE  "LMC"
        Material$= CHR$(137)
CASE  "MMC"
        Material$= CHR$(136)
END SELECT
Toler$= VAL$(Tol)&" "&Material$


Stat=SetInputFormat("a99","")
Stat= GetValue("DATUM, A B C D E F G , None ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "N", "None", "NONE"
	Datum$=""
CASE ELSE
	Stat= BackSlashChars(Answer$,A$)
	Stat= ReplaceString(A$,"\n",CHR$(10),Answer$)
	Datum$= UPC$(Answer$)
END SELECT

IF Dynamic_position THEN
	Pc= PointXYZ(0,0,0)
ELSE
	Stat=SetInputFormat("n4","")
	Pc=XyzInput("INPUT",WsXyzInput)
	IF (ExitScript(Destination$)) THEN Leave
END IF


Make_box:!
IF LEN(Datum$) THEN
        E1= FeatureControlBox(Pc,Tableorig,Symbol$,Toler$,Datum$)
ELSE
        E1= FeatureControlBox(Pc,Tableorig,Symbol$,Toler$)
END IF
Stat=DeleteEntity(Pc)


IF Dynamic_position THEN
	Which_end=WsEnd
	Vnum= LastPickView
	Stat= DynamicDimEdit(Vnum,E1,Which_end,"PICK LOCATION")
	IF (ExitScript(Destination$)) THEN 
		Stat= DeleteEntity(E1)
		GOTO Leave
	END IF
END IF

ActivateUndo
Stat= AdvanceUndoNumber("feature box")
Stat= AddDimToUndo(WsUBCreateMode,E1)

Leave:!
Stat=SetInputFormat("n4","")
Stat=DeleteEntity(Pc)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	IF Destination$= "SCRIPTSTART" THEN Text_loop
        IF Destination$= "BACKUP" THEN Text_loop
	 LOAD Destination$
END IF
END
