
! script name: hexajet.d/process_contour
! var_topic: processes a contour for the hexajet

!A
!A NAME:
!A
!A 	Process Contour for Hexajet		VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	This script processes a contour for the hexajet. No offset of tapers are added.
!A
!A
!B INSTRUCTIONS:
!B
!B
!B
!B
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: process hexajet contour")

OPTION BASE 1
DIM Destination$[256]
DIM Answer$[256]
DIM A$[256]
DIM Contour$[256]
DIM Offset_var$[256]
DIM Name$[256]
DIM Table_dir$[256]
DIM Question1$[180]
DIM Question$(10)[80],Reply$(10)[80]


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

Table_dir$="/usr/weber/database/tables/Hexajet.d"

ActivateUndo
Pen_color= CurrentColor

Angle= 10
Radius= 1.00
Side= 1

Thickness= 1.0
Overshoot= 0.060
Kerf= 0.014
Feed=10

IF 0 THEN
Thickness:!
Offset_dist:!
Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Thickness)
Thickness=GetValue("MATERIAL THICKNESS",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Feed)
Feed=GetValue("STRAIGHT LINE FEED RATE")
IF (ExitScript(Destination$)) THEN Leave

ELSE

Input_box:!
Question$(1)="MATERIAL THICKNESS"
Question$(2)="STRAIGHT LINE FEED RATE"

Reply$(1)=VAL$(Thickness)
Reply$(2)=VAL$(Feed)


Stat=ChangeLabelStr("MultiLineShell","HexaContour")
ApplyLoop: !
Stat=MultiInput(Question$(*),Reply$(*),0)
IF (ExitScript(Destination$)) THEN Leave
IF Stat>2 THEN Leave

A$= Reply$(1)
Answer$= TRIM$(A$)
Stat= EvaluateAnswer(Answer$,Thickness)
IF Stat=1 THEN Input_box
IF Thickness< 0.0001 THEN Input_box

A$= Reply$(2)
Answer$= TRIM$(A$)
Stat= EvaluateAnswer(Answer$,Feed)
IF Stat=1 THEN Input_box
IF Feed< 0.0001 THEN Input_box

END IF

Pick_loop:!
Stat=SetPickMask(WsPickNoSurf)
E1=PickEntity("PICK THE CONTOUR")
IF (ExitScript(Destination$)) THEN Leave
Contour= ParentGroup(E1,0)
IF NOT ValidDependency(Contour) THEN Pick_loop
Stat= EntityNameCheck(Contour,Contour$)


Stat= GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("HEXAJET: Contour")
Stat= SetRecDelLastExec
Stat= NullReference(Contour$)
Pc=PointXYZ(100,0,0)
Table1= ImportTable(Table_dir$&"/RampTable_MM",Pc,WsUpperLeft,CHR$(9))
Stat= NameEntity(Table1,"Hexajet_feed_ramp_table")
Table2= ImportTable(Table_dir$&"/100%_Speed_RadiusTable_MM",Pc,WsUpperLeft,CHR$(9))
Stat= NameEntity(Table2,"Hexajet_thickness_radius")
Table3= ImportTable(Table_dir$&"/%Radius_%SpeedTable",Pc,WsUpperLeft,CHR$(9))
Stat= NameEntity(Table3,"Hexajet_radius_multiplier")
Table4= ImportTable(Table_dir$&"/ThicknessTable_MM",Pc,WsUpperLeft,CHR$(9))
Stat= NameEntity(Table4,"Hexajet_thickness_table")
Table5= ImportTable(Table_dir$&"/Comp_Side_Taper",Pc,WsUpperLeft,CHR$(9))
Stat= NameEntity(Table5,"Hexajet_side_compensation_taper")
Table6= ImportTable(Table_dir$&"/CornerSlowdownTable",Pc,WsUpperLeft,CHR$(9))
Stat= NameEntity(Table6,"Hexajet_corner_slowdown")
Table7= ImportTable(Table_dir$&"/Cutting_Table_SQ_MM",Pc,WsUpperLeft,CHR$(9))
Stat= NameEntity(Table7,"Hexajet_cutting_table")
Table8= ImportTable(Table_dir$&"/DynamicPierceDistance_MM",Pc,WsUpperLeft,CHR$(9))
Stat= NameEntity(Table8,"Hexajet_dynamic_pierce_dist")
Table9= ImportTable(Table_dir$&"/Forward_Speed_Taper",Pc,WsUpperLeft,CHR$(9))
Stat= NameEntity(Table9,"Hexajet_forward_speed_taper")
Table10= ImportTable(Table_dir$&"/Forward_Taper_Speed",Pc,WsUpperLeft,CHR$(9))
Stat= NameEntity(Table10,"Hexajet_forward_taper_speed_factor")
Table11= ImportTable(Table_dir$&"/Quality_Multiplier_Table",Pc,WsUpperLeft,CHR$(9))
Stat= NameEntity(Table11,"Hexajet_quality_multiplier_table")
Table12= ImportTable(Table_dir$&"/Contour_Start_Codes",Pc,WsUpperLeft,CHR$(9))
Stat= NameEntity(Table12,"Hexajet_contour_start_codes")
Table13= ImportTable(Table_dir$&"/Contour_End_Codes",Pc,WsUpperLeft,CHR$(9))
Stat= NameEntity(Table13,"Hexajet_contour_end_codes")
Table14= ImportTable(Table_dir$&"/Startup_Codes",Pc,WsUpperLeft,CHR$(9))
Stat= NameEntity(Table14,"Hexajet_startup_codes")
V1= FreeParameter("Material thickness",Thickness)
V1= FreeParameter("Material thickness",Thickness)
V8= FreeParameter("Straight Line Feed Rate",Feed)
V9= FreeParameter("IJK vectors on",Ijk_on)
Stat= HexaJetContour(Contour$,V1,V8,V9)
Stat=DeleteEntity(Pc)
Stat=DeleteEntity(Table1)
Stat=DeleteEntity(Table2)
Stat=DeleteEntity(Table3)
Stat=DeleteEntity(Table4)
Stat=DeleteEntity(Table5)
Stat=DeleteEntity(Table6)
Stat=DeleteEntity(Table7)
Stat=DeleteEntity(Table8)
Stat=DeleteEntity(Table9)
Stat=DeleteEntity(Table10)
Stat=DeleteEntity(Table11)
Stat=DeleteEntity(Table12)
Stat=DeleteEntity(Table13)
Stat=DeleteEntity(Table14)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

ActivateUndo
Stat= AdvanceUndoNumber("hexajet contour")
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)

GOTO Pick_loop

Leave:!
Stat=DeleteEntity(Pc)
Stat=DeleteEntity(Table1)
Stat=DeleteEntity(Table2)
Stat=DeleteEntity(Table3)
Stat=DeleteEntity(Table4)
Stat=DeleteEntity(Table5)
Stat=DeleteEntity(Table6)
Stat=SetPickMask(WsPickGeometry)
LowerSelectBox
Stat=SetInputFormat("n4","")
Stat=DeleteEntity(Pt)
IF (NOT LEN(Destination$)) THEN
	  LOAD "typecontrol"
ELSE
	  LOAD Destination$
END IF
END
