
! script name: vsurfaces.d/offsetpart
! var_topic: make offset surfaces from a group of surfaces

!A
!A NAME:
!A
!A 	Offset: Part	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will make offset surfaces from a group of surfaces.
!A
!B INSTRUCTIONS:
!B
!B 	PICK SURFACE GROUP: Pick the group of surfaces.
!B
!B	OFFSET: Enter the offset amount to be used for the surfaces.
!B
!C NOTES:
!C
!C 	An offset surface is one of the standard surfaces offset in the normal
!C 	direction by the offset amount.
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: offset surface group ")

DIM Answer$[256]
DIM Destination$[256]
DIM Part_group$[256]
DIM Name$[256]
DIM Offset_var$[256]

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

ActivateUndo
Offset= 1.0

Start:!
Stat=SetPickMask(WsPickSurfOnly)
Stat=SetInputFormat("n4","")
Part_group=PickGroupEnt("PICK SURFACE GROUP",WsSurfaceGroup)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Part_group) THEN Start
Stat= EntityNameCheck(Part_group,Part_group$)
Stat=SetPickMask(WsPickAll)

Stat=Highlight(Part_group,WsPickPen,WsDirArrowOff)

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Offset)
Offset=GetValue("OFFSET",Answer$)
IF ExitScript(Destination$) THEN Leave
No_offset_var= LastVariableInput(Offset_var$)


Stat= GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("OFFSET: Part")
Stat= SetRecDelLastExec
IF No_offset_var THEN
        V1= FreeParameter("Offset",Offset)
ELSE
        V1= FreeParameter("Offset",Offset_var$)
END IF
G1=OffsetSurfGrp(Part_group$,V1)
Stat= AutoNameGroup(G1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(G1) THEN
        DelLastVarRecord
ELSE
ActivateUndo
	Stat= AdvanceUndoNumber("offset part")
	Stat= AddGroupToUndo(WsUBCreateMode,G1,1,WsTrue)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF

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

