
! script name: vpkscrews.d/vpkunflightedsection
! solids: creates an unflighted screw section
!A
!A NAME:
!A
!A 	Unflighted Section:   VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	This script creates an unflighted section
!A
!B INSTRUCTIONS:
!B
!B
!B
!B NOTES:
!B
!B
!B
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: unflighted section ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Body$[256]
DIM Pname$[256]
DIM Prop_name$[256]
DIM A$[256]

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

Start:!
Stat= GLPlotOn

Section_length= 0.35


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

Pointed_end=0
Stat=SetInputFormat("a1=",",C,F,P,")
Stat=SetEqualsValue(0,"C")
stat=GetValue("Conical, Pointed,  or Flat END",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$="C" THEN Conical_end=1
IF Answer$="F" THEN Conical_end=0
IF Answer$="P" THEN 
	Conical_end=1
	Pointed_end=1
END IF

IF (Conical_end AND NOT Pointed_end) THEN
   Stat=SetInputFormat("n4=")
   End_depth= VariableValue(Curr_flight_depth)
   Stat=SetEqualsValue(End_depth)
   End_depth=GetValue("END DEPTH",Answer$)
   IF ExitScript(Destination$) THEN Leave
END IF



WPKClearErrorFlag
Stat= GenerateVarName("Body",Name$)
Stat= GenerateVarName(WsPointEnt,Pname$)
Stat= GenerateVarName(WsPointEnt,Prop_name$)
RecordFunctionOn
V1=FreeParameter("Section length",Section_length)
Stat= RecordDescr("SCREW: Unflighted")
Ps=PointXYZ("Curr_start_length",0,0)
Pe=PtIncrXYZ(Ps,V1,0,0)
Stat= NameEntity(Pe,Pname$)
IF NOT Conical_end THEN
C1=WPKCylinder(Ps,Pe,"Curr_flight_dia/2-Curr_flight_depth",V1)
ELSE
   IF Pointed_end THEN
      V3=FreeParameter("Radius2",0.001)
      C1=WPKCone(Ps,Pe,"Curr_flight_dia/2-Curr_flight_depth",V3,V1)
      V22=NumericVariable("Curr_flight_depth",WsVariationVars,"Curr_flight_dia/2")
   ELSE
      V2=FreeParameter("End depth",End_depth)
      V3=FreeParameter("Radius2",VariableValue("Curr_flight_dia")/2-VariableValue(V2))
      C1=WPKCone(Ps,Pe,"Curr_flight_dia/2-Curr_flight_depth",V3,V1)
      V22=NumericVariable("Curr_flight_depth",WsVariationVars,VariableValue(V2))
      END IF
END IF
Stat=WPKNameBody(C1,Body$)
PkInstance= WPKCreateInstance(FindNamedEntity("ScrewAssembly"),C1)
Stat=WPKSetBodyParent(C1)
V1=NumericVariable("Curr_start_length",WsVariationVars,XPointValue(Pe))
V22= FreeParameter("Current_Section_Number",VariableValue("Curr_Section"))
V22=NumericVariable("Curr_Section",WsVariationVars,(VariableValue(V22)+1))
Stat=DeleteEntity(Ps)
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:","Unflighted Section")
Stat= PutUserString(Prop_data,"Section type:","Unflighted")
Stat=PutUserValue(Prop_data,"Screw diameter:","Curr_flight_dia")
Stat=PutUserValue(Prop_data,"End channel depth:","Curr_flight_depth")
Stat=PutUserValue(Prop_data,"Section length:",Section_length)
Stat= PutUserValue(Prop_data,"Section number:",(VariableValue("Curr_Section")))
Stat= NameEntity(Prop_data,Prop_name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord


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


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




