
! script name: vsurfaces.d/offsetsurf
! var_topic: make offset surface from a  surface

!A
!A NAME:
!A
!A 	Offset: Single	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a surface to have an offset surface made from it.
!A
!B INSTRUCTIONS:
!B
!B 	PICK SURFACE: Pick the surface.
!B
!B	OFFSET: Enter the offset amount to be used for the surface.
!B
!C NOTES:
!C
!C 	An offset surface is one of the standard surfaces offset in the
!C 	normal direction by the offset amount.

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

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

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

Offset= 1.0

ActivateUndo
Start:!
Stat=SetInputFormat("n4","")

Stat=SetPickMask(WsPickSurfOnly)
Stat=SetInputFormat("n0","")
Surf=PickEntity("PICK SURFACE",Answer$)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Surf) THEN Start
Stat= EntityNameCheck(Surf,Surface$)
Stat=SetPickMask(WsPickAll)

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

Stat= GenerateVarName(WsOffsetSurfEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("OFFSET: Surface")
Stat= SetRecDelLastExec
IF No_offset_var THEN
        V1= FreeParameter("Offset",Offset)
ELSE
        V1= FreeParameter("Offset",Offset_var$)
END IF
S1=OffsetSurface(Surface$,V1)
Stat= NameEntity(S1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(S1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("offset surf")
	Stat= AddItemToUndo(WsUBCreateMode,S1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF

GOTO Start

Leave:!
Stat=SetPickMask(WsPickAll)
Stat=SetInputFormat("n4","")

IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END

