
! script name: milacron.d/profiledisk
! var_topic: creates a disk sheet body

!A
!A NAME:
!A
!A 	Profile Disk Sheet Body VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	Creates a sheet body for simulation. The body matches the od diameter of the
!A	screw sliced perpendicular to the axis.
!A
!B INSTRUCTIONS:
!B
!B
!B
!C NOTES:
!C
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: profile disk sheet body ")

DIM Destination$[256]
DIM Answer$[256]
DIM Section_name$[256]
DIM SectionID$[256]
DIM Name$[256]

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


ActivateUndo
Start:!

Ask_value:!
Stat=SetPickReturn(WsGeometryX)
Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Xvalue)
Xvalue=GetValue("X VALUE",Answer$)
IF ExitScript(Destination$) THEN Leave


Stat= GenerateVarName("Body",Name$)
RecordFunctionOn
Stat= RecordDescr("SHEET BODY: radial profile sheet ")
V0= FreeParameter("X Value",Xvalue)
Prop_grp= GrpOfUserProps(20000,21000)
P1= GroupElement(Prop_grp,1)
P2= GroupElement(Prop_grp,9999)
V1= FreeParameter("Start Diameter",GetUserValue(P1,"Starting outer diameter:"))
V2= FreeParameter("End Diameter",GetUserValue(P2,"Ending outer diameter:"))
V3= FreeParameter("Total length",(GetUserValue(P2,"Xstart:")+GetUserValue(P2,"Section length:")))
V4= FreeParameter("Parameter1",(VariableValue(V0)/VariableValue(V3)))
V5= FreeParameter("Diameter",(VariableValue(V1)+VariableValue(V4)*(VariableValue(V2)-VariableValue(V1))))
Pc=PointXYZ(V0,0,0)
Trans1=AngleTransform(Pc,0.0,90.0,0.0,WsWorkplaneVals)
D1=Disk(Trans1,0.5*VariableValue(V5),0,360)
Pkbody=WPKBasicSolid(D1)
Stat= WPKNameBody(Pkbody,Name$)
Stat= WPKSetBodyParent(Pkbody)
Stat= DeleteEntity(D1)
Stat= DeleteEntity(Pc)
Stat= DeleteEntity(Prop_grp)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= WPKSolidRecordOn(Curr_record)
ActivateUndo
Stat= AdvanceUndoNumber("radial profile sheet body")
Stat= AddItemToUndo(WsUBPKSessionMark)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
WPKErrorCheck

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

END

