
! script name: filing.d/readextfile
! topic: read external

!A
!A NAME:
!A
!A 	External
!A
!A DESCRIPTION:
!A
!A 	This script allows an external to be read in.
!A
!B INSTRUCTIONS:
!B
!B 	SELECT EXISTING EXTERNAL FILE: The selection box will appear at this
!B 		time for a selection to be made.
!B
!B 	REFERENCE POINT ABS X,Y,Z: Enter the X,Y,Z coordinates of the reference
!B 		point.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	X ANGLE: Enter the angular orientation in X.
!B
!B 	Y ANGLE: Enter the angular orientation in Y.
!B
!B 	Z ANGLE: Enter the angular orientation in Z.
!B
!B 	SCALE FACTOR: Enter the scale factor of the external to be brought in.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: external ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Output$[256]
DIM D_label$[256]
DIM Sub_label$[256]
DIM F_label$[256]
DIM Choice$[256]
DIM Mask$[32]
DIM Dir$[256]

DeActivateUndo
Stat= NamedVarStr("retrieve dir",WsSystemVars,"/usr/weber/ST/",Dir$)
D_label$="DIRECTORY"
Sub_label$="SUB DIRECTORIES"
F_label$="FILES"
Choice$="FILE TO OPEN"
Mask$= "*"

Start:!
Stat=UserFileBox(Dir$,Mask$,D_label$,Sub_label$,F_label$,Choice$)
Stat=SetInputFormat("a99","")
Stat=GetValue("SELECT EXISTING EXTERNAL FILE",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF ANSWER$= "CANCEL" THEN Leave
IF NamedVarVal("save dirs",WsSystemVars,0) THEN V1=CreateVariable("retrieve dir",WsSystemVars,PathNameDirectory(Answer$))

Name$=Answer$
StdWorkplane
LowerFileBox

Pt=XyzInput("REFERENCE POINT ",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

stat= SetInputFormat("n4=","")
stat= SetEqualsValue(0)

Xangle=GetValue("X ANGLE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Yangle=GetValue("Y ANGLE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Zangle=GetValue("Z ANGLE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

stat= SetInputFormat("n4=","")
stat= SetEqualsValue(1.0)
Scale_factor=GetValue("SCALE FACTOR",Answer$)
IF (ExitScript(Destination$)) THEN Leave

T1=AngleTransform(Pt,Xangle,Yangle,Zangle)

stat= DisplayMessage("READING EXTERNAL FILE: "&Name$)
stat= ReadExtFile(Name$,t1,Scale_factor,1)

stat= DeleteEntity(Pt)


GOTO Start


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