
! script name: dynvgeomtol.d/profileline
! var_topic: profile line feature box

!A
!A NAME:
!A
!A 	Profile Line	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script makes a profile line feature box.
!A
!A~ image location - images/profileline.gif
!A
!B INSTRUCTIONS:
!B
!B 	TOLERANCE: Enter the profile line 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 line ")

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



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

Graphical_mode=NamedVarVal("Graphical mode",WsSystemVars,1.0)

ActivateUndo
Start:!
Nsym= 142
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


Place_dim:!
IF NOT Graphical_mode THEN
        Stat= PointInputMode(1)
        Pc=XyzInput("BOX LOCATION",WsXyzInput)
        IF (ExitScript(Destination$)) THEN Leave
        IF NOT ValidGeometry(Pc) THEN Line_loop
        Last_pick_ent= LastPickEnt
        Pick_para= LastPickPara
        Pick_return= CurrPickReturn
        IF NOT ValidDependency(Last_pick_ent) THEN
                 Last_pick_ent= CopyEntity(Pc)
                 Stat= EntityNameCheck(Last_pick_ent,Point$)
		 Pc_created=1
        ELSE
                 Stat= EntityNameCheck(Last_pick_ent,Point$)
		 Pc_created=0
        END IF
        Stat=SetLastPoint(Pc)
	Stat=DeleteEntity(Pc)
ELSE
	PlotOff
	Pc= PointXYZ(0,0,0)
	IF LEN(Datum$) THEN
        	E1= FeatureControlBox(Pc,Tableorig,Symbol$,Toler$,Datum$)
	ELSE
        	E1= FeatureControlBox(Pc,Tableorig,Symbol$,Toler$)
	END IF
	Stat=DeleteEntity(Pc)
	PlotOn
        Which_end=WsEnd
        Vnum= LastPickView
        Stat= DynamicDimEdit(Vnum,E1,Which_end,"PICK LOCATION")
        IF (ExitScript(Destination$)) THEN
                Stat= DeleteEntity(E1)
                GOTO Leave
        END IF

	Tableorig= GetFeatBoxOrigType(E1)
        Last_pick_ent= LastPickEnt
        Pick_para= LastPickPara
        Pick_return= CurrPickReturn
        IF NOT ValidDependency(Last_pick_ent) THEN
		 Pc= ParameterPt(E1,1.0)
                 Last_pick_ent=CopyEntity(Pc)
                 Stat= MakeVisible(Last_pick_ent)
                 Stat= EntityNameCheck(Last_pick_ent,Point$)
		 Pc_created=1
        ELSE
		 Pc= ParameterPt(E1,1.0)
                 Stat= EntityNameCheck(Last_pick_ent,Point$)
		 Pc_created=0
        END IF
        Stat=SetLastPoint(Pc)
        Stat=DeleteEntityList(Pc,E1)
END IF


Stat= GenerateVarName("D",Name$)
RecordFunctionOn
Stat= RecordDescr("GEOMETRIC TOL: Profile line")
Stat= SetRecDelLastExec
SELECT Pick_return
CASE WsGeometryEnd
        Pc= ParameterReturnPt(Point$,Pick_para,WsGeometryEnd)
CASE WsGeometryMid
        Pc= ParameterReturnPt(Point$,Pick_para,WsGeometryMid)
CASE WsGeomCenter
        Pc= ParameterReturnPt(Point$,Pick_para,WsGeomCenter)
END SELECT
V0= FreeParameter("Table origin",Tableorig)
IF LEN(Datum$) THEN
        V1= StringConstant(Symbol$)
        V2= StringConstant(Toler$)
        V3= StringConstant(Datum$)
        E1= FeatureControlBox(Pc,V0,V1,V2,V3)
ELSE
        V1= StringConstant(Symbol$)
        V2= StringConstant(Toler$)
        E1= FeatureControlBox(Pc,V0,V1,V2)
END IF
Stat=DeleteEntity(Pc)
Stat= NameEntity(E1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(E1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("profile line")
	IF Pc_created THEN Stat= AddItemToUndo(WsUBCreateMode,Point$)
	Stat= AddDimToUndo(WsUBCreateMode,E1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF

Stat= PlotEntity(Point$)

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