
! script name: vpksolids.d/vpkedgegroupchamfer
! var_solids: set chamfer on an edge group


!A
!A NAME:
!A
!A 	Blend: Edge Group Chamfer  VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script sets a blend chamfer on an edge group.
!A
!A~ image location - images/pkchamfer.gif
!A
!B INSTRUCTIONS:
!B
!B	PICK EDGE GROUP: Pick the edge group
!B		
!C NOTE:
!C
!C	It may be possible that some chamfers which do not work properly
!C	when in propagate mode will work if each individual edge is
!C	selected and then are collectively fixed.
!C
!# see also - htdocs/help.d/parasolids.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: set edge chamfer ")

OPTION BASE 1
DIM Destination$[256]
DIM Answer$[256]
DIM Edge_group$[256]
DIM Chamfer_var$[256]
DIM Bodyname$[256]


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

Chamfer_len=NamedVarVal("solid chamfer length",WsPKSolidsVars,0.0)
Angle_tol=NamedVarVal("solid blend propagate angle",WsPKSolidsVars,1.0)

Stat= GLPlotOn
Start:!
Propagate= WsFalse
Stat= SetEqualsValue(Chamfer_len)
Stat=SetInputFormat("n4=","")
Chamfer_len=GetValue("CHAMFER LENGTH")
IF ExitScript(Destination$) THEN Leave
No_chamfer_var= LastVariableInput(Chamfer_var$)
V1=CreateVariable("solid chamfer length",WsPKSolidsVars,Chamfer_len)


E1=WPKPickEntity("PICK EDGE GROUP",WsPKPickEdge)
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Start

Body= WPKParentBody(E1)
Pkgroup= WPKContainingGroup(E1,1)
IF NOT WPKIsEntity(Pkgroup) THEN Start

Stat= EntityNameCheck(Pkgroup,Edgegroup$)
Stat= EntityNameCheck(Body,Bodyname$)

WPKClearErrorFlag
RecordFunctionOn
Stat= RecordDescr("BLEND: Chamfer Edge Group")
V1= FreeParameter("Propagate on",Propagate)
V4= FreeParameter("Propagate angle",Angle_tol)
IF No_chamfer_var THEN
        V5= FreeParameter("Chamfer",Chamfer_len)
ELSE
        V5= FreeParameter("Chamfer",Chamfer_var$)
END IF
Stat= WPKEdgeChamfer(Edgegroup$,V5,V5,V1)
Stat= WPKFixBlends(Bodyname$,V1,V4)
Stat= WPKNameBody(Bodyname$,Bodyname$)
Stat= WPKSetBodyParent(Bodyname$,1)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

ActivateUndo
Stat= WPKSolidRecordOn(Curr_record)
Stat= AdvanceUndoNumber("chamfer edge group")
Stat= AddItemToUndo(WsUBPKSessionMark)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
WPKErrorCheck

Leave:!
V3=CreateVariable("solid blend propagate angle",WsPKSolidsVars,Angle_tol)
Stat= DeleteGroup(Group,WsTrue)
Stat=SetInputFormat("n4","")
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
