
! script name: vpksolids.d/vpksimplescrew
! solids: adds screwshape to a body
!A
!A NAME:
!A
!A 	Variable Pitch Simple Screw:   VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	This script creates a simple variable pitch screw.
!A
!B INSTRUCTIONS:
!B		NUMBER OF FLIGHTS: Number of flights
!B
!B		Left or Right HAND SCREW: Is the screw left or right hand.
!B
!B		SCREW DIAMETER  Connect: Diameter of od of the screw. Connect
!B			will link diameter with previous section. 
!B
!B		START PITCH   Connect: Give the starting pitch. Connect will 
!B			link pitch to end of previous section.
!B
!B		END PITCH   Constant: Give the starting pitch. Constant will 
!B			make pitch variationally constant.
!B
!B		START CHANNEL DEPTH   Connect: Start depth of channel.
!B
!B		END CHANNEL DEPTH   Constant: End depth of channel.
!B
!B		START FLIGHT WIDTH   Connect: Starting width of flight.
!B
!B		END FLIGHT WIDTH   Constant: Ending width of flight.
!B
!B		START ANGLE   Connect: Starting angle orientation.
!B
!B
!B NOTES:
!B
!B	This script creates a solid model of a section of a simple
!B      variable pitch screw. The flights may either extend the complete
!B	number of turns or it may be cutoff at the ends.
!B
!B
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: var pitch screw ")

OPTION BASE 1
DIM Destination$[256]
DIM Answer$[256]
DIM A$[256]
DIM B$[256]
DIM Name$[256]
DIM Point$[256]
DIM Pname$[256]
DIM Prop_name$[256]
DIM Dia_var$[256]
DIM SLead_rad_var$[256]
DIM STrail_rad_var$[256]
DIM ELead_rad_var$[256]
DIM ETrail_rad_var$[256]
DIM Spitch_var$[256]
DIM Epitch_var$[256]
DIM Length_var$[256]
DIM Swidth_var$[256]
DIM Ewidth_var$[256]
DIM Sdepth_var$[256]
DIM Edepth_var$[256]
DIM Sangle_var$[256]
DIM Section_type$[256]
DIM Question$(20)[80]
DIM Reply$(20)[80]

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


ActivateUndo
Units= CurrentUnits
IF Units= WsMetric THEN
        Screw_radius= 57
        Start_pitch= 114
        End_pitch= 114
	Screw_length= 250
ELSE
        Screw_radius= 2.25
        Start_pitch= 4.5
        End_pitch= 4.5
	Screw_length= 10
END IF
astep= 10.0
Nflights=1
Use_input_box=1

Start:!
Stat= GLPlotOn

Cloop:!
Stat=SetInputFormat("a1=",",F,M,T,V,")
Stat=SetEqualsValue(0,"F")
Stat=GetValue("TYPE: Feed, Meter, Transition, Vent ",Answer$)
IF ExitScript(Destination$) THEN Leave
SELECT Answer$
CASE "F"
	Section_type$="Feed"
CASE "M"
	Section_type$="Meter"
CASE "T"
	Section_type$="Transition"
CASE "V"
	Section_type$="Vent"
END SELECT

IF Use_input_box THEN Make_questions

Stat=SetInputFormat("n0=","")
Stat=SetEqualsValue(Nflights)
Nflights=GetValue("NUMBER OF FLIGHTS",Answer$)
IF ExitScript(Destination$) THEN Leave

V1= FindNamedVar("Curr_Section",WsVariationVars)
Section_num= VariableValue(V1)
IF Section_num=0 THEN 
	Front_cutoff= 1
ELSE
	Front_cutoff= 0
END IF

V1= FindNamedVar("Number_of_sections",WsVariationVars)
Number_of_sections= VariableValue(V1)
IF Section_num>= (Number_of_sections-1) THEN 
	Back_cutoff= 1
ELSE
	Back_cutoff= 0
END IF



V1= FindNamedVar("Screw_Hand",WsVariationVars)
IF ValidGeometry(V1) THEN
   Hand= VariableValue(V1)
ELSE
   Stat=SetInputFormat("a1=",",L,R,")
   Stat=SetEqualsValue(0,"R")
   Stat=GetValue("Left or Right HAND SCREW ",Answer$)
   IF ExitScript(Destination$) THEN Leave
   IF Answer$= "L" THEN
        Hand= WsLeft
   ELSE
        Hand= WsRight
   END IF
END IF

Ask_diameter:!
V1= FindNamedVar("Curr_Flight_Dia",WsVariationVars)
Screw_diameter= VariableValue(V1)

Stat=SetInputFormat("n4a1=",",C,")
Stat=SetEqualsValue(Screw_diameter)
Screw_diameter=GetValue("SCREW DIAMETER  Connect ",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "C" THEN
	Screw_diameter= VariableValue(V1)
	IF Screw_diameter>0 THEN
		Dia_var$= "Curr_flight_dia"
		No_dia_var=0
	ELSE
		GOTO Ask_diameter
	END IF
ELSE
	No_dia_var= LastVariableInput(Dia_var$)
END IF

Ask_start_pitch:!
V1= FindNamedVar("Curr_Flight_pitch",WsVariationVars)
Start_pitch= VariableValue(V1)

Stat=SetInputFormat("n4a1=",",C,")
Stat=SetEqualsValue(Start_pitch)
Start_pitch=GetValue("START PITCH   Connect",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "C" THEN
        Start_pitch= VariableValue(V1)
        IF Start_pitch>0 THEN
                Spitch_var$= "Curr_flight_pitch"
                No_spitch_var=0
        ELSE
                GOTO Ask_start_pitch
        END IF
ELSE
	No_spitch_var= LastVariableInput(Spitch_var$)
END IF

End_pitch= Start_pitch
Stat=SetInputFormat("n4a1=",",C,")
Stat=SetEqualsValue(End_pitch)
End_pitch=GetValue("END PITCH   Constant pitch",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "C" THEN
        End_pitch=0
        No_epitch_var=1
ELSE
	No_epitch_var= LastVariableInput(Epitch_var$)
END IF


Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Screw_length)
Screw_length=GetValue("SCREW SECTION LENGTH",Answer$)
IF ExitScript(Destination$) THEN Leave
No_length_var= LastVariableInput(Length_var$)

Ask_start_depth:!
V1= FindNamedVar("Curr_Flight_Depth",WsVariationVars)
Start_depth= VariableValue(V1)

Stat=SetInputFormat("n4a1=",",C,")
Stat=SetEqualsValue(Start_depth)
Start_depth=GetValue("START CHANNEL DEPTH   Connect ",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "C" THEN
        Start_depth= VariableValue(V1)
        IF Start_depth>0 THEN
                Sdepth_var$= "Curr_flight_depth"
                No_sdepth_var=0
        ELSE
                GOTO Ask_start_depth
        END IF
ELSE
	No_sdepth_var= LastVariableInput(Sdepth_var$)
END IF


End_depth= Start_depth
Stat=SetInputFormat("n4a1=",",C,")
Stat=SetEqualsValue(End_depth)
End_depth=GetValue("END CHANNEL DEPTH   Constant depth",Answer$)
IF ExitScript(Destination$) THEN Leave
No_edepth_var= LastVariableInput(Edepth_var$)
IF Answer$= "C" THEN
        End_depth=0
        No_edepth_var=1
ELSE
	No_edepth_var= LastVariableInput(Edepth_var$)
END IF


Ask_start_width:!
V1= FindNamedVar("Curr_Flight_Width",WsVariationVars)
Start_width= VariableValue(V1)

Stat=SetInputFormat("n4a1=",",C,")
Stat=SetEqualsValue(Start_width)
Start_width=GetValue("START FLIGHT WIDTH   Connect ",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "C" THEN
        Start_width= VariableValue(V1)
        IF Start_width>0 THEN
                Swidth_var$= "Curr_flight_width"
                No_swidth_var=0
        ELSE
                GOTO Ask_start_width
        END IF
ELSE
	No_swidth_var= LastVariableInput(Swidth_var$)
END IF

End_width= Start_width
Stat=SetInputFormat("n4a1=",",C,")
Stat=SetEqualsValue(End_width)
End_width=GetValue("END FLIGHT WIDTH    Constant width",Answer$)
IF ExitScript(Destination$) THEN Leave
No_ewidth_var= LastVariableInput(Ewidth_var$)
IF Answer$= "C" THEN
        End_width=0
        No_ewidth_var=1
ELSE
	No_ewidth_var= LastVariableInput(Ewidth_var$)
END IF



Ask_slead_radius:!
V1= FindNamedVar("Curr_lead_radius",WsVariationVars)
SLeading_radius= VariableValue(V1)

Stat=SetInputFormat("n4a1=",",C,")
Stat=SetEqualsValue(SLeading_radius)
SLeading_radius=GetValue("START LEADING RADIUS  Connect ",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "C" THEN
        SLeading_radius= VariableValue(V1)
        IF SLeading_radius>0 THEN
                SLead_rad_var$= "Curr_lead_radius"
                No_slead_rad_var=0
        ELSE
                GOTO Ask_slead_radius
        END IF
ELSE
        No_slead_rad_var= LastVariableInput(SLead_rad_var$)
END IF

Ask_elead_radius:!
ELeading_radius= Sleading_radius

Stat=SetInputFormat("n4a1=",",C,")
Stat=SetEqualsValue(ELeading_radius)
ELeading_radius=GetValue("END LEADING RADIUS  Const ",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "C" THEN
        ELeading_radius= 0
         No_elead_rad_var=1
ELSE
        No_elead_rad_var= LastVariableInput(ELead_rad_var$)
END IF


Ask_strail_radius:!
V1= FindNamedVar("Curr_trail_radius",WsVariationVars)
STrailing_radius= VariableValue(V1)

Stat=SetInputFormat("n4a1=",",C,")
Stat=SetEqualsValue(STrailing_radius)
STrailing_radius=GetValue("START TRAILING RADIUS  Connect ",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "C" THEN
        STrailing_radius= VariableValue(V1)
        IF STrailing_radius>0 THEN
                STrail_rad_var$= "Curr_trail_radius"
                No_strail_rad_var=0
        ELSE
                GOTO Ask_strail_radius
        END IF
ELSE
        No_strail_rad_var= LastVariableInput(STrail_rad_var$)
END IF

Ask_etrail_radius:!
ETrailing_radius= Strailing_radius

Stat=SetInputFormat("n4a1=",",C,")
Stat=SetEqualsValue(ETrailing_radius)
ETrailing_radius=GetValue("END TRAILING RADIUS  Const ",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "C" THEN
        ETrailing_radius= 0
         No_etrail_rad_var=1
ELSE
        No_etrail_rad_var= LastVariableInput(ETrail_rad_var$)
END IF


Ask_start_angle:!
V1= FindNamedVar("Curr_Flight_Angle",WsVariationVars)
Start_angle= VariableValue(V1)

Stat=SetInputFormat("n4a1=",",C,")
Stat=SetEqualsValue((Start_angle MOD 360))
Start_angle=GetValue("START ANGLE   Connect",Answer$)
IF ExitScript(Destination$) THEN Leave
No_sangle_var= LastVariableInput(Sangle_var$)
IF Answer$= "C" THEN
        Start_angle= VariableValue(V1)
        IF ValidGeometry(V1) THEN
                Sangle_var$= "Curr_flight_angle"
                No_sangle_var=0
        ELSE
                GOTO Ask_start_angle
        END IF
ELSE
	No_sangle_var= LastVariableInput(Sangle_var$)
END IF

GOTO Make_record


Make_questions:!
FOR I=1 TO 20
	Question$(I)=""
	Reply$(I)=""
NEXT I

V1= FindNamedVar("Curr_Section",WsVariationVars)
Curr_section= VariableValue(V1)
V1= FindNamedVar("Screw_Hand",WsVariationVars)
Hand= VariableValue(V1)
V1= FindNamedVar("Curr_Flight_Dia",WsVariationVars)
Screw_diameter= VariableValue(V1)
V1= FindNamedVar("Curr_Flight_pitch",WsVariationVars)
Start_pitch= VariableValue(V1)
V1= FindNamedVar("Curr_Flight_Depth",WsVariationVars)
Start_depth= VariableValue(V1)
V1= FindNamedVar("Curr_Flight_Width",WsVariationVars)
Start_width= VariableValue(V1)
V1= FindNamedVar("Curr_lead_radius",WsVariationVars)
SLeading_radius= VariableValue(V1)
Eleading_radius= Sleading_radius
V1= FindNamedVar("Curr_trail_radius",WsVariationVars)
STrailing_radius= VariableValue(V1)
Etrailing_radius= Strailing_radius
V1= FindNamedVar("Curr_Flight_Angle",WsVariationVars)
Start_angle= VariableValue(V1)

Question$(1)= "SECTION TYPE: "
Reply$(1)= Section_type$

Question$(2)= "NUMBER OF FLIGHTS:  "
Reply$(2)= "1"

Question$(3)= "Left or Right HAND SCREW:  "
Reply$(3)= RPT$("L",Hand= WsLeft)&RPT$("R", Hand<>WsLeft)

Question$(4)= "SCREW DIAMETER:  "
IF Curr_section THEN
	Reply$(4)= "Connect  ("&VAL$(Screw_diameter)&")"
ELSE
	Reply$(4)= VAL$(Screw_diameter)
END IF

Question$(5)= "START PITCH:  "
IF Curr_section THEN
	Reply$(5)= "Connect  ("&VAL$(Start_pitch)&")"
ELSE
	Reply$(5)= VAL$(Start_pitch)
END IF

Question$(6)= "END PITCH:  "
IF Curr_section THEN
	Reply$(6)= "Const"
ELSE
	Reply$(6)= VAL$(Start_pitch)
END IF

Question$(7)= "SCREW SECTION LENGTH:  "
Reply$(7)= VAL$(Screw_length)

Question$(8)= "START CHANNEL DEPTH:  "
IF Curr_section THEN
	Reply$(8)= "Connect  ("&VAL$(Start_depth)&")"
ELSE
	Reply$(8)= VAL$(Start_depth)
END IF

Question$(9)= "END CHANNEL DEPTH:  "
IF Curr_section THEN
	Reply$(9)= "Const"
ELSE
	Reply$(9)= VAL$(Start_depth)
END IF

Question$(10)= "START FLIGHT WIDTH:  "
IF Curr_section THEN
	Reply$(10)= "Connect  ("&VAL$(Start_width)&")"
ELSE
	Reply$(10)= VAL$(Start_width)
END IF

Question$(11)= "END FLIGHT WIDTH:  "
IF Curr_section THEN
	Reply$(11)= "Const"
ELSE
	Reply$(11)= VAL$(Start_width)
END IF

Question$(12)= "START LEADING RADIUS:  "
Reply$(12)= VAL$(SLeading_radius)

Question$(13)= "END LEADING RADIUS:  "
Reply$(13)= VAL$(ELeading_radius)

Question$(14)= "START TRAILING RADIUS:  "
Reply$(14)= VAL$(STrailing_radius)

Question$(15)= "END TRAILING RADIUS:  "
Reply$(15)= VAL$(ETrailing_radius)

Question$(16)= "START ANGLE:  "
IF Curr_section THEN
	Reply$(16)= "Connect  ("&VAL$(Start_angle)&")"
ELSE
	Reply$(16)= VAL$(Start_angle MOD 360)
END IF

Question$(17)= "FRONT CUTOFF:  "
Reply$(17)= "0"

Question$(18)= "BACK CUTOFF:  "
Reply$(18)= "0"

Input_box:!
Stat= DisplayMessage(" ")
Stat=ChangeLabelStr("MultiLineShell","Reference Entity Prompts")
Input_stat=MultiInput(Question$(*),Reply$(*),0)
IF (ExitScript(Destination$)) THEN Leave
IF Input_stat=27 THEN Leave
Stat= DisplayMessage(" ")

Analyze_answers:!
A$= Reply$(1)
Answer$= TRIM$(A$)
SELECT Answer$
CASE "F","f","Feed"
        Section_type$="Feed"
CASE "M","m","Meter"
        Section_type$="Meter"
CASE "T","t","Transition"
        Section_type$="Transition"
CASE "V","v","Vent"
        Section_type$="Vent"
CASE ELSE
	GOTO Input_box
END SELECT

A$= Reply$(2)
Answer$= TRIM$(A$)
IF NOT IsStringNumeric(Answer$) THEN Input_box
Nflights= VAL(Answer$)
IF Nflights< 1 THEN Input_box

A$= Reply$(3)
Answer$= TRIM$(A$)
IF Answer$="L" OR Answer$="l" THEN 
	Hand= WsLeft
ELSE
	Hand= WsRight
END IF

A$= Reply$(4)
Answer$= TRIM$(A$)
IF Answer$= "C" OR Answer$="c" OR (POS(Answer$,"Connect")>0) THEN
	V1= FindNamedVar("Curr_Flight_Dia",WsVariationVars)
        Screw_diameter= VariableValue(V1)
        IF Screw_diameter>0 THEN
                Dia_var$= "Curr_flight_dia"
                No_dia_var=0
        ELSE
                GOTO Input_box
        END IF
ELSE
	IF NOT IsStringNumeric(Answer$) THEN Input_box
	Screw_diameter= VAL(Answer$)
	IF Screw_diameter< 0.001 THEN Input_box
        No_dia_var=1
END IF

A$= Reply$(5)
Answer$= TRIM$(A$)
IF Answer$= "C" OR Answer$="c" OR (POS(Answer$,"Connect")>0) THEN
	V1= FindNamedVar("Curr_Flight_pitch",WsVariationVars)
        Start_pitch= VariableValue(V1)
        IF Start_pitch>0 THEN
                Spitch_var$= "Curr_flight_pitch"
                No_spitch_var=0
        ELSE
                GOTO Input_box
        END IF
ELSE
	IF NOT IsStringNumeric(Answer$) THEN Input_box
	Start_pitch= VAL(Answer$)
	IF Start_pitch< 0.001 THEN Input_box
        No_spitch_var=1
END IF

A$= Reply$(6)
Answer$= TRIM$(A$)
IF Answer$= "C" OR Answer$="c" OR (POS(Answer$,"Const")>0) THEN
        End_pitch=0
        No_epitch_var=1
ELSE
	End_pitch= VAL(Answer$)
	IF End_pitch< 0.001 THEN Input_box
        No_epitch_var=1
END IF

A$= Reply$(7)
Answer$= TRIM$(A$)
IF NOT IsStringNumeric(Answer$) THEN Input_box
Screw_length= VAL(Answer$)
IF Screw_length< 0.001 THEN Input_box
No_length_var=1

A$= Reply$(8)
Answer$= TRIM$(A$)
IF Answer$= "C" OR Answer$="c" OR (POS(Answer$,"Connect")>0) THEN
	V1= FindNamedVar("Curr_Flight_Depth",WsVariationVars)
        Start_depth= VariableValue(V1)
        IF Start_depth>0 THEN
                Sdepth_var$= "Curr_flight_depth"
                No_sdepth_var=0
        ELSE
                GOTO Input_box
        END IF
ELSE
	IF NOT IsStringNumeric(Answer$) THEN Input_box
	Start_depth= VAL(Answer$)
	IF Start_depth< 0.001 THEN Input_box
        No_sdepth_var= 1
END IF


A$= Reply$(9)
Answer$= TRIM$(A$)
IF Answer$= "C" OR Answer$="c" OR (POS(Answer$,"Const")>0) THEN
        End_depth=0
        No_edepth_var=1
ELSE
	IF NOT IsStringNumeric(Answer$) THEN Input_box
	End_depth= VAL(Answer$)
	IF End_depth< 0.001 THEN Input_box
        No_edepth_var=1
END IF

A$= Reply$(10)
Answer$= TRIM$(A$)
IF Answer$= "C" OR Answer$="c" OR (POS(Answer$,"Connect")>0) THEN
	V1= FindNamedVar("Curr_Flight_Width",WsVariationVars)
        Start_width= VariableValue(V1)
        IF Start_width>0 THEN
                Swidth_var$= "Curr_flight_width"
                No_swidth_var=0
        ELSE
                GOTO Input_box
        END IF
ELSE
	IF NOT IsStringNumeric(Answer$) THEN Input_box
        Start_width= VAL(Answer$)
	IF Start_width< 0.001 THEN Input_box
        No_swidth_var=1
END IF

A$= Reply$(11)
Answer$= TRIM$(A$)
IF Answer$= "C" OR Answer$="c" OR (POS(Answer$,"Const")>0) THEN
        End_width=0
        No_ewidth_var=1
ELSE
	IF NOT IsStringNumeric(Answer$) THEN Input_box
	End_width=VAL(Answer$)
	IF End_width< 0.001 THEN Input_box
        No_ewidth_var=1
END IF

A$= Reply$(12)
Answer$= TRIM$(A$)
IF Answer$= "C" OR Answer$="c" OR (POS(Answer$,"Connect")>0) THEN
	V1= FindNamedVar("Curr_lead_radius",WsVariationVars)
        SLeading_radius= VariableValue(V1)
        IF SLeading_radius>0 THEN
                SLead_rad_var$= "Curr_lead_radius"
                No_slead_rad_var=0
        ELSE
                GOTO Input_box
        END IF
ELSE
	IF NOT IsStringNumeric(Answer$) THEN Input_box
	SLeading_radius=VAL(Answer$)
        No_slead_rad_var=1
END IF

A$= Reply$(13)
Answer$= TRIM$(A$)
IF Answer$= "C" OR Answer$="c" OR (POS(Answer$,"Const")>0) THEN
        ELeading_radius= 0
        No_elead_rad_var=1
ELSE
	IF NOT IsStringNumeric(Answer$) THEN Input_box
	ELeading_radius=VAL(Answer$)
        No_elead_rad_var=1
END IF


A$= Reply$(14)
Answer$= TRIM$(A$)
IF Answer$= "C" OR Answer$="c" OR (POS(Answer$,"Connect")>0) THEN
        V1= FindNamedVar("Curr_trail_radius",WsVariationVars)
        STrailing_radius= VariableValue(V1)
        IF STrailing_radius>0 THEN
                STrail_rad_var$= "Curr_trail_radius"
                No_strail_rad_var=0
        ELSE
                GOTO Input_box
        END IF
ELSE
        IF NOT IsStringNumeric(Answer$) THEN Input_box
        STrailing_radius=VAL(Answer$)
        No_strail_rad_var=1
END IF

A$= Reply$(15)
Answer$= TRIM$(A$)
IF Answer$= "C" OR Answer$="c" OR (POS(Answer$,"Const")>0) THEN
        ETrailing_radius= 0
        No_etrail_rad_var=1
ELSE
	IF NOT IsStringNumeric(Answer$) THEN Input_box
	ETrailing_radius=VAL(Answer$)
        No_etrail_rad_var=1
END IF


A$= Reply$(16)
Answer$= TRIM$(A$)
IF Answer$= "C" OR Answer$="c" OR (POS(Answer$,"Connect")>0) THEN
	V1= FindNamedVar("Curr_Flight_Angle",WsVariationVars)
        Start_angle= VariableValue(V1)
        IF ValidGeometry(V1) THEN
                Sangle_var$= "Curr_flight_angle"
                No_sangle_var=0
        ELSE
                GOTO Input_box
        END IF
ELSE
        IF NOT IsStringNumeric(Answer$) THEN Input_box
        Start_angle=VAL(Answer$)
        No_sangle_var=1
END IF

A$= Reply$(17)
Answer$= TRIM$(A$)
IF NOT IsStringNumeric(Answer$) THEN Input_box
Front_cutoff= VAL(Answer$)

A$= Reply$(18)
Answer$= TRIM$(A$)
IF NOT IsStringNumeric(Answer$) THEN Input_box
Back_cutoff= VAL(Answer$)

PlotAll


Make_record:!
WPKClearErrorFlag
Stat= GenerateVarName(WsGroupEnt,Name$)
Stat= GenerateVarName(WsPointEnt,Pname$)
Stat= GenerateVarName(WsPointEnt,Prop_name$)
RecordFunctionOn
Stat= RecordDescr("SCREW: Simple")
Stat= DisplayMessage("Current Section #"&VAL$(VariableValue("Curr_section")+1))
V19= FreeParameter("Number of flights", Nflights)
V1= FreeParameter("Hand",Hand)
IF No_dia_var THEN
        V2= FreeParameter("Screw Diameter",Screw_diameter)
ELSE
        V2= FreeParameter("Screw Diameter",Dia_var$)
END IF
IF No_spitch_var THEN
        V3= FreeParameter("Start pitch",Start_pitch)
ELSE
        V3= FreeParameter("Start pitch",Spitch_var$)
END IF
IF No_epitch_var THEN
	IF End_pitch=0 THEN
        	V4= FreeParameter("End pitch",V3)
	ELSE
        	V4= FreeParameter("End pitch",End_pitch)
	END IF
ELSE
        V4= FreeParameter("End pitch",Epitch_var$)
END IF
IF No_length_var THEN
        V5= FreeParameter("Section Length",Screw_length)
ELSE
        V5= FreeParameter("Section Length",Length_var$)
END IF
IF No_sdepth_var THEN
        V6= FreeParameter("Start channel depth",Start_depth)
ELSE
        V6= FreeParameter("Start channel depth",Sdepth_var$)
END IF
IF No_edepth_var THEN
	IF End_depth=0 THEN
        	V7= FreeParameter("End channel depth",V6)
	ELSE
        	V7= FreeParameter("End channel depth",End_depth)
	END IF
ELSE
        V7= FreeParameter("End channel depth",Edepth_var$)
END IF
IF No_swidth_var THEN
        V8= FreeParameter("Start flight width",Start_width)
ELSE
        V8= FreeParameter("Start flight width",Swidth_var$)
END IF
IF No_ewidth_var THEN
	IF End_width=0 THEN
        	V9= FreeParameter("End flight width",V8)
	ELSE
        	V9= FreeParameter("End flight width",End_width)
	END IF
ELSE
        V9= FreeParameter("End flight width",Ewidth_var$)
END IF
IF No_slead_rad_var THEN
        V31= FreeParameter("Start leading radius",SLeading_radius)
ELSE
        V31= FreeParameter("Start leading radius",SLead_rad_var$)
END IF
IF No_elead_rad_var THEN
        V32= FreeParameter("End leading radius",ELeading_radius)
ELSE
        V32= FreeParameter("End leading radius",ELead_rad_var$)
END IF
IF No_strail_rad_var THEN
        V33= FreeParameter("Start Trailing radius",STrailing_radius)
ELSE
        V33= FreeParameter("Start Trailing radius",STrail_rad_var$)
END IF
IF No_etrail_rad_var THEN
        V34= FreeParameter("End Trailing radius",ETrailing_radius)
ELSE
        V34= FreeParameter("End Trailing radius",ETrail_rad_var$)
END IF
IF No_sangle_var THEN
        V10= FreeParameter("Start angle",Start_angle)
ELSE
        V10= FreeParameter("Start angle",Sangle_var$)
END IF
Workr= CurrentWorkplane
Stat= SetWorkplane
Ps= PointXYZ(VariableValue("Curr_Start_Length"),0,0)
Pt= PointXYZ(0,0,0)
T1=AngleTransform(Pt,90,-90,0)
Stat=SetWorkplane(T1)
Stat= DeleteEntity(Pt)
V11= FreeParameter("Left Wall angle",Left_wall_angle)
V12= FreeParameter("Right Wall angle",Right_wall_angle)
V13= FreeParameter("Zstart ",ZPointValue(Ps))
V14= FreeParameter("Angular step", Astep)
V15= FreeParameter("Flight od taper", 0.0)
V16= FreeParameter("Flight taper type", 1)
V17= FreeParameter("Front Cutoff", Front_cutoff)
V18= FreeParameter("Back Cutoff", Back_cutoff)

Prop_data= CreateUserData(20010,"Screw",CHR$(10))
Stat= PutUserString(Prop_data,"Class name:","Extrusion Screw")
Stat= PutUserValue(Prop_data,"Class id number:",20010)
Stat= PutUserString(Prop_data,"Name:","Simple Screw")
IF Hand= WsRight THEN
	Stat= PutUserString(Prop_data,"Hand:","Right")
ELSE
	Stat= PutUserString(Prop_data,"Hand:","Left")
END IF
Stat= PutUserValue(Prop_data,"Section number:",(VariableValue("Curr_Section")))
Stat= PutUserString(Prop_data,"Section type:",Section_type$)
Stat= PutUserValue(Prop_data,"Number of flights:",V19)
Stat= PutUserValue(Prop_data,"Screw diameter:",V2)
Stat= PutUserValue(Prop_data,"Section length:",V5)
Stat= PutUserValue(Prop_data,"Start pitch:",V3)
Stat= PutUserValue(Prop_data,"End pitch:",V4)
Stat= PutUserValue(Prop_data,"Start flight width:",V8)
Stat= PutUserValue(Prop_data,"End flight width:",V9)
Stat= PutUserValue(Prop_data,"Start channel depth:",V6)
Stat= PutUserValue(Prop_data,"End channel depth:",V7)
Stat= PutUserValue(Prop_data,"Start leading radius:",V31)
Stat= PutUserValue(Prop_data,"End leading radius:",V32)
Stat= PutUserValue(Prop_data,"Start trailing radius:",V33)
Stat= PutUserValue(Prop_data,"End trailing radius:",V34)
Stat= PutUserValue(Prop_data,"Leading flank angle:",V11)
Stat= PutUserValue(Prop_data,"Trailing flank angle:",V12)
Stat= PutUserValue(Prop_data,"Flight od taper:",V15)
Stat= PutUserValue(Prop_data,"Flight od taper type:",V16)
Stat= PutUserValue(Prop_data,"Front cutoff type:",V17)
Stat= PutUserValue(Prop_data,"Back cutoff type:",V18)
Stat= PutUserValue(Prop_data,"Angular step:",V14)
Stat= NameEntity(Prop_data,Prop_name$)
Bodygroup= WPKSimpleScrew(Prop_data,V13,V10);
Stat= WPKNameBodyGroup(Bodygroup,Name$)
Stat= WPKSetBodyParent(Bodygroup,1)
Stat= DeleteEntity(Bodygroup)
Stat= SetWorkplane
Pe= PtIncrXyz(Ps,V5,0,0)
Stat= NameEntity(Pe,Pname$)
V22= FreeParameter("Current_Section_Number",VariableValue("Curr_Section"))
V22=NumericVariable("Curr_Section",WsVariationVars,(VariableValue(V22)+1))
V22=NumericVariable("Screw_Hand",WsVariationVars,V1)
V22=NumericVariable("Curr_Flight_Dia",WsVariationVars,V2)
V23=NumericVariable("Curr_Flight_Pitch",WsVariationVars,V4)
V23=NumericVariable("Curr_Flight_Depth",WsVariationVars,V7)
V24=NumericVariable("Curr_Flight_Width",WsVariationVars,V9)
V25= FreeParameter("Flight_End_Angle", VarPitchAngle(V1,V3,V4,V5,V10))
V26=NumericVariable("Curr_Flight_Angle",WsVariationVars,V25)
V27=NumericVariable("Curr_Start_Length",WsVariationVars,XPointValue(Pe))
V28=NumericVariable("Curr_Lead_Radius",WsVariationVars,V32)
V29=NumericVariable("Curr_Trail_Radius",WsVariationVars,V34)
Stat=SetWorkplane(Workr)
Stat= DeleteEntityList(Ps)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= WPKSolidRecordOn(Curr_record)
ActivateUndo
Stat= AdvanceUndoNumber("simple screw")
Stat= AddItemToUndo(WsUBCreateMode,Pname$)
Stat= AddItemToUndo(WsUBCreateMode,Prop_name$)
Stat= AddItemToUndo(WsUBPKSessionMark)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
WPKErrorCheck

ResizeAll


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




