
! script name: filing.d/placeextfile
! topic: read and position external

!A
!A NAME:
!A
!A 	Place External
!A
!A DESCRIPTION:
!A
!A 	This script allows an external to be read in and positioned.
!A
!B INSTRUCTIONS:
!B
!B 	SELECT EXISTING EXTERNAL FILE: The file selection box will appear at
!B 		this time for a selection to be made.
!B
!B 	SCALE FACTOR: Enter the scale factor of the external to be brought in.
!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 	ANGLE: Enter the angle of orientation for the external.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: place 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

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

Point_loop:!

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

Angle= InputAngle("ANGLE")
IF (ExitScript(Destination$)) THEN Leave


T1=AngleTransform(Pt,0.0,0.0,Angle)

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

stat= DeleteEntity(Pt)


GOTO Point_loop


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