
! script name: milacron.d/weldgroovesegment
! var_solids: make a weld groove body on a flight segment

!A
!A NAME:
!A
!A 	Weld Groove Segment   VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script make a weld groove on a segement of the flight OD.
!A
!B INSTRUCTIONS:
!B
!B
!B NOTES:
!B
!B
!# see also - htdocs/help.d/parasolids.htm


stat=ChangeLabelStr("ScriptNameStatus","Function: weld groove segment ")

OPTION BASE 1
DIM Destination$[256]
DIM Answer$[256]
DIM Facename$[256]
DIM Bodyname$[256]
DIM Name$[256]
DIM Wclear_var$[256]
DIM Wdepth_var$[256]

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

Pick_color=2

Stat= GLPlotOn
Start:!
Weld_clearance=NamedVarVal("weld clearance",WsSystemVars,2.0)
Stat=SetEqualsValue(Weld_clearance)
Stat=SetInputFormat("n4=","")

Weld_clearance=GetValue("WELD GROOVE CLEARANCE",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_wclear_var= LastVariableInput(WClear_var$)
V1=CreateVariable("weld clearance",WsSystemVars,Weld_clearance)

Weld_depth=NamedVarVal("weld depth",WsSystemVars,2.0)
Stat=SetEqualsValue(Weld_depth)
Stat=SetInputFormat("n4=","")

Weld_depth=GetValue("WELD GROOVE DEPTH",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_wdepth_var= LastVariableInput(Wdepth_var$)
V1=CreateVariable("weld depth",WsSystemVars,Weld_depth)


Face_loop:!
Stat=SetInputFormat("a1",",N,")
E1=WPKPickEntity("PICK FACE",WsPKPickFace,Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "N"
	GOTO Start
END SELECT

IF NOT WPKIsEntity(E1) THEN Face_loop
Face1= WPKEntityTag(E1)
Facename$= WPKEntityName(Face1)
Bodyname$= WPKBodyName(Face1)


WPKClearErrorFlag
Stat= GenerateVarName("Body",Name$)
RecordFunctionOn
Stat= RecordDescr("SOLID: weld groove body")
IF No_wclear_var THEN
        V1= FreeParameter("Weld groove clearance",Weld_clearance)
ELSE
        V1= FreeParameter("Weld groove clearance",Wclear_var$)
END IF
IF No_wdepth_var THEN
        V2= FreeParameter("Weld groove depth",Weld_depth)
ELSE
        V2= FreeParameter("Weld groove depth",Wdepth_var$)
END IF
V3= FreeParameter("Offset",(VariableValue(V1)+VariableValue(V2)))
PlotOff
Pkbody= WPKCopyFace(Facename$)
E2= WPKThickenSheet(Pkbody,V3,V3)
E3= WPKOffsetBody(Pkbody,(-VariableValue(V1)))
Stat= WPKNameBody(Pkbody,Name$)
Stat= WPKSetBodyParent(Pkbody)
Stat= SetSubAssembly(Name$,2000)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
PlotOn

Stat=WPKUpdateBody(Name$)

PlotAll
Stat= WPKSolidRecordOn(Curr_record)
ActivateUndo
Stat= AdvanceUndoNumber("weld groove body")
Stat= AddItemToUndo(WsUBPKSessionMark)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
WPKErrorCheck
GOTO Face_loop


Leave:!
Stat= DeleteGroup(Mark_group,WsTrue)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
