
! script name: wsccommon.d/importigs
! topic: read iges ascii data file and place at its model space

!A
!A NAME:
!A
!A 	Import Iges Data
!A
!A DESCRIPTION:
!A
!A 	This script manipulates IGES ascii data files.  The file can be
!A	loaded as the current job in a "New" mode or merged with the
!A	present job.  The script is also capable of viewing iges header 
!A	information without effecting the current job.
!A
!A	A switch box called the IGES WIDGET (program name: igs_widget) is
!A	available through the named variable "use iges widget".  When
!A	"use iges widget" is set to "yes", the widget will be run, while
!A	a value of "no" turns the widget off.
!A 	

!B INSTRUCTIONS:
!B
!B	If running in new file mode:
!B	THIS ERASES THE CURRENT JOB. LOAD Yes / No: Answering "Y" will
!B	perform a "delete all" operation removing ALL existing geometry,
!B	before loading the file.  Answer "N" to leave the script.
!B
!B 	SELECT IGES FILE: The file selection box will appear.  The user
!B 		should choose the IGES file to be processed.
!B
!B	If running in widget mode the widget will appear on the display.
!B		The full description of the iges widget can be found
!B		later in this document.
!B
!B	If running in merge mode:
!B	Undo or Merge: Enter "U" to undo (delete) the file placement.
!B		Enter "M" to finalize the merge.  Exiting the script
!B		forces an Undo.
!B

DIM Answer$[256],Destination$[256],Name$[256],Dir$[256],D_label$[256],Dir1$[256]
DIM Sub_label$[256],F_label$[256],Choice$[256],Mask$[32],Group_name$[256]
DIM Decision$[256],Syn_name$[56],Mode$[128],Header$[4000]
DIM Startup$[256],Setconstants$[256],Fileheader$[256]
DIM Store_dir$[255],Retrieve_dir$[255],Pics_dir$[255]
DIM Iges_dir$[255],Dxf_dir$[255],Use_widget$[255]
DIM Pass$[128]
DIM Filename$[1024]

DeActivateUndo
Stat=ChangeLabelStr("ScriptNameStatus","Function: import iges")
Stat=NamedVarStr("iges in parameters",WsSystemVars,"-p3",Pass$)

Component_group= 30999
Group_type= Component_group
Group_num=0

IF NOT HasOption(WsHasIges) THEN 
	Stat=MessageFileBox("/usr/weber/ascrpt/sec.d/iges","IGES ACCESS WARNING")
	GOTO Leave_1
END IF

Mode$="new"
IF ARGC>1 THEN
	Filename$= ARGV(1)
ELSE
	Filename$= ""
END IF
Stat= NamedVarStr("use iges widget",WsSystemVars,"no",Use_widget$)

IF Mode$="new" THEN
	Stat= NamedVarStr("startup script",WsSystemVars,"startup",Startup$)
	Stat= NamedVarStr("startup constants",WsSystemVars,"setconstants",Setconstants$)
	Stat= NamedVarStr("storage dir",WsSystemVars,"/usr/weber/ST/",Store_dir$)
	Stat= NamedVarStr("retrieve dir",WsSystemVars,"/usr/weber/ST/",Retrieve_dir$)
	Stat= NamedVarStr("pics storage dir",WsSystemVars,"/usr/weber/ST/pics/",Pics_dir$)
	Stat= NamedVarStr("iges storage dir",WsSystemVars,"/usr/weber/ST/iges/",Iges_dir$)
	Stat= NamedVarStr("dxf storage dir",WsSystemVars,"/usr/weber/ST/dxf/",Dxf_dir$)
	Use_safe= NamedVarVal("use backup routine",WsSystemVars,0.0)
	Time_check= NamedVarVal("time check",WsSystemVars,720.0)
!	Stat=SetInputFormat("a1=",",Y,N,")
!	Stat=SetEqualsValue(0,"Y")
!	Stat=GetValue("THIS ERASES THE CURRENT JOB. LOAD Yes / No ",Answer$)
!	IF ExitScript(Destination$) THEN Leave
Answer$="Y"

	IF Answer$="Y" THEN
		DeleteAll

		Stat= RemoveFile("synfile")
		Stat= RemoveFile("command_buffer")
		Stat= RemoveFile("tapelist")
		Stat= RemoveFile("timefile")
		Stat= RemoveFile("tempdata")
		Stat= RemoveFile("tempscript")
		Stat= RemoveFile("tempfile")
		Stat= RemoveDirFiles("./","*","command_file")
		Stat= RemoveDirFiles("./","*","notepad")
		Stat= RemoveDirFiles("./","*","tapefile")
		Stat= RemoveDirFiles("./","*","",".gif")
		Stat= RemoveDirFiles("./","*","",".jpg")
		Stat= RemoveDirFiles("./","*","",".html")
		Stat= RemoveDirFiles("./","*","",".htm")
		Stat= RemoveDirFiles("./","*","",".hpgl")
		Stat= RemoveDirFiles("./","*","",".plt")

		V1=CreateVariable("startup script",WsSystemVars,Startup$)
		V1=CreateVariable("startup constants",WsSystemVars,Setconstants$)
		V1=CreateVariable("storage dir",WsSystemVars,Store_dir$)
		V1=CreateVariable("retrieve dir",WsSystemVars,Retrieve_dir$)
		V1=CreateVariable("pics dir",WsSystemVars,Pics_dir$)
		V1=CreateVariable("iges storage dir",WsSystemVars,Iges_dir$)
		V1=CreateVariable("dxf storage dir",WsSystemVars,Dxf_dir$)
		V1=CreateVariable("use iges widget",WsSystemVars,Use_widget$)
		V1=CreateVariable("use backup routine",WsSystemVars,Use_safe)
		V1=CreateVariable("time check",WsSystemVars,Time_check)

		V1=CreateVariable("job start time",WsSystemVars,TIMEDATE)
		V1=CreateVariable("accumulated time",WsSystemVars,0.0)
		InitScriptLog
		StdWorkplane
	ELSE
        	LOAD "typecontrol"
	END IF
END IF


Stat= NamedVarStr("iges storage dir",WsSystemVars,"/usr/weber/ST/iges/",Dir$)

IF Mode$="header" OR Use_widget$="no" THEN
IF NOT DoesFileExist(Filename$)=1 THEN
	D_label$="DIRECTORY"
	Sub_label$="SUB DIRECTORIES"
	F_label$="FILES"
	Choice$="FILE TO IMPORT"
	Mask$="[A-Z0-9a-z]*"
	Stat=UserFileBox(Dir$,Mask$,D_label$,Sub_label$,F_label$,Choice$,"IGES")
	Stat=SetInputFormat("a99","")
Restart:!
	Stat=GetValue("SELECT IGES FILE",Filename$)
	IF ExitScript(Destination$) THEN Leave
	IF Filename$= "CANCEL" THEN Leave
	IF Filename$= "" THEN Restart
	IF NamedVarVal("save dirs",WsSystemVars,0) THEN V1=CreateVariable("iges storage dir",WsSystemVars,PathNameDirectory(Filename$))
END IF

	IF Mode$="header" THEN
		Stat= StartIgesIn(Filename$,"-","-p1 -g","global","iges_errors")
		Stat=MessageFileBox("global","IGES GLOBAL DATA")
		Stat=MessageFileBox("iges_errors","IGES ERRORS ENCOUNTERED")
		GOTO Restart
	END IF
END IF

LowerFileBox
IF Use_widget$="no" THEN
	Syn_name$="igsout"
	Stat= DisplayMessage("IMPORTING DATA FROM "&Filename$)
	Stat= StartIgesIn(Filename$,Syn_name$,Pass$,"global","iges_errors")
ELSE
	Stat= DisplayMessage("RUNNING WIDGET")
	Stat= StartIgesIn("","","","global","iges_errors",WsTrue)
	ON ERROR GOTO Problem
	ASSIGN @File TO "igsout_name"
	ENTER @File;Syn_name$
	P=LEN(Syn_name$)
	WHILE ((P>0) AND (NUM(Syn_name$[P,P])<31))
		Syn_name$[P,P]=""
		P=P-1
	END WHILE
Problem:IF LEN(Syn_name$) THEN Noproblem
Syn_name$="igsout"
Noproblem:ASSIGN @File to *
	OFF ERROR
	IF Igs_cancel THEN Leave_1
	Stat= DisplayMessage("IMPORTING DATA FROM IGES")
END IF
Stat=ChangeLabelStr("websys","Synergy Command Window")


!C
!C Iges data is converted to synergy by a process call to "igssyn".
!C The command line statement has the following syntax:
!C
!C Usage:igssyn infile outfile [options]
!C	igssyn  -      outfile [options] < infile
!C	igssyn infile  -  -g  [-p#]
!C	options: [-b[#]] [-c[#]] [-g] [-i] [-m] [-p#] [-s dlist] [-e elist]
!C		 [-u] [-B[#]] [-N[#]] [-R#] [-T#] [-RU#] [-uv#] [-xyz#]
!C		 [-l defaults file] [-S#] [-D] [-w#]
!C
!D igssyn options:  an output file must be specified unless using
!D		the -g option.
!D
!D	these switches are provided for running from the console.
!D
!D	-a# tolerance factor: eg  -a3 will decrease tol by factor of 3.
!D	-b# alter the blank status switch function
!D		-b0 default	- hide blanked entities
!D		-b1 		- include blanked entities - unhidden
!D		-b2 		- do not include blanked entities
!D	-c# convert rational bsplines of degree # or greater to csplines
!D	-c  without # - same as above with # default to 8
!D	-g  process global data only - i.e. produce no output file
!D		with -p2 or -p3 options could do some counting
!D	-i  ignore properties associated with entities to speed up process
!D	-m  turn off transform check switch (i.e., the switch that
!D		ignores the transformation matrix of a parent entity
!D		if it's child has the same transform)
!D	-p# set print level to #.  Print levels:
!D		-p0 no standard output
!D		-p1 print global data
!D		-p2 includes level 1 & record totals
!D		-p3 includes levels 1, 2 & entity totals
!D		-p4 prints entity numbers as they're processed and
!D		    includes level 3
!D		-p5 includes levels 1, 2 & 3, plus names entities using
!D		    i(directory number)
!D		default) level 1 (i.e. -p1 if -p# not specified)
!D	-u  ignore subordinate entity switch
!D	-s dlist - skip all entities in directory record list by dir rec #
!D	-t# trim surface switch bit switch:
!D		(***this deprecated switch is replaced by:
!D			 -S#,-N#,-R#,-T#,-B#,-RU#,-uv#, and -xyz#)
!D		1) trim the surface 0) don't
!D		2) transfer UV  curves also
!D		4) transfer XYZ curves also
!D		possible values:
!D		-t0 don't trim surface
!D		-t1       trim surface
!D		-t2 don't trim surface but include UV  curve
!D		-t3       trim surface and include UV  curve
!D		-t4 don't trim surface but include XYZ curve
!D		-t5       trim surface and include XYZ curve
!D		-t6 don't trim surface but include UV and XYZ curve
!D		-t7       trim surface and include UV and XYZ curve
!D		default) -t1 if -t# not specified
!D	-B  in trimming bicubic surfaces (114's) use the UV curves.
!D		default uses the XYZ curves.  WARNING: can fail!
!D	-N  in trimming nurb surfaces (128's) use the XYZ curves.
!D		default uses the UV curves.  WARNING: can fail!
!D
!D
!D new options:
!D
!D
!D	*****			filter options				*****
!D
!D	-S#	all surfaces:	-S0	->  include - default
!D				-S1	->  exclude
!D				-S2	->  include only surfaces
!D	-D	exclude drafting
!D		default include
!D	-uv#	uv trims:	-uv0	->  as is in file - default
!D				-uv1	->  include all uv trims
!D				-uv2	->  exclude all uv trims
!D	-xyz#	xyz trims:	-xyz0	->  as is in file - default
!D				-xyz1	->  include all xyz trims
!D				-xyz2	->  exclude all xyz trims
!D
!D
!D	*****			trimming options			*****
!D
!D	surface trimming options, where # stands for:	0=uv  trim
!D							1=xyz trim
!D	-B#  bicubics					2=no  trim
!D	-N#  nurbs
!D	-R#  revolutions
!D	-RU# ruled
!D	-T#  tabcyls
!D
!D
!D	*****			special options				*****
!D
!D	-w#		entity timeout - give up on an entity after # minutes
!D	-e elist  	skip all entities of the types in list by entity #
!D	-l pathname	specify default filename to use for switch defaults
!D
!D Most of these settings can be selected via the iges widget (igs_widget)
!D	which in turn, calls igssyn with the proper switch settings.
!E	A description of the iges widget capabilities and usage follows:
!E
!E Program name: /usr/weber/bin/igs_widget
!E
!E Usage:igs_widget [options]
!E	options:[-l defaults file name]
!E		[-p program to run after widget (default value: igssyn)]
!E
!E	The iges widget consists of a select box with a menu bar, Iges
!E	file name selection line, Synergy file name selection line,
!E	Synergy name option menu, and an output report option menu.
!E	
!E	Menu bar pulldown menus:
!E		File, Options - descriptions below
!E	Input IGES file name:
!E		A holding area for the IGES file name.
!E	Output Synergy name and option menu:
!E		A holding area for the Synergy file name.
!E		The option menu has two settings: file & none.
!E		file:
!E			The process will create Synergy geometry
!E			in the named file.
!E		none:
!E			No output file will be created.  Use this option
!E			to count entity totals or view Iges file headers
!E			without creating a Synergy geometry file.
!E	Report option menu:
!E		This menu controls the amount of data the process reports
!E		to the user:
!E		give names, debug, entity totals, record totals, header, none
!E		give names:
!E			All unnamed entities are given a name in the format:
!E			i#	where # is the Iges entity directory number.
!E		debug:
!E			As each entity begins processing it's directory
!E			number is printed with a "start" label.  When the
!E			entity is completed, it's directory number is
!E			printed again with an "end" label.  This mode can
!E			be useful to determine "problem" entities, and then
!E			the "Skipped dir nums" chart (discussed later) can
!E			be used to skip these problem entities.
!E		entity totals:
!E			Report entity totals, record totals, and global data.
!E		record totals:
!E			Report record totals, and global data.
!E		header:
!E			Report global data.
!E		none:
!E			Do not produce a report.
!E
!E	File pulldown menu pushbuttons:
!E		Input, Output, Load defaults, Save defaults, Quit
!E
!E		Input:
!E			Creates a file selection box to select an
!E			Iges file for import to Synergy.  The selected
!E			file name will be copied into the widget's
!E			Input IGES file name selection line.
!E		Output:
!E			Creates a file selection box to select a
!E			Synergy file name.  This file is the storage
!E			area for the translated Iges data.  The chosen
!E			file name will be copied into the widget's
!E			Output Synergy name selection line.
!E		Load defaults:
!E			Creates a file selection box to select an
!E			Iges default options file.  All of the options
!E			switch defaults will be changed to the stored
!E			settings.
!E		Save defaults:
!E			Creates a file selection box to select an
!E			Iges default options file.  All of the current
!E			options switch settings will be stored in the
!E			selected file.
!E		Quit:
!E			Exits the iges widget and leaves the import iges
!E			script.	
!E
!E	Option pulldown menu pushbuttons:
!E		Filters, Trimming, Special
!E
!E		Filters:
!E			Creates a widget with option menus that filter
!E			six different aspects of an Iges file:
!E			Surfaces, Drafting, Properties, UV Trims, XYZ
!E			Trims, Dependencies.
!E
!E			Surfaces: include, exclude, only.
!E				*include:
!E					Include independent surfaces and
!E					dependent surfaces that are
!E					referenced by supported entities
!E				exclude:
!E					Ignore all surfaces.
!E				only:
!E					Include ONLY surfaces.
!E			Drafting: include, exclude.
!E				*include:
!E					Include drafting entities.
!E				exclude:
!E					Ignore drafting entities.
!E			Properties: include, exclude.
!E				*include:
!E					Include iges properties (e.g.
!E					colors, layers, line types, etc.).
!E				exclude:
!E					Ignore iges properties.
!E			UV Trims: as is, include, exclude.
!E				*as is:
!E					Include these features as indicated
!E					by the built-in Iges switch settings.
!E				include:
!E					Include these features regardless
!E					of the built-in Iges switch settings.
!E				exclude:
!E					Ignore these features regardless
!E					of the built-in Iges switch settings.
!E			XYZ Trims: as is, include, exclude.
!E					This option menu's settings have the
!E					same meanings as the "UV Trims" as
!E					applied to XYZ trim curves.
!E			Dependencies: include, exclude.
!E				*include:
!E					Follow the entity parent-child
!E					relationship as defined in the
!E					Iges standard.  In this mode
!E					a supported child entity may be
!E					excluded if it is only referenced
!E					by an unsupported parent or is not
!E					referenced at all.
!E				exclude:
!E					Ignore the parent-child relationship
!E					and bring in all supported entities.
!E					WARNING: the parent-child
!E					relationship is sometimes vital to
!E					an entities' placement in model space.
!E					Therefore, this switch setting may
!E					cause more problems than it solves.
!E
!E			The filters widget has two additional push buttons.
!E			These push buttons have the same function for all
!E			three option widgets:
!E			Done and Restore/Defaults.
!E			Done:
!E				Use this button to accept the current switch
!E				settings.
!E			Restore/Defaults:
!E				This button starts with a Restore label but
!E				once a switch setting has been altered, it's
!E				label changes to Defaults.  Use the Defaults
!E				button to reset the switch settings back to
!E				their default state.  After Defaults has been
!E				selected, the button label returns to Restore.
!E				The user can switch back and forth between
!E				default settings or the last changed values
!E				by pushing this button repeatedly.
!E	*(default switch setting).
!E
!E		Trimming:
!E			Creates a widget with option menus that control
!E			the trimming methods used on five surface types:
!E			Nurbs, Revolutions, Tabcyls, Parasplines, Ruled.
!E
!E			Nurbs(iges entity 128): uv trim, xyz, off.
!E				*uv trim:
!E					Trim the nurb surfaces using the
!E					uv trim curve child of the trimmed
!E					surface (iges entity 144) parent.
!E				xyz:
!E					Use the xyz trim curve to trim these
!E					surfaces.
!E				off:
!E					Do not trim these surfaces.
!E			Revolutions(iges entity 120): uv trim, xyz, off.
!E				uv trim:
!E					Not available at this time.
!E				*xyz:
!E					Use the xyz trim curve to trim these
!E					surfaces.
!E				off:
!E					Do not trim these surfaces.
!E			Tabcyls(iges entity 122): uv trim, xyz, off.
!E				uv trim:
!E					Not available at this time.
!E				*xyz:
!E					Use the xyz trim curve to trim these
!E					surfaces.
!E				off:
!E					Do not trim these surfaces.
!E			Parasplines(iges entity 114): uv trim, xyz, off.
!E				uv trim:
!E					Trim the parametric spline surfaces
!E					using the uv trim curve child of
!E					the trimmed surface parent.
!E				*xyz:
!E					Use the xyz trim curve to trim these
!E					surfaces.
!E				off:
!E					Do not trim these surfaces.
!E			Ruled(iges entity 122): uv trim, xyz, off.
!E				uv trim:
!E					Not available at this time.
!E				*xyz:
!E					Use the xyz trim curve to trim these
!E					surfaces.
!E				off:
!E					Do not trim these surfaces.
!E	*(default switch setting).
!E
!E		Special:
!E			Creates a widget to control miscellaneous
!E			scales and entity skipping tables.
!E
!E			Tolerance factor: [1-25]
!E				This setting acts as the divisor for the
!E				internal tolerance values used in surface
!E				trimming (e.g To make the internal
!E				tolerance 1/2 of it's current value
!E				set this to 2.  A setting of 10 will
!E				make the internal tolerance 1/10 of it's
!E				normal setting).
!E			Entity timeout: [0-25]
!E				This scale value represents the	maximum
!E				time, in minutes, to spend on any single
!E				entity.  If an entity has corrupt data
!E				that causes unresolved results, the
!E				timeout will force an exit of that
!E				entity's routine so the program can
!E				carry on with the next entity.  The default
!E				zero value turns the timeout off.
!E			Convert nurb surfs degree: [0-25]
!E				This setting represents the minimum degree
!E				of nurb surface to convert to parametric
!E				spline surface.  The default zero value
!E				turns nurb conversion off.
!E			Skipped dir nums:
!E				Fill this table in with the directory
!E				numbers of Iges entities to ignore.
!E			Skipped entity types:
!E				Fill this table in with Iges entity type
!E				numbers to ignore.  (see table below for
!E				descriptions of entity type numbers).
!F
!F	Curve and Surface Geometric Entities:
!F
!F	Entity	
!F	type#	Entity description
!F----------------------------------
!F	100	Circle
!F	102	Composite curve
!F	104	Conic arc
!F	106	Copious data - Linear path - Simple closed planar path
!F	108	Plane
!F	110	Line
!F	112	Parametric spline curve
!F	114	Parametric spline surface
!F	116	Point
!F	118	Ruled surface
!F	120	Surface of revolution
!F	122	Tabulated cylinder
!F	124	Transformation matrix
!F	126	Ration b-spline curve
!F	128	Ration b-spline surface
!F	140	Offset surface
!F	142	Curve on a parametric surface
!F	144	Trimmed parametric surface
!F
!F	Annotation Entities:
!F
!F	Entity	
!F	type#	Entity description
!F----------------------------------
!F	202	Angular dimension
!F	204	Curve dimension
!F	206	Diameter dimension
!F	208	Flag note
!F	210	General label
!F	212	General note
!F	213	New general note
!F	214	Leader
!F	216	Linear dimension
!F	218	Ordinate dimension
!F	220	Point dimension
!F	222	Radius dimension
!F	228	General symbol
!F
!F	Structure Entities:
!F
!F	Entity	
!F	type#	Entity description
!F----------------------------------
!F	308	Subfigure definition
!F	402	Associativity instance
!F	404	Drawing
!F	408	Subfigure instance
!F	410	View
!F

Stat=MessageFileBox("global","IGES GLOBAL DATA")
Stat=MessageFileBox("iges_errors","IGES ERRORS ENCOUNTERED")


StdWorkplane

New_location: !

IF Mode$<>"new" THEN
	Gname$="IGES_DATA"
	Path_num=CurrPathNum
	Cont_num=CurrContourNum
	Hole_num=CurrHoleNum
	Path_grp_num=CurrPathGrpNum
	Hole_grp_num=CurrHoleGrpNum


	SELECT Mode$
	CASE "2d"
		Stat=SetInputFormat("n4","")
		Pc= XyzInput("LOCATION",WsXyzInput)
		IF ExitScript(Destination$) THEN Leave

		Angle= InputAngle("ORIENTATION ANGLE")
		IF ExitScript(Destination$) THEN Leave
		T1=AngleTransform(Pc,0,0,Angle)
	CASE "3d"
		E1=PickEntity("PICK ENTITY FOR WORKPLANE")
		IF (ExitScript(Destination$)) THEN Leave

		Stat=SetWorkplane(E1)
		Work= CurrentWorkplane
		IF NOT ValidGeometry(Work) THEN
			Pc= PointXYZ(0,0,0)
			T1= AngleTransform(Pc,0,0,0)
		ELSE
			T1= Work
		END IF
	CASE ELSE
		Pc=PointXYZ(0,0,0)
		T1= AngleTransform(Pc,0,0,0)
	END SELECT

	PlotOff

	Group=ReadGroupFile(Group_name$,Group_type,Syn_name$)

	IF ValidGeometry(Group) THEN 
		Stat= TransGroupTrans(Group,T1)
	END IF
	Stat= DeleteEntity(Pc)
	PlotOn
	ResizeAll

	Decision$="U"
	Stat=SetInputFormat("a1=",",U,M,")
	Stat=SetEqualsValue(0,"M")
	Stat=GetValue("Undo or Merge",Answer$)
	IF ExitScript(Destination$) THEN Leave
	Decision$=Answer$
	IF Mode$="" THEN Leave
	IF Decision$="M" THEN
		Group_num= Group_num+1
		Group_name$= Gname$&VAL$(Group_num)
	ELSE
		GOSUB Delete_group
		GOSUB Reset_counters
	END IF
	GOTO New_location
ELSE
	PlotOff
	Stat=ReadStoredFile(Syn_name$,1,1)

	Stat= CurrentHeader(Header$)
	IF LEN(Header$) THEN
        	Head=ReadUserData(WsGeneralString,"HEADER",Header$)
	ELSE
		Fileheader$= "signature"
		Head=ReadUserData(9991,"HEADER",Fileheader$)
	END IF
	IF ValidGeometry(Head) THEN
        	Versn= Systemversion
        	OUTPUT A$ USING "#,5D.DD"; Versn
        	Stat= PutUserString(Head,"SYNERGY:",A$)
        	Stat= PutUserString(Head,"File name:","NONE")
        	Stat= PutUserString(Head,"Units:"," ")
        	Stat= PutUserString(Head,"Comments:","data imported from IGES")
        	Stat= UserDataString(Head,Header$)
        	Stat= FileHeader(Header$)
        	Stat= DeleteEntity(Head)
	END IF
	PlotOn
	ResizeAll
END IF

Leave:!


IF NOT ValidGeometry(Group) THEN Leave_1

IF Decision$="U" THEN
	GOSUB Delete_group
	GOSUB Reset_counters
ELSE
   Stat= DeleteEntity(Group)
END IF

TransformCleanup

Leave_1: !

LowerFileBox
Stat=SetInputFormat("n4","")
Stat= DeleteEntity(Pc)

IF NOT LEN(Destination$) THEN
	IF Mode$="new" THEN
	 	LOAD Setconstants$
	ELSE
	 	LOAD "typecontrol"
	END IF
ELSE
	 LOAD Destination$
END IF

Delete_group:!
IF NOT ValidGeometry(Group) THEN RETURN
Temp_group=Group
Stat=UnLink(Temp_group)
Stat=DeleteGroup(Temp_group,1)
Stat=DeleteEntity(Temp_group)
RETURN

Reset_counters: !
Stat=SetCurrPathNum(Path_num)
Stat=SetCurrContNum(Cont_num)
Stat=SetCurrHoleNum(Hole_num)
Stat=SetPathGrpNum(Path_grp_num)
Stat=SetHoleGrpNum(Hole_grp_num)
RETURN

END

